Documentation
¶
Index ¶
- Constants
- func OnionV3FromPubKey(pubKey ed25519.PublicKey) (string, error)
- func PubKeyFromOnionV3(onionAddress string) (ed25519.PublicKey, error)
- type AccountPathMapping
- type BlockFees
- type CbData
- type InitTxArgs
- type InitTxSendArgs
- type IssueInvoiceTxArgs
- type KernelFeaturesArgs
- type NodeHeightResult
- type OutputCommitMapping
- type OutputData
- type ParticipantData
- type PaymentInfo
- type SendTXArgs
- type Slate
- type StoredProofInfo
- type TorConfig
- type TxLogEntry
- type VersionCompatInfo
- type VersionInfo
- type WalletInfo
Constants ¶
const ( // UnknownSlateState coming from earlier versions of the slate UnknownSlateState slateState = iota // Standard1SlateState flow, freshly init Standard1SlateState // Standard2SlateState flow, return journey Standard2SlateState // Standard3SlateState flow, ready for transaction posting Standard3SlateState // Invoice1SlateState flow, freshly init Invoice1SlateState // Invoice2SlateState flow, return journey Invoice2SlateState // Invoice3SlateState flow, ready for tranasction posting Invoice3SlateState )
const ( // Unconfirmed output Unconfirmed outputStatus = iota // Unspent output Unspent // Locked output Locked // Spent output Spent )
const ( // ConfirmedCoinbase is a coinbase transaction becomes confirmed ConfirmedCoinbase txLogEntryType = iota // TxReceived are outputs created when a transaction is received TxReceived // TxSent are inputs locked + change outputs when a transaction is created TxSent // TxReceivedCancelled is a received transaction that was rolled back by user TxReceivedCancelled // TxSentCancelled is a sent transaction that was rolled back by user TxSentCancelled )
Variables ¶
This section is empty.
Functions ¶
func OnionV3FromPubKey ¶
OnionV3FromPubKey generates an onion address from an ed25519 public key
Types ¶
type AccountPathMapping ¶
type AccountPathMapping struct {
// label used by user
Label string
// Corresponding parent BIP32 derivation path
Path string
}
AccountPathMapping maps name accounts to BIP32 paths
type BlockFees ¶
type BlockFees struct {
// fees
Fees core.Uint64 `json:"fees"`
// height
Height core.Uint64 `json:"height"`
// key id
KeyID *keychain.Identifier `json:"key_id"`
}
BlockFees are the fees in block to use for coinbase amount calculation
type CbData ¶
type CbData struct {
// Output
Output core.Output `json:"output"`
// Kernel
Kernel core.TxKernel `json:"kernel"`
// Key Id
KeyID *keychain.Identifier `json:"key_id"`
}
CbData is the response to build a coinbase output.
type InitTxArgs ¶
type InitTxArgs struct {
// The human readable account name from which to draw outputs
// for the transaction, overriding whatever the active account is as set via the
// [`set_active_account`](../grin_wallet_api/owner/struct.Owner.html#method.set_active_account) method.
SrcAcctName *string `json:"src_acct_name"`
// The amount to send, in nanogrins. (`1 G = 1_000_000_000nG`)
Amount core.Uint64 `json:"amount"`
// The minimum number of confirmations an output
// should have in order to be included in the transaction.
MinimumConfirmations core.Uint64 `json:"minimum_confirmations"`
// By default, the wallet selects as many inputs as possible in a
// transaction, to reduce the Output set and the fees. The wallet will attempt to spend
// include up to `max_outputs` in a transaction, however if this is not enough to cover
// the whole amount, the wallet will include more outputs. This parameter should be considered
// a soft limit.
MaxOutputs uint32 `json:"max_outputs"`
// The target number of change outputs to create in the transaction.
// The actual number created will be `num_change_outputs` + whatever remainder is needed.
NumChangeOutputs uint32 `json:"num_change_outputs"`
// If `true`, attempt to use up as many outputs as
// possible to create the transaction, up the 'soft limit' of `max_outputs`. This helps
// to reduce the size of the UTXO set and the amount of data stored in the wallet, and
// minimizes fees. This will generally result in many inputs and a large change output(s),
// usually much larger than the amount being sent. If `false`, the transaction will include
// as many outputs as are needed to meet the amount, (and no more) starting with the smallest
// value outputs.
SelectionStrategyIsUseAll bool `json:"selection_strategy_is_use_all"`
// Optionally set the output target slate version (acceptable
// down to the minimum slate version compatible with the current. If `None` the slate
// is generated with the latest version.
TargetSlateVersion *uint16 `json:"target_slate_version"`
// Number of blocks from current after which TX should be ignored
TTLBlocks *core.Uint64 `json:"ttl_blocks"`
// If set, require a payment proof for the particular recipient
PaymentProofRecipientAddress *slatepack.SlatepackAddress `json:"payment_proof_recipient_address"`
// If true, just return an estimate of the resulting slate, containing fees and amounts
// locked without actually locking outputs or creating the transaction. Note if this is set to
// 'true', the amount field in the slate will contain the total amount locked, not the provided
// transaction amount
EstimateOnly *bool `json:"estimate_only"`
// Sender arguments. If present, the underlying function will also attempt to send the
// transaction to a destination and optionally finalize the result
SendArgs *InitTxSendArgs `json:"send_args"`
}
InitTxArgs is V3 Init / Send TX API Args
type InitTxSendArgs ¶
type InitTxSendArgs struct {
// The destination, contents will depend on the particular method
Dest string `json:"dest"`
// Whether to post the transaction if the send and finalize were successful
PostTx bool `json:"post_tx"`
// Whether to use dandelion when posting. If false, skip the dandelion relay
Fluff bool `json:"fluff"`
// If set, skip the Slatepack TOR send attempt
SkipTor bool `json:"skip_tor"`
}
InitTxSendArgs is the send TX API Args, for convenience functionality that inits the transaction and sends in one go
type IssueInvoiceTxArgs ¶
type IssueInvoiceTxArgs struct {
// The human readable account name to which the received funds should be added
// overriding whatever the active account is as set via the
// [`set_active_account`](../grin_wallet_api/owner/struct.Owner.html#method.set_active_account) method.
DestAcctName *string `json:"dest_acct_name"`
// The invoice amount in nanogrins. (`1 G = 1_000_000_000nG`)
Amount core.Uint64 `json:"amount"`
// Optional message, that will be signed
Message *string `json:"message"`
// Optionally set the output target slate version (acceptable
// down to the minimum slate version compatible with the current. If `None` the slate
// is generated with the latest version.
TargetSlateVersion *uint16 `json:"target_slate_version"`
}
IssueInvoiceTxArgs are the v2 Issue Invoice Tx Args
type KernelFeaturesArgs ¶
type KernelFeaturesArgs struct {
/// Lock height, for HeightLocked
LockHeight core.Uint64 `json:"lock_height"`
}
KernelFeaturesArgs are the kernel features arguments definition
type NodeHeightResult ¶
type NodeHeightResult struct {
// Last known height
Height core.Uint64 `json:"height"`
// Hash
HeaderHash string `json:"header_hash"`
// Whether this height was updated from the node
UpdatedFromNode bool `json:"updated_from_node"`
}
NodeHeightResult is the node height result
type OutputCommitMapping ¶
type OutputCommitMapping struct {
// Output Data
Output OutputData `json:"output"`
// The commit
Commit string `json:"commit"`
}
OutputCommitMapping is the map Outputdata to commits
type OutputData ¶
type OutputData struct {
// Root key_id that the key for this output is derived from
RootKeyID keychain.Identifier `json:"root_key_id"`
// Derived key for this output
KeyID keychain.Identifier `json:"key_id"`
// How many derivations down from the root key
NChild uint32 `json:"n_child"`
// The actual commit optionally stored
Commit *string `json:"commit"`
// PMMR Index, used on restore in case of duplicate wallets using the same
// key_id (2 wallets using same seed, for instance
MMRIndex *core.Uint64 `json:"mmr_index"`
// Value of the output, necessary to rebuild the commitment
Value core.Uint64 `json:"value"`
// Current status of the output
Status outputStatus `json:"status"`
// Height of the output
Height core.Uint64 `json:"height"`
// Height we are locked until
LockHeight core.Uint64 `json:"lock_height"`
// Is this a coinbase output? Is it subject to coinbase locktime?
IsCoinbase bool `json:"is_coinbase"`
// Optional corresponding internal entry in tx entry log
TxLogEntry *uint32 `json:"tx_log_entry"`
}
OutputData is the information about an output that's being tracked by the wallet. Must be enough to reconstruct the commitment associated with the output when the root private key is known.
type ParticipantData ¶
type ParticipantData struct {
// Public key corresponding to private blinding factor
PublicBlindExcess string `json:"public_blind_excess"`
// Public key corresponding to private nonce
PublicNonce string `json:"public_nonce"`
// Public partial signature
PartSig *string `json:"part_sig"`
}
ParticipantData is a public data for each participant in the slate
type PaymentInfo ¶
type PaymentInfo struct {
SenderAddress string `json:"sender_address"`
ReceiverAddress string `json:"receiver_address"`
ReceiverSignature *string `json:"receiver_signature"`
}
PaymentInfo is a payment info
type SendTXArgs ¶
type SendTXArgs struct {
// amount to send
Amount uint64 `json:"amount"`
// minimum confirmations
MinimumConfirmations uint64 `json:"minimum_confirmations"`
// payment method
Method string `json:"method"`
// destination url
Dest string `json:"dest"`
// Max number of outputs
MaxOutputs uint `json:"max_outputs"`
// Number of change outputs to generate
NumChangeOutputs uint `json:"num_change_outputs"`
// whether to use all outputs (combine)
SelectionStrategyIsUseAll bool `json:"selection_strategy_is_use_all"`
// Optional message, that will be signed
Message *string `json:"message"`
// Optional slate version to target when sending
TargetSlateVersion *uint16 `json:"target_slate_version"`
}
SendTXArgs Send TX API Args TODO: This is here to ensure the legacy V1 API remains intact remove this when v1 api is removed
type Slate ¶
type Slate struct {
// Versioning info
VersionInfo VersionCompatInfo `json:"version_info"`
// The number of participants intended to take part in this transaction
NumParticipants uint8 `json:"num_participants"`
// Unique transaction ID, selected by sender
ID uuid.UUID `json:"id"`
// Slate state
State slateState `json:"state"`
// The core transaction data:
// inputs, outputs, kernels, kernel offset
// Optional as of V4 to allow for a compact
// transaction initiation
Transaction *core.Transaction `json:"tx"`
// base amount (excluding fee)
Amount core.Uint64 `json:"amount"`
// fee amount
Fee core.Uint64 `json:"fee"`
// TTL, the block height at which wallets
// should refuse to process the transaction and unlock all
// associated outputs
TTLCutoffHeight *core.Uint64 `json:"ttl_cutoff_height"`
// Kernel Features flag -
// 0: plain
// 1: coinbase (invalid)
// 2: height_locked
// 3: NRD
KernelFeatures uint8 `json:"kernel_features"`
// Offset, needed when posting of tranasction is deferred
Offset string
// Participant data, each participant in the transaction will
// insert their public data here. For now, 0 is sender and 1
// is receiver, though this will change for multi-party
ParticipantData *[]ParticipantData `json:"participant_data"`
// Payment Proof
PaymentProof *PaymentInfo `json:"payment_proof"`
// Kernel features arguments
KernelFeaturesArgs *KernelFeaturesArgs `json:"kernel_features_args"`
}
A Slate is passed around to all parties to build up all of the public transaction data needed to create a finalized transaction. Callers can pass the slate around by whatever means they choose, (but we can provide some binary or JSON serialization helpers here).
type StoredProofInfo ¶
type StoredProofInfo struct {
// receiver address
ReceiverAddress string `json:"receiver_address"`
// receiver signature
ReceiverSignature *string `json:"receiver_signature"`
// sender address derivation path index
SenderAddressPath uint32 `json:"sender_address_path"`
// sender address
SenderAddress string `json:"sender_address"`
// sender signature
SenderSignature *string `json:"sender_signature"`
}
StoredProofInfo is the payment proof information. Differs from what is sent via the slate
type TorConfig ¶
type TorConfig struct {
// whether to skip any attempts to send via TOR
SkipSendAttempt *bool `json:"skip_send_attempt"`
// Whether to start tor listener on listener startup (default true)
UseTorListener bool `json:"use_tor_listener"`
// Just the address of the socks proxy for now
SocksProxyAddr string `json:"socks_proxy_addr"`
// Send configuration directory
SendConfigDir string `json:"send_config_dir"`
}
TorConfig is the Tor configuration
type TxLogEntry ¶
type TxLogEntry struct {
// BIP32 account path used for creating this tx
ParentKeyID keychain.Identifier `json:"parent_key_id"`
// Local id for this transaction (distinct from a slate transaction id)
ID uint32 `json:"id"`
// Slate transaction this entry is associated with, if any
TxSlateID *uuid.UUID `json:"tx_slate_id"`
// Transaction type (as above)
TxType txLogEntryType `json:"tx_type"`
// Time this tx entry was created
// #[serde(with = "tx_date_format")]
CreationTs time.Time `json:"creation_ts"`
// Time this tx was confirmed (by this wallet)
// #[serde(default, with = "opt_tx_date_format")]
ConfirmationTs *time.Time `json:"confirmation_ts"`
// Whether the inputs+outputs involved in this transaction have been
// confirmed (In all cases either all outputs involved in a tx should be
// confirmed, or none should be; otherwise there's a deeper problem)
Confirmed bool `json:"confirmed"`
// number of inputs involved in TX
NumInputs uint `json:"num_inputs"`
// number of outputs involved in TX
NumOutputs uint `json:"num_outputs"`
// Amount credited via this transaction
AmountCredited core.Uint64 `json:"amount_credited"`
// Amount debited via this transaction
AmountDebited core.Uint64 `json:"amount_debited"`
// Fee
Fee *core.Uint64 `json:"fee"`
// Cutoff block height
TTLCutoffHeight *core.Uint64 `json:"ttl_cutoff_height"`
// Location of the store transaction, (reference or resending)
StoredTx *string `json:"stored_tx"`
// Associated kernel excess, for later lookup if necessary
KernelExcess *string `json:"kernel_excess"`
// Height reported when transaction was created, if lookup
// of kernel is necessary
KernelLookupMinHeight *core.Uint64 `json:"kernel_lookup_min_height"`
// Additional info needed to stored payment proof
PaymentProof *StoredProofInfo `json:"payment_proof"`
// Track the time it took for a transaction to get reverted
RevertedAfter *string `json:"reverted_after"`
}
TxLogEntry is an optional transaction information, recorded when an event happens to add or remove funds from a wallet. One Transaction log entry maps to one or many outputs
type VersionCompatInfo ¶
type VersionCompatInfo struct {
// The current version of the slate format
Version uint16 `json:"version"`
// The grin block header version this slate is intended for
BlockHeaderVersion uint16 `json:"block_header_version"`
}
VersionCompatInfo is a version compat info
func (VersionCompatInfo) MarshalJSON ¶
func (v VersionCompatInfo) MarshalJSON() ([]byte, error)
MarshalJSON marshals the VersionCompatInfo as a quoted version like {}:{}
func (*VersionCompatInfo) UnmarshalJSON ¶
func (v *VersionCompatInfo) UnmarshalJSON(bs []byte) error
UnmarshalJSON unmarshals a quoted version to a v
type VersionInfo ¶
type VersionInfo struct {
// API version
ForeignAPIVersion uint16 `json:"foreign_api_version"`
// Slate version
SupportedSlateVersions []slateversions.SlateVersion `json:"supported_slate_versions"`
}
VersionInfo is the version request result
type WalletInfo ¶
type WalletInfo struct {
// height from which info was taken
LastConfirmedHeight core.Uint64 `json:"last_confirmed_height"`
// Minimum number of confirmations for an output to be treated as "spendable".
MinimumConfirmations core.Uint64 `json:"minimum_confirmations"`
// total amount in the wallet
Total core.Uint64 `json:"total"`
// amount awaiting finalization
AmountAwaitingFinalization core.Uint64 `json:"amount_awaiting_finalization"`
// amount awaiting confirmation
AmountAwaitingConfirmation core.Uint64 `json:"amount_awaiting_confirmation"`
// coinbases waiting for lock height
AmountImmature core.Uint64 `json:"amount_immature"`
// amount currently spendable
AmountCurrentlySpendable core.Uint64 `json:"amount_currently_spendable"`
// amount locked via previous transactions
AmountLocked core.Uint64 `json:"amount_locked"`
}
WalletInfo is a contained wallet info struct, so automated tests can parse wallet info can add more fields here over time as needed