Documentation ¶
Overview ¶
Package wallet provides ... TODO: Flesh out this section
Index ¶
- Constants
- Variables
- func Create(ctx context.Context, db DB, pubPass, privPass, seed []byte, ...) error
- func CreateWatchOnly(ctx context.Context, db DB, extendedPubKey string, pubPass []byte, ...) error
- func CurrentAgendas(params *chaincfg.Params) (version uint32, agendas []chaincfg.ConsensusDeployment)
- func PossibleCoinJoin(tx *wire.MsgTx) (isMix bool, mixDenom int64, mixCount uint32)
- func UnstableAPI(w *Wallet) unstableAPI
- func UseLogger(logger slog.Logger)
- func VerifyMessage(msg string, addr stdaddr.Address, sig []byte, params stdaddr.AddressParams) (bool, error)
- type AccountBalance
- type AccountKind
- type AccountNotification
- type AccountNotificationsClient
- type AccountProperties
- type AccountResult
- type AccountTotalReceivedResult
- type AccountsResult
- type Address
- type AgendaChoice
- type BIP0044Address
- type Balances
- type Block
- type BlockIdentifier
- type BlockIdentity
- type BlockInfo
- type BlockNode
- type Caller
- type Config
- type ConfirmationNotification
- type ConfirmationNotificationsClient
- type CreatedTx
- type CreditCategory
- type DB
- type DialFunc
- type FilterProof
- type Input
- type KnownAddress
- type MainTipChangedNotification
- type MainTipChangedNotificationsClient
- type MissingCFilterProgress
- type NetworkBackend
- type NextAddressCallOption
- type NotificationServer
- func (s *NotificationServer) AccountNotifications() AccountNotificationsClient
- func (s *NotificationServer) ConfirmationNotifications(ctx context.Context) *ConfirmationNotificationsClient
- func (s *NotificationServer) MainTipChangedNotifications() MainTipChangedNotificationsClient
- func (s *NotificationServer) RemovedTransactionNotifications() RemovedTransactionNotificationsClient
- func (s *NotificationServer) TransactionNotifications() TransactionNotificationsClient
- type OutputInfo
- type OutputKind
- type OutputRedeemer
- type OutputSelectionAlgorithm
- type OutputSelectionPolicy
- type P2SHAddress
- type P2SHMultiSigOutput
- type Peer
- type PubKeyHashAddress
- type PurchaseTicketsRequest
- type PurchaseTicketsResponse
- type RemovedTransactionNotification
- type RemovedTransactionNotificationsClient
- type RescanFilter
- func (f *RescanFilter) AddAddress(a stdaddr.Address)
- func (f *RescanFilter) AddUnspentOutPoint(op *wire.OutPoint)
- func (f *RescanFilter) ExistsAddress(a stdaddr.Address) (ok bool)
- func (f *RescanFilter) ExistsUnspentOutPoint(op *wire.OutPoint) bool
- func (f *RescanFilter) RemoveAddress(a stdaddr.Address)
- func (f *RescanFilter) RemoveUnspentOutPoint(op *wire.OutPoint)
- type RescanProgress
- type SidechainForest
- func (f *SidechainForest) AddBlockNode(n *BlockNode) bool
- func (f *SidechainForest) FullSideChain(newBlocks []*BlockNode) ([]*BlockNode, error)
- func (f *SidechainForest) HasSideChainBlock(blockHash *chainhash.Hash) bool
- func (f *SidechainForest) Prune(mainChainHeight int32, params *chaincfg.Params)
- func (f *SidechainForest) PruneTree(root *chainhash.Hash)
- type SignatureError
- type StakeDifficultyInfo
- type StakeInfoData
- type TicketStatus
- type TicketSummary
- type TransactionNotifications
- type TransactionNotificationsClient
- type TransactionOutput
- type TransactionSummary
- type TransactionSummaryInput
- type TransactionSummaryOutput
- type TransactionType
- type TreasuryKeyPolicy
- type VSPTicket
- type Wallet
- func (w *Wallet) AbandonTransaction(ctx context.Context, hash *chainhash.Hash) error
- func (w *Wallet) AccountBalance(ctx context.Context, account uint32, confirms int32) (Balances, error)
- func (w *Wallet) AccountBalances(ctx context.Context, confirms int32) ([]Balances, error)
- func (w *Wallet) AccountHasPassphrase(ctx context.Context, account uint32) (bool, error)
- func (w *Wallet) AccountName(ctx context.Context, accountNumber uint32) (string, error)
- func (w *Wallet) AccountNumber(ctx context.Context, accountName string) (uint32, error)
- func (w *Wallet) AccountUnlocked(ctx context.Context, account uint32) (bool, error)
- func (w *Wallet) AccountXpriv(ctx context.Context, account uint32) (*hdkeychain.ExtendedKey, error)
- func (w *Wallet) AccountXpub(ctx context.Context, account uint32) (*hdkeychain.ExtendedKey, error)
- func (w *Wallet) Accounts(ctx context.Context) (*AccountsResult, error)
- func (w *Wallet) AddTSpend(tx wire.MsgTx) error
- func (w *Wallet) AddTransaction(ctx context.Context, tx *wire.MsgTx, blockHash *chainhash.Hash) error
- func (w *Wallet) AgendaChoices(ctx context.Context, ticketHash *chainhash.Hash) (choices []AgendaChoice, voteBits uint16, err error)
- func (w *Wallet) AllowsHighFees() bool
- func (w *Wallet) BIP0044BranchNextIndexes(ctx context.Context, account uint32) (extChild, intChild uint32, err error)
- func (w *Wallet) BlockHeader(ctx context.Context, blockHash *chainhash.Hash) (*wire.BlockHeader, error)
- func (w *Wallet) BlockInMainChain(ctx context.Context, hash *chainhash.Hash) (haveBlock, invalidated bool, err error)
- func (w *Wallet) BlockInfo(ctx context.Context, blockID *BlockIdentifier) (*BlockInfo, error)
- func (w *Wallet) BlockLocators(ctx context.Context, sidechain []*BlockNode) ([]*chainhash.Hash, error)
- func (w *Wallet) CFilterV2(ctx context.Context, blockHash *chainhash.Hash) ([gcs2.KeySize]byte, *gcs2.FilterV2, error)
- func (w *Wallet) ChainParams() *chaincfg.Params
- func (w *Wallet) ChainSwitch(ctx context.Context, forest *SidechainForest, chain []*BlockNode, ...) ([]*BlockNode, error)
- func (w *Wallet) ChangePrivatePassphrase(ctx context.Context, old, new []byte) error
- func (w *Wallet) ChangePublicPassphrase(ctx context.Context, old, new []byte) error
- func (w *Wallet) CoinType(ctx context.Context) (uint32, error)
- func (w *Wallet) CoinTypePrivKey(ctx context.Context) (*hdkeychain.ExtendedKey, error)
- func (w *Wallet) CommittedTickets(ctx context.Context, tickets []*chainhash.Hash) ([]*chainhash.Hash, []stdaddr.Address, error)
- func (w *Wallet) Consolidate(ctx context.Context, inputs int, account uint32, address stdaddr.Address) (*chainhash.Hash, error)
- func (w *Wallet) CreateMultisigTx(ctx context.Context, account uint32, amount dcrutil.Amount, pubkeys [][]byte, ...) (*CreatedTx, stdaddr.Address, []byte, error)
- func (w *Wallet) CreateSignature(ctx context.Context, tx *wire.MsgTx, idx uint32, addr stdaddr.Address, ...) (sig, pubkey []byte, err error)
- func (w *Wallet) CurrentAddress(account uint32) (stdaddr.Address, error)
- func (w *Wallet) DetermineRelevantTxs(ctx context.Context, txs ...*wire.MsgTx) ([]*wire.MsgTx, []*wire.MsgTx, error)
- func (w *Wallet) DisapprovePercent() uint32
- func (w *Wallet) DiscoverActiveAddresses(ctx context.Context, p Peer, startBlock *chainhash.Hash, discoverAccts bool, ...) error
- func (w *Wallet) DumpWIFPrivateKey(ctx context.Context, addr stdaddr.Address) (string, error)
- func (w *Wallet) EvaluateBestChain(ctx context.Context, f *SidechainForest) ([]*BlockNode, error)
- func (w *Wallet) FetchMissingCFilters(ctx context.Context, p Peer) error
- func (w *Wallet) FetchMissingCFiltersWithProgress(ctx context.Context, p Peer, progress chan<- MissingCFilterProgress)
- func (w *Wallet) FetchOutput(ctx context.Context, outPoint *wire.OutPoint) (*wire.TxOut, error)
- func (w *Wallet) FetchP2SHMultiSigOutput(ctx context.Context, outPoint *wire.OutPoint) (*P2SHMultiSigOutput, error)
- func (w *Wallet) ForUnspentUnexpiredTickets(ctx context.Context, f func(hash *chainhash.Hash) error) error
- func (w *Wallet) GapLimit() uint32
- func (w *Wallet) GenerateVoteTx(ctx context.Context, blockHash *chainhash.Hash, height int32, ...) (*wire.MsgTx, error)deprecated
- func (w *Wallet) GetAllTSpends(ctx context.Context) []*wire.MsgTx
- func (w *Wallet) GetCoinjoinTxsSumbByAcct(ctx context.Context) (map[uint32]int, error)
- func (w *Wallet) GetTicketInfo(ctx context.Context, hash *chainhash.Hash) (*TicketSummary, *wire.BlockHeader, error)
- func (w *Wallet) GetTicketInfoPrecise(ctx context.Context, rpcCaller Caller, hash *chainhash.Hash) (*TicketSummary, *wire.BlockHeader, error)
- func (w *Wallet) GetTickets(ctx context.Context, f func([]*TicketSummary, *wire.BlockHeader) (bool, error), ...) error
- func (w *Wallet) GetTicketsPrecise(ctx context.Context, rpcCaller Caller, ...) error
- func (w *Wallet) GetTransactions(ctx context.Context, f func(*Block) (bool, error), ...) error
- func (w *Wallet) GetTransactionsByHashes(ctx context.Context, txHashes []*chainhash.Hash) (txs []*wire.MsgTx, notFound []*wire.InvVect, err error)
- func (w *Wallet) GetVSPTicketsByFeeStatus(ctx context.Context, feeStatus int) ([]chainhash.Hash, error)
- func (w *Wallet) HaveAddress(ctx context.Context, a stdaddr.Address) (bool, error)
- func (w *Wallet) ImportCFiltersV2(ctx context.Context, startBlockHeight int32, filterData [][]byte) error
- func (w *Wallet) ImportPrivateKey(ctx context.Context, wif *dcrutil.WIF) (string, error)
- func (w *Wallet) ImportScript(ctx context.Context, rs []byte) error
- func (w *Wallet) ImportVotingAccount(ctx context.Context, xpriv *hdkeychain.ExtendedKey, passphrase []byte, ...) (uint32, error)
- func (w *Wallet) ImportXpubAccount(ctx context.Context, name string, xpub *hdkeychain.ExtendedKey) error
- func (w *Wallet) ImportedAddresses(ctx context.Context, account string) (_ []KnownAddress, err error)
- func (w *Wallet) InitialHeight() int32
- func (w *Wallet) IsVSPTicketConfirmed(ctx context.Context, ticketHash *chainhash.Hash) (bool, error)
- func (w *Wallet) KnownAddress(ctx context.Context, a stdaddr.Address) (KnownAddress, error)
- func (w *Wallet) ListAddressTransactions(ctx context.Context, pkHashes map[string]struct{}) ([]types.ListTransactionsResult, error)
- func (w *Wallet) ListAllTransactions(ctx context.Context) ([]types.ListTransactionsResult, error)
- func (w *Wallet) ListSinceBlock(ctx context.Context, start, end, syncHeight int32) ([]types.ListTransactionsResult, error)
- func (w *Wallet) ListTransactionDetails(ctx context.Context, txHash *chainhash.Hash) ([]types.ListTransactionsResult, error)
- func (w *Wallet) ListTransactions(ctx context.Context, from, count int) ([]types.ListTransactionsResult, error)
- func (w *Wallet) ListUnspent(ctx context.Context, minconf, maxconf int32, addresses map[string]struct{}, ...) ([]*types.ListUnspentResult, error)
- func (w *Wallet) LiveTicketHashes(ctx context.Context, rpcCaller Caller, includeImmature bool) ([]chainhash.Hash, error)
- func (w *Wallet) LoadActiveDataFilters(ctx context.Context, n NetworkBackend, reload bool) (err error)
- func (w *Wallet) LoadPrivateKey(ctx context.Context, addr stdaddr.Address) (key *secp256k1.PrivateKey, zero func(), err error)
- func (w *Wallet) Lock()
- func (w *Wallet) LockAccount(ctx context.Context, account uint32) error
- func (w *Wallet) LockOutpoint(txHash *chainhash.Hash, index uint32)
- func (w *Wallet) Locked() bool
- func (w *Wallet) LockedOutpoint(txHash *chainhash.Hash, index uint32) bool
- func (w *Wallet) LockedOutpoints(ctx context.Context, accountName string) ([]dcrdtypes.TransactionInput, error)
- func (w *Wallet) MainChainTip(ctx context.Context) (hash chainhash.Hash, height int32)
- func (w *Wallet) ManualTickets() bool
- func (w *Wallet) MixAccount(ctx context.Context, dialTLS DialFunc, csppserver string, ...) error
- func (w *Wallet) MixOutput(ctx context.Context, dialTLS DialFunc, csppserver string, ...) error
- func (w *Wallet) NeedsAccountsSync(ctx context.Context) (bool, error)
- func (w *Wallet) NetworkBackend() (NetworkBackend, error)
- func (w *Wallet) NewChangeAddress(ctx context.Context, account uint32) (stdaddr.Address, error)
- func (w *Wallet) NewExternalAddress(ctx context.Context, account uint32, callOpts ...NextAddressCallOption) (stdaddr.Address, error)
- func (w *Wallet) NewInternalAddress(ctx context.Context, account uint32, callOpts ...NextAddressCallOption) (stdaddr.Address, error)
- func (w *Wallet) NewUnsignedTransaction(ctx context.Context, outputs []*wire.TxOut, relayFeePerKb dcrutil.Amount, ...) (*txauthor.AuthoredTx, error)
- func (w *Wallet) NextAccount(ctx context.Context, name string) (uint32, error)
- func (w *Wallet) NextStakeDifficulty(ctx context.Context) (dcrutil.Amount, error)
- func (w *Wallet) NextStakeDifficultyAfterHeader(ctx context.Context, h *wire.BlockHeader) (dcrutil.Amount, error)
- func (w *Wallet) OutputInfo(ctx context.Context, out *wire.OutPoint) (OutputInfo, error)
- func (w *Wallet) PrepareRedeemMultiSigOutTxOutput(msgTx *wire.MsgTx, p2shOutput *P2SHMultiSigOutput, pkScript *[]byte) error
- func (w *Wallet) PublishTransaction(ctx context.Context, tx *wire.MsgTx, n NetworkBackend) (*chainhash.Hash, error)
- func (w *Wallet) PublishUnminedTransactions(ctx context.Context, p Peer) error
- func (w *Wallet) PurchaseTickets(ctx context.Context, n NetworkBackend, req *PurchaseTicketsRequest) (*PurchaseTicketsResponse, error)
- func (w *Wallet) RangeCFiltersV2(ctx context.Context, startBlock, endBlock *BlockIdentifier, ...) error
- func (w *Wallet) RelayFee() dcrutil.Amount
- func (w *Wallet) RenameAccount(ctx context.Context, account uint32, newName string) error
- func (w *Wallet) Rescan(ctx context.Context, n NetworkBackend, startHash *chainhash.Hash) error
- func (w *Wallet) RescanFromHeight(ctx context.Context, n NetworkBackend, startHeight int32) error
- func (w *Wallet) RescanPoint(ctx context.Context) (*chainhash.Hash, error)
- func (w *Wallet) RescanProgressFromHeight(ctx context.Context, n NetworkBackend, startHeight int32, ...)
- func (w *Wallet) ReserveOutputsForAmount(ctx context.Context, account uint32, amount dcrutil.Amount, minconf int32) ([]Input, error)
- func (w *Wallet) ResetLockedOutpoints()
- func (w *Wallet) RevokeExpiredTickets(ctx context.Context, p Peer) (err error)deprecated
- func (w *Wallet) RevokeOwnedTickets(ctx context.Context, missedTicketHashes []*chainhash.Hash) errordeprecated
- func (w *Wallet) RevokeTicket(ctx context.Context, ticketHash *chainhash.Hash, p Peer) errordeprecated
- func (w *Wallet) RevokeTickets(ctx context.Context, rpcCaller Caller) error
- func (w *Wallet) SaveRescanned(ctx context.Context, hash *chainhash.Hash, txs []*wire.MsgTx) error
- func (w *Wallet) SelectInputs(ctx context.Context, targetAmount dcrutil.Amount, policy OutputSelectionPolicy) (inputDetail *txauthor.InputDetail, err error)
- func (w *Wallet) SendOutputs(ctx context.Context, outputs []*wire.TxOut, account, changeAccount uint32, ...) (*chainhash.Hash, error)
- func (w *Wallet) SendOutputsToTreasury(ctx context.Context, outputs []*wire.TxOut, account, changeAccount uint32, ...) (*chainhash.Hash, error)
- func (w *Wallet) SetAccountPassphrase(ctx context.Context, account uint32, passphrase []byte) error
- func (w *Wallet) SetAgendaChoices(ctx context.Context, ticketHash *chainhash.Hash, choices ...AgendaChoice) (voteBits uint16, err error)
- func (w *Wallet) SetDisapprovePercent(percent uint32)
- func (w *Wallet) SetNetworkBackend(n NetworkBackend)
- func (w *Wallet) SetPublished(ctx context.Context, hash *chainhash.Hash, published bool) error
- func (w *Wallet) SetRelayFee(relayFee dcrutil.Amount)
- func (w *Wallet) SetTSpendPolicy(ctx context.Context, tspendHash *chainhash.Hash, policy stake.TreasuryVoteT, ...) error
- func (w *Wallet) SetTreasuryKeyPolicy(ctx context.Context, pikey []byte, policy stake.TreasuryVoteT, ...) error
- func (w *Wallet) SignHashes(ctx context.Context, hashes [][]byte, addr stdaddr.Address) ([][]byte, []byte, error)
- func (w *Wallet) SignMessage(ctx context.Context, msg string, addr stdaddr.Address) (sig []byte, err error)
- func (w *Wallet) SignTransaction(ctx context.Context, tx *wire.MsgTx, hashType txscript.SigHashType, ...) ([]SignatureError, error)
- func (w *Wallet) SortedActivePaymentAddresses(ctx context.Context) ([]string, error)
- func (w *Wallet) Spender(ctx context.Context, out *wire.OutPoint) (*wire.MsgTx, uint32, error)
- func (w *Wallet) StakeInfo(ctx context.Context) (*StakeInfoData, error)
- func (w *Wallet) StakeInfoPrecise(ctx context.Context, rpcCaller Caller) (*StakeInfoData, error)
- func (w *Wallet) StakePoolUserInfo(ctx context.Context, userAddress stdaddr.StakeAddress) (*udb.StakePoolUser, error)
- func (w *Wallet) SyncLastReturnedAddress(ctx context.Context, account, branch, child uint32) error
- func (w *Wallet) TSpendPolicy(tspendHash, ticketHash *chainhash.Hash) stake.TreasuryVoteT
- func (w *Wallet) TSpendPolicyForTicket(ticketHash *chainhash.Hash) map[string]string
- func (w *Wallet) TicketHashesForVotingAddress(ctx context.Context, votingAddr stdaddr.Address) ([]chainhash.Hash, error)
- func (w *Wallet) TotalReceivedForAccounts(ctx context.Context, minConf int32) ([]AccountTotalReceivedResult, error)
- func (w *Wallet) TotalReceivedForAddr(ctx context.Context, addr stdaddr.Address, minConf int32) (dcrutil.Amount, error)
- func (w *Wallet) TransactionSummary(ctx context.Context, txHash *chainhash.Hash) (txSummary *TransactionSummary, confs int32, blockHash *chainhash.Hash, ...)
- func (w *Wallet) TreasuryKeyPolicies() []TreasuryKeyPolicy
- func (w *Wallet) TreasuryKeyPolicy(pikey []byte, ticket *chainhash.Hash) stake.TreasuryVoteT
- func (w *Wallet) TreasuryKeyPolicyForTicket(ticketHash *chainhash.Hash) map[string]string
- func (w *Wallet) TxBlock(ctx context.Context, hash *chainhash.Hash) (chainhash.Hash, int32, error)
- func (w *Wallet) TxConfirms(ctx context.Context, hash *chainhash.Hash) (int32, error)
- func (w *Wallet) Unlock(ctx context.Context, passphrase []byte, timeout <-chan time.Time) error
- func (w *Wallet) UnlockAccount(ctx context.Context, account uint32, passphrase []byte) error
- func (w *Wallet) UnlockOutpoint(txHash *chainhash.Hash, index uint32)
- func (w *Wallet) Unlocked() bool
- func (w *Wallet) UnminedTransactions(ctx context.Context) ([]*wire.MsgTx, error)
- func (w *Wallet) UnspentOutput(ctx context.Context, op wire.OutPoint, includeMempool bool) (*udb.Credit, error)
- func (w *Wallet) UnspentOutputs(ctx context.Context, policy OutputSelectionPolicy) ([]*TransactionOutput, error)
- func (w *Wallet) UpdateVspTicketFeeToConfirmed(ctx context.Context, ticketHash, feeHash *chainhash.Hash, host string, ...) error
- func (w *Wallet) UpdateVspTicketFeeToErrored(ctx context.Context, ticketHash *chainhash.Hash, host string, pubkey []byte) error
- func (w *Wallet) UpdateVspTicketFeeToPaid(ctx context.Context, ticketHash, feeHash *chainhash.Hash, host string, ...) error
- func (w *Wallet) UpdateVspTicketFeeToStarted(ctx context.Context, ticketHash, feeHash *chainhash.Hash, host string, ...) error
- func (w *Wallet) UpgradeToSLIP0044CoinType(ctx context.Context) error
- func (w *Wallet) VSPFeeHashForTicket(ctx context.Context, ticketHash *chainhash.Hash) (chainhash.Hash, error)
- func (w *Wallet) VSPHostForTicket(ctx context.Context, ticketHash *chainhash.Hash) (string, error)
- func (w *Wallet) VSPTicketInfo(ctx context.Context, ticketHash *chainhash.Hash) (*VSPTicket, error)
- func (w *Wallet) ValidateHeaderChainDifficulties(ctx context.Context, chain []*BlockNode, idx int) ([]*BlockNode, error)
- func (w *Wallet) ValidatePreDCP0005CFilters(ctx context.Context) error
- func (w *Wallet) VoteBits() stake.VoteBits
- func (w *Wallet) VoteOnOwnedTickets(ctx context.Context, winningTicketHashes []*chainhash.Hash, ...) error
- func (w *Wallet) VotingEnabled() bool
- func (w *Wallet) VotingXprivFromSeed(seed []byte) (*hdkeychain.ExtendedKey, error)
- func (w *Wallet) WatchingOnly() bool
Constants ¶
const ( // OutputSelectionAlgorithmDefault describes the default output selection // algorithm. It is not optimized for any particular use case. OutputSelectionAlgorithmDefault = iota // OutputSelectionAlgorithmAll describes the output selection algorithm of // picking every possible available output. This is useful for sweeping. OutputSelectionAlgorithmAll )
const DefaultAccountGapLimit = 10
DefaultAccountGapLimit is the default number of accounts that can be created in a row without using any of them
const DefaultGapLimit = uint32(20)
DefaultGapLimit is the default unused address gap limit defined by BIP0044.
const ( // InsecurePubPassphrase is the default outer encryption passphrase used // for public data (everything but private keys). Using a non-default // public passphrase can prevent an attacker without the public // passphrase from discovering all past and future wallet addresses if // they gain access to the wallet database. // // NOTE: at time of writing, public encryption only applies to public // data in the waddrmgr namespace. Transactions are not yet encrypted. InsecurePubPassphrase = "public" )
Variables ¶
var ( // SimulationPassphrase is the password for a wallet created for simnet // with --createtemp. SimulationPassphrase = []byte("password") )
Functions ¶
func Create ¶
func Create(ctx context.Context, db DB, pubPass, privPass, seed []byte, params *chaincfg.Params) error
Create creates an new wallet, writing it to an empty database. If the passed seed is non-nil, it is used. Otherwise, a secure random seed of the recommended length is generated.
func CreateWatchOnly ¶
func CreateWatchOnly(ctx context.Context, db DB, extendedPubKey string, pubPass []byte, params *chaincfg.Params) error
CreateWatchOnly creates a watchonly wallet on the provided db.
func CurrentAgendas ¶
func CurrentAgendas(params *chaincfg.Params) (version uint32, agendas []chaincfg.ConsensusDeployment)
CurrentAgendas returns the current stake version for the active network and this version of the software, and all agendas defined by it.
func PossibleCoinJoin ¶
PossibleCoinJoin tests if a transaction may be a CSPP-mixed transaction. It can return false positives, as one can create a tx which looks like a coinjoin tx, although it isn't.
func UnstableAPI ¶
func UnstableAPI(w *Wallet) unstableAPI
UnstableAPI exposes additional unstable public APIs for a Wallet. These APIs may be changed or removed at any time. Currently this type exists to ease the transition (particularly for the legacy JSON-RPC server) from using exported manager packages to a unified wallet package that exposes all functionality by itself. New code should not be written using this API.
func UseLogger ¶
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.
func VerifyMessage ¶
func VerifyMessage(msg string, addr stdaddr.Address, sig []byte, params stdaddr.AddressParams) (bool, error)
VerifyMessage verifies that sig is a valid signature of msg and was created using the secp256k1 private key for addr.
Types ¶
type AccountBalance ¶
type AccountBalance struct { Account uint32 TotalBalance dcrutil.Amount }
AccountBalance associates a total (zero confirmation) balance with an account. Balances for other minimum confirmation counts require more expensive logic and it is not clear which minimums a client is interested in, so they are not included.
type AccountKind ¶
type AccountKind int
AccountKind describes the purpose and type of a wallet account.
const ( // AccountKindBIP0044 describes a BIP0044 account derived from the // wallet seed. New addresses created from the account encode secp256k1 // P2PKH output scripts. AccountKindBIP0044 AccountKind = iota // AccountKindImported describes an account with only singular, possibly // unrelated imported keys. Keys must be manually reimported after seed // restore. New addresses can not be derived from the account. AccountKindImported // AccountKindImportedXpub describes a BIP0044 account created from an // imported extended key. It operates like a seed-derived BIP0044 // account. AccountKindImportedXpub )
type AccountNotification ¶
type AccountNotification struct { AccountNumber uint32 AccountName string ExternalKeyCount uint32 InternalKeyCount uint32 ImportedKeyCount uint32 }
AccountNotification contains properties regarding an account, such as its name and the number of derived and imported keys. When any of these properties change, the notification is fired.
type AccountNotificationsClient ¶
type AccountNotificationsClient struct { C chan *AccountNotification // contains filtered or unexported fields }
AccountNotificationsClient receives AccountNotifications over the channel C.
func (*AccountNotificationsClient) Done ¶
func (c *AccountNotificationsClient) Done()
Done deregisters the client from the server and drains any remaining messages. It must be called exactly once when the client is finished receiving notifications.
type AccountProperties ¶
type AccountProperties struct { AccountNumber uint32 AccountName string AccountType uint8 LastUsedExternalIndex uint32 LastUsedInternalIndex uint32 LastReturnedExternalIndex uint32 LastReturnedInternalIndex uint32 ImportedKeyCount uint32 AccountEncrypted bool AccountUnlocked bool }
AccountProperties contains properties associated with each account, such as the account name, number, and the nubmer of derived and imported keys. If no address usage has been recorded on any of the external or internal branches, the child index is ^uint32(0).
type AccountResult ¶
type AccountResult struct { AccountProperties TotalBalance dcrutil.Amount }
AccountResult is a single account result for the AccountsResult type.
type AccountTotalReceivedResult ¶
type AccountTotalReceivedResult struct { AccountNumber uint32 AccountName string TotalReceived dcrutil.Amount LastConfirmation int32 }
AccountTotalReceivedResult is a single result for the Wallet.TotalReceivedForAccounts method.
type AccountsResult ¶
type AccountsResult struct { Accounts []AccountResult CurrentBlockHash *chainhash.Hash CurrentBlockHeight int32 }
AccountsResult is the resutl of the wallet's Accounts method. See that method for more details.
type Address ¶
type Address interface { String() string // PaymentScript returns the output script and script version to pay the // address. The version is always returned with the script, as it is // not useful to use the script without the version. PaymentScript() (version uint16, script []byte) // ScriptLen returns the known length of the address output script. ScriptLen() int }
Address is a human-readable encoding of an output script.
Address encodings may include a network identifier, to prevent misuse on an alternate Decred network.
type AgendaChoice ¶
AgendaChoice describes a user's choice for a consensus deployment agenda.
type BIP0044Address ¶
type BIP0044Address interface { PubKeyHashAddress // Path returns the BIP0032 indexes to derive the BIP0044 address from // the coin type key. The account index is always the non-hardened // identifier, with values between 0 through 1<<31 - 1 (inclusive). The // account index will always be zero if this address belongs to an // imported xpub or imported xpriv account. Path() (account, branch, child uint32) }
BIP0044Address is a KnownAddress for a secp256k1 pay-to-pubkey-hash output, with keys created from a derived or imported BIP0044 account extended pubkey.
type Balances ¶
type Balances struct { Account uint32 ImmatureCoinbaseRewards dcrutil.Amount ImmatureStakeGeneration dcrutil.Amount LockedByTickets dcrutil.Amount Spendable dcrutil.Amount Total dcrutil.Amount VotingAuthority dcrutil.Amount Unconfirmed dcrutil.Amount }
Balances describes a breakdown of an account's balances in various categories.
type Block ¶
type Block struct { Header *wire.BlockHeader // Nil if referring to mempool Transactions []TransactionSummary }
Block contains the properties and all relevant transactions of an attached block.
type BlockIdentifier ¶
type BlockIdentifier struct {
// contains filtered or unexported fields
}
BlockIdentifier identifies a block by either a height in the main chain or a hash.
func NewBlockIdentifierFromHash ¶
func NewBlockIdentifierFromHash(hash *chainhash.Hash) *BlockIdentifier
NewBlockIdentifierFromHash constructs a BlockIdentifier for a block hash.
func NewBlockIdentifierFromHeight ¶
func NewBlockIdentifierFromHeight(height int32) *BlockIdentifier
NewBlockIdentifierFromHeight constructs a BlockIdentifier for a block height.
type BlockIdentity ¶
BlockIdentity identifies a block, or the lack of one (used to describe an unmined transaction).
func (*BlockIdentity) None ¶
func (b *BlockIdentity) None() bool
None returns whether there is no block described by the instance. When associated with a transaction, this indicates the transaction is unmined.
type BlockInfo ¶
type BlockInfo struct { Hash chainhash.Hash Height int32 Confirmations int32 Header []byte Timestamp int64 StakeInvalidated bool }
BlockInfo records info pertaining to a block. It does not include any information about wallet transactions contained in the block.
type BlockNode ¶
type BlockNode struct { Header *wire.BlockHeader Hash *chainhash.Hash FilterV2 *gcs.FilterV2 // contains filtered or unexported fields }
BlockNode represents a block node for a SidechainForest. BlockNodes are not safe for concurrent access, and all exported fields must be treated as immutable.
func NewBlockNode ¶
func NewBlockNode(header *wire.BlockHeader, hash *chainhash.Hash, filter *gcs.FilterV2) *BlockNode
NewBlockNode creates a block node for usage with a SidechainForest.
type Caller ¶
type Caller interface { // Call performs the remote procedure call defined by method and // waits for a response or a broken client connection. // Args provides positional parameters for the call. // Res must be a pointer to a struct, slice, or map type to unmarshal // a result (if any), or nil if no result is needed. Call(ctx context.Context, method string, res interface{}, args ...interface{}) error }
Caller provides a client interface to perform remote procedure calls. Serialization and calling conventions are implementation-specific.
type Config ¶
type Config struct { DB DB PubPassphrase []byte VotingEnabled bool AddressReuse bool VotingAddress stdaddr.StakeAddress PoolAddress stdaddr.StakeAddress PoolFees float64 GapLimit uint32 AccountGapLimit int MixSplitLimit int DisableCoinTypeUpgrades bool StakePoolColdExtKey string ManualTickets bool AllowHighFees bool RelayFee dcrutil.Amount Params *chaincfg.Params }
Config represents the configuration options needed to initialize a wallet.
type ConfirmationNotification ¶
type ConfirmationNotification struct { TxHash *chainhash.Hash Confirmations int32 BlockHash *chainhash.Hash // nil when unmined BlockHeight int32 // -1 when unmined }
ConfirmationNotification describes the number of confirmations of a single transaction, or -1 if the transaction is unknown or removed from the wallet. If the transaction is mined (Confirmations >= 1), the block hash and height is included. Otherwise the block hash is nil and the block height is set to -1.
type ConfirmationNotificationsClient ¶
type ConfirmationNotificationsClient struct {
// contains filtered or unexported fields
}
ConfirmationNotificationsClient provides confirmation notifications of watched transactions until the caller's context signals done. Callers register for notifications using Watch and receive notifications by calling Recv.
func (*ConfirmationNotificationsClient) Recv ¶
func (c *ConfirmationNotificationsClient) Recv() ([]ConfirmationNotification, error)
Recv waits for the next notification. Returns context.Canceled when the context is canceled.
func (*ConfirmationNotificationsClient) Watch ¶
func (c *ConfirmationNotificationsClient) Watch(txHashes []*chainhash.Hash, stopAfter int32)
Watch adds additional transactions to watch and create confirmation results for. Results are immediately created with the current number of confirmations and are watched until stopAfter confirmations is met or the transaction is unknown or removed from the wallet.
type CreatedTx ¶
type CreatedTx struct { MsgTx *wire.MsgTx ChangeAddr stdaddr.Address ChangeIndex int // negative if no change Fee dcrutil.Amount }
CreatedTx holds the state of a newly-created transaction and the change output (if one was added).
type CreditCategory ¶
type CreditCategory byte
CreditCategory describes the type of wallet transaction output. The category of "sent transactions" (debits) is always "send", and is not expressed by this type.
TODO: This is a requirement of the RPC server and should be moved.
const ( CreditReceive CreditCategory = iota CreditGenerate CreditImmature )
These constants define the possible credit categories.
func (CreditCategory) String ¶
func (c CreditCategory) String() string
String returns the category as a string. This string may be used as the JSON string for categories as part of listtransactions and gettransaction RPC responses.
type DB ¶
DB represents an ACID database for a wallet.
type DialFunc ¶
DialFunc provides a method to dial a network connection. If the dialed network connection is secured by TLS, TLS configuration is provided by the method, not the caller.
type FilterProof ¶
FilterProof specifies cfilterv2 data of an individual block during a Peer.CFiltersV2 call.
Note: This is a type alias of an anonymous struct rather than a regular struct due to the packages that fulfill the Peer interface having a dependency graph (spv -> wallet -> rpc/client/dcrd) that prevents directly returning a struct.
type KnownAddress ¶
type KnownAddress interface { Address // AccountName returns the account name associated with the known // address. AccountName() string // AccountKind describes the kind or purpose of the address' account. AccountKind() AccountKind }
KnownAddress represents an address recorded by the wallet. It is potentially watched for involving transactions during wallet syncs.
type MainTipChangedNotification ¶
type MainTipChangedNotification struct { AttachedBlocks []*chainhash.Hash DetachedBlocks []*chainhash.Hash NewHeight int32 }
MainTipChangedNotification describes processed changes to the main chain tip block. Attached and detached blocks are sorted by increasing heights.
This is intended to be a lightweight alternative to TransactionNotifications when only info regarding the main chain tip block changing is needed.
type MainTipChangedNotificationsClient ¶
type MainTipChangedNotificationsClient struct { C chan *MainTipChangedNotification // contains filtered or unexported fields }
MainTipChangedNotificationsClient receives MainTipChangedNotifications over the channel C.
func (*MainTipChangedNotificationsClient) Done ¶
func (c *MainTipChangedNotificationsClient) Done()
Done deregisters the client from the server and drains any remaining messages. It must be called exactly once when the client is finished receiving notifications.
type MissingCFilterProgress ¶
MissingCFilterProgress records the first and last height of the progress that was received and any errors that were received during the fetching.
type NetworkBackend ¶
type NetworkBackend interface { Peer LoadTxFilter(ctx context.Context, reload bool, addrs []stdaddr.Address, outpoints []wire.OutPoint) error Rescan(ctx context.Context, blocks []chainhash.Hash, save func(block *chainhash.Hash, txs []*wire.MsgTx) error) error // This is impossible to determine over the wire protocol, and will always // error. Use Wallet.NextStakeDifficulty to calculate the next ticket price // when the DCP0001 deployment is known to be active. StakeDifficulty(ctx context.Context) (dcrutil.Amount, error) }
NetworkBackend provides wallets with Decred network functionality. Some wallet operations require the wallet to be associated with a network backend to complete.
NetworkBackend expands on the Peer interface to provide additional functionality for rescanning and filtering.
type NextAddressCallOption ¶
type NextAddressCallOption func(*nextAddressCallOptions)
NextAddressCallOption defines a call option for the NextAddress family of wallet methods.
func WithGapPolicyError ¶
func WithGapPolicyError() NextAddressCallOption
WithGapPolicyError configures the NextAddress family of methods to error whenever the gap limit would be exceeded. When this default policy is used, callers should check errors against the GapLimit error code and let users specify whether to ignore the gap limit or wrap around to a previously returned address.
func WithGapPolicyIgnore ¶
func WithGapPolicyIgnore() NextAddressCallOption
WithGapPolicyIgnore configures the NextAddress family of methods to ignore the gap limit entirely when generating addresses. Exceeding the gap limit may result in unsynced address child indexes when seed restoring the wallet, unless the restoring gap limit is increased, as well as breaking automatic address synchronization of multiple running wallets.
This is a good policy to use when addresses must never be reused, but be aware of the issues noted above.
func WithGapPolicyWrap ¶
func WithGapPolicyWrap() NextAddressCallOption
WithGapPolicyWrap configures the NextAddress family of methods to wrap around to a previously returned address instead of erroring or ignoring the gap limit and returning a new unused address.
This is a good policy to use for most individual users' wallets where funds are segmented by accounts and not the addresses that control each output.
type NotificationServer ¶
type NotificationServer struct {
// contains filtered or unexported fields
}
NotificationServer is a server that interested clients may hook into to receive notifications of changes in a wallet. A client is created for each registered notification. Clients are guaranteed to receive messages in the order wallet created them, but there is no guaranteed synchronization between different clients.
func (*NotificationServer) AccountNotifications ¶
func (s *NotificationServer) AccountNotifications() AccountNotificationsClient
AccountNotifications returns a client for receiving AccountNotifications over a channel. The channel is unbuffered. When finished, the client's Done method should be called to disassociate the client from the server.
func (*NotificationServer) ConfirmationNotifications ¶
func (s *NotificationServer) ConfirmationNotifications(ctx context.Context) *ConfirmationNotificationsClient
ConfirmationNotifications registers a client for confirmation notifications from the notification server.
func (*NotificationServer) MainTipChangedNotifications ¶
func (s *NotificationServer) MainTipChangedNotifications() MainTipChangedNotificationsClient
MainTipChangedNotifications returns a client for receiving MainTipChangedNotification over a channel. The channel is unbuffered. When finished, the client's Done method should be called to disassociate the client from the server.
func (*NotificationServer) RemovedTransactionNotifications ¶
func (s *NotificationServer) RemovedTransactionNotifications() RemovedTransactionNotificationsClient
RemovedTransactionNotifications returns a client for receiving RemovedTransactionNotifications over a channel. The channel is unbuffered. When finished, the client's Done method should be called to disassociate the client from the server.
func (*NotificationServer) TransactionNotifications ¶
func (s *NotificationServer) TransactionNotifications() TransactionNotificationsClient
TransactionNotifications returns a client for receiving TransactionNotifiations notifications over a channel. The channel is unbuffered.
When finished, the Done method should be called on the client to disassociate it from the server.
type OutputInfo ¶
OutputInfo describes additional info about an output which can be queried using an outpoint.
type OutputKind ¶
type OutputKind byte
OutputKind describes a kind of transaction output. This is used to differentiate between coinbase, stakebase, and normal outputs.
const ( OutputKindNormal OutputKind = iota OutputKindCoinbase OutputKindStakebase // not returned by all APIs yet )
Defined OutputKind constants
type OutputRedeemer ¶
OutputRedeemer identifies the transaction input which redeems an output.
type OutputSelectionAlgorithm ¶
type OutputSelectionAlgorithm uint
OutputSelectionAlgorithm specifies the algorithm to use when selecting outputs to construct a transaction.
type OutputSelectionPolicy ¶
OutputSelectionPolicy describes the rules for selecting an output from the wallet.
type P2SHAddress ¶
type P2SHAddress interface { KnownAddress // RedeemScript returns the preimage of the script hash. The returned // version is the script version of the address, or the script version // of the redeemed previous output, and must be used for any operations // involving the script. RedeemScript() (version uint16, script []byte) }
P2SHAddress is a KnownAddress which pays to the hash of an arbitrary script.
type P2SHMultiSigOutput ¶
type P2SHMultiSigOutput struct { // TODO: Add a TransactionOutput member to this struct and remove these // fields which are duplicated by it. This improves consistency. Only // not done now because wtxmgr APIs don't support an efficient way of // fetching other Transactionoutput data together with the rest of the // multisig info. OutPoint wire.OutPoint OutputAmount dcrutil.Amount ContainingBlock BlockIdentity P2SHAddress *stdaddr.AddressScriptHashV0 RedeemScript []byte M, N uint8 // M of N signatures required to redeem Redeemer *OutputRedeemer // nil unless spent }
P2SHMultiSigOutput describes a transaction output with a pay-to-script-hash output script and an imported redemption script. Along with common details of the output, this structure also includes the P2SH address the script was created from and the number of signatures required to redeem it.
TODO: Could be useful to return how many of the required signatures can be created by this wallet.
type Peer ¶
type Peer interface { Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error) CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash) ([]FilterProof, error) Headers(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error) PublishTransactions(ctx context.Context, txs ...*wire.MsgTx) error }
Peer provides wallets with a subset of Decred network functionality available to a single peer.
type PubKeyHashAddress ¶
type PubKeyHashAddress interface { KnownAddress // PubKey returns the serialized compressed public key. This key must // be included in scripts redeeming P2PKH outputs paying the address. PubKey() []byte // PubKeyHash returns the hashed compressed public key. This hash must // appear in output scripts paying to the address. PubKeyHash() []byte }
PubKeyHashAddress is a KnownAddress for a secp256k1 pay-to-pubkey-hash (P2PKH) output script.
type PurchaseTicketsRequest ¶
type PurchaseTicketsRequest struct { Count int SourceAccount uint32 VotingAddress stdaddr.StakeAddress MinConf int32 Expiry int32 VotingAccount uint32 // Used when VotingAddress == nil, or CSPPServer != "" DontSignTx bool // Mixed split buying through CoinShuffle++ CSPPServer string DialCSPPServer DialFunc MixedAccount uint32 MixedAccountBranch uint32 MixedSplitAccount uint32 ChangeAccount uint32 // VSP ticket buying; not currently usable with CoinShuffle++. VSPAddress stdaddr.StakeAddress VSPFees float64 // VSPFeeProcessFunc Process the fee price for the vsp to register a ticket // so we can reserve the amount. VSPFeeProcess func(context.Context) (float64, error) // VSPFeePaymentProcess processes the payment of the vsp fee and returns // the paid fee tx. VSPFeePaymentProcess func(context.Context, *chainhash.Hash, *wire.MsgTx) error // contains filtered or unexported fields }
PurchaseTicketsRequest describes the parameters for purchasing tickets.
type PurchaseTicketsResponse ¶
type PurchaseTicketsResponse struct { TicketHashes []*chainhash.Hash Tickets []*wire.MsgTx SplitTx *wire.MsgTx }
PurchaseTicketsResponse describes the response for purchasing tickets request.
type RemovedTransactionNotification ¶
RemovedTransactionNotification includes the removed transaction hash.
type RemovedTransactionNotificationsClient ¶
type RemovedTransactionNotificationsClient struct { C chan *RemovedTransactionNotification // contains filtered or unexported fields }
RemovedTransactionNotificationsClient receives RemovedTransactionNotifications over the channel C.
func (*RemovedTransactionNotificationsClient) Done ¶
func (c *RemovedTransactionNotificationsClient) Done()
Done deregisters the client from the server and drains any remaining messages. It must be called exactly once when the client is finished receiving notifications.
type RescanFilter ¶
type RescanFilter struct {
// contains filtered or unexported fields
}
RescanFilter implements a precise filter intended to hold all watched wallet data in memory such as addresses and unspent outputs. The zero value is not valid, and filters must be created using NewRescanFilter. RescanFilter is not safe for concurrent access.
func NewRescanFilter ¶
func NewRescanFilter(addresses []stdaddr.Address, unspentOutPoints []*wire.OutPoint) *RescanFilter
NewRescanFilter creates and initializes a RescanFilter containing each passed address and outpoint.
func (*RescanFilter) AddAddress ¶
func (f *RescanFilter) AddAddress(a stdaddr.Address)
AddAddress adds an address to the filter if it does not already exist.
func (*RescanFilter) AddUnspentOutPoint ¶
func (f *RescanFilter) AddUnspentOutPoint(op *wire.OutPoint)
AddUnspentOutPoint adds an outpoint to the filter if it does not already exist.
func (*RescanFilter) ExistsAddress ¶
func (f *RescanFilter) ExistsAddress(a stdaddr.Address) (ok bool)
ExistsAddress returns whether an address is contained in the filter.
func (*RescanFilter) ExistsUnspentOutPoint ¶
func (f *RescanFilter) ExistsUnspentOutPoint(op *wire.OutPoint) bool
ExistsUnspentOutPoint returns whether an outpoint is contained in the filter.
func (*RescanFilter) RemoveAddress ¶
func (f *RescanFilter) RemoveAddress(a stdaddr.Address)
RemoveAddress removes an address from the filter if it exists.
func (*RescanFilter) RemoveUnspentOutPoint ¶
func (f *RescanFilter) RemoveUnspentOutPoint(op *wire.OutPoint)
RemoveUnspentOutPoint removes an outpoint from the filter if it exists.
type RescanProgress ¶
RescanProgress records the height the rescan has completed through and any errors during processing of the rescan.
type SidechainForest ¶
type SidechainForest struct {
// contains filtered or unexported fields
}
SidechainForest provides in-memory management of sidechain and orphan blocks. It implements a forest of disjoint rooted trees, each tree containing sidechains stemming from a different fork point in the main chain, or orphans.
SidechainForest is not safe for concurrent access.
func (*SidechainForest) AddBlockNode ¶
func (f *SidechainForest) AddBlockNode(n *BlockNode) bool
AddBlockNode adds a sidechain block node to the forest. The node may either begin a new sidechain, extend an existing sidechain, or start or extend a tree of orphan blocks. Adding the parent node of a previously-saved orphan block will restructure the forest by re-rooting the previous orphan tree onto the tree containing the added node. Returns true iff the node if the node was not a duplicate.
func (*SidechainForest) FullSideChain ¶
func (f *SidechainForest) FullSideChain(newBlocks []*BlockNode) ([]*BlockNode, error)
FullSideChain returns the sidechain which starts at one of the existing roots and ends with the set of passed new blocks.
func (*SidechainForest) HasSideChainBlock ¶
func (f *SidechainForest) HasSideChainBlock(blockHash *chainhash.Hash) bool
HasSideChainBlock returns true if the given block hash is contained in the sidechain forest at any level.
func (*SidechainForest) Prune ¶
func (f *SidechainForest) Prune(mainChainHeight int32, params *chaincfg.Params)
Prune removes any sidechain trees which contain a root that is significantly behind the current main chain tip block.
func (*SidechainForest) PruneTree ¶
func (f *SidechainForest) PruneTree(root *chainhash.Hash)
PruneTree removes the tree beginning with root from the forest.
type SignatureError ¶
SignatureError records the underlying error when validating a transaction input signature.
type StakeDifficultyInfo ¶
type StakeDifficultyInfo struct { BlockHash *chainhash.Hash BlockHeight int64 StakeDifficulty int64 }
StakeDifficultyInfo is a container for stake difficulty information updates.
type StakeInfoData ¶
type StakeInfoData struct { BlockHeight int64 TotalSubsidy dcrutil.Amount Sdiff dcrutil.Amount OwnMempoolTix uint32 Unspent uint32 Voted uint32 Revoked uint32 UnspentExpired uint32 PoolSize uint32 AllMempoolTix uint32 Immature uint32 Live uint32 Missed uint32 Expired uint32 }
StakeInfoData carries counts of ticket states and other various stake data.
type TicketStatus ¶
type TicketStatus uint
TicketStatus describes the current status a ticket can be observed to be.
const ( // TicketStatusUnknown any ticket that its status was unable to be determined. TicketStatusUnknown TicketStatus = iota // unknown // TicketStatusUnmined any not yet mined ticket. TicketStatusUnmined // unmined // TicketStatusImmature any so to be live ticket. TicketStatusImmature // immature // TicketStatusLive any currently live ticket. TicketStatusLive // live // TicketStatusVoted any ticket that was seen to have voted. TicketStatusVoted // voted // TicketStatusMissed any ticket that has yet to be revoked, and was missed. TicketStatusMissed // missed // TicketStatusExpired any ticket that has yet to be revoked, and was expired. // In SPV mode, this status may be used by unspent tickets definitely // past the expiry period, even if the ticket was actually missed rather than // expiring. TicketStatusExpired // expired // TicketStatusUnspent is a matured ticket that has not been spent. It // is only used under SPV mode where it is unknown if a ticket is live, // was missed, or expired. TicketStatusUnspent // unspent // TicketStatusRevoked any ticket that has been previously revoked. TicketStatusRevoked // revoked )
func (TicketStatus) String ¶
func (i TicketStatus) String() string
type TicketSummary ¶
type TicketSummary struct { Ticket *TransactionSummary Spender *TransactionSummary Status TicketStatus }
TicketSummary contains the properties to describe a ticket's current status
type TransactionNotifications ¶
type TransactionNotifications struct { AttachedBlocks []Block DetachedBlocks []*wire.BlockHeader UnminedTransactions []TransactionSummary UnminedTransactionHashes []*chainhash.Hash NewBalances []AccountBalance }
TransactionNotifications is a notification of changes to the wallet's transaction set and the current chain tip that wallet is considered to be synced with. All transactions added to the blockchain are organized by the block they were mined in.
During a chain switch, all removed block hashes are included. Detached blocks are sorted in the reverse order they were mined. Attached blocks are sorted in the order mined.
All newly added unmined transactions are included. Removed unmined transactions are not explicitly included. Instead, the hashes of all transactions still unmined are included.
If any transactions were involved, each affected account's new total balance is included.
TODO: Because this includes stuff about blocks and can be fired without any changes to transactions, it needs a better name.
type TransactionNotificationsClient ¶
type TransactionNotificationsClient struct { C <-chan *TransactionNotifications // contains filtered or unexported fields }
TransactionNotificationsClient receives TransactionNotifications from the NotificationServer over the channel C.
func (*TransactionNotificationsClient) Done ¶
func (c *TransactionNotificationsClient) Done()
Done deregisters the client from the server and drains any remaining messages. It must be called exactly once when the client is finished receiving notifications.
type TransactionOutput ¶
type TransactionOutput struct { OutPoint wire.OutPoint Output wire.TxOut OutputKind OutputKind // These should be added later when the DB can return them more // efficiently: //TxLockTime uint32 //TxExpiry uint32 ContainingBlock BlockIdentity ReceiveTime time.Time }
TransactionOutput describes an output that was or is at least partially controlled by the wallet. Depending on context, this could refer to an unspent output, or a spent one.
type TransactionSummary ¶
type TransactionSummary struct { Hash *chainhash.Hash Transaction []byte MyInputs []TransactionSummaryInput MyOutputs []TransactionSummaryOutput Fee dcrutil.Amount Timestamp int64 Type TransactionType }
TransactionSummary contains a transaction relevant to the wallet and marks which inputs and outputs were relevant.
type TransactionSummaryInput ¶
type TransactionSummaryInput struct { Index uint32 PreviousAccount uint32 PreviousAmount dcrutil.Amount }
TransactionSummaryInput describes a transaction input that is relevant to the wallet. The Index field marks the transaction input index of the transaction (not included here). The PreviousAccount and PreviousAmount fields describe how much this input debits from a wallet account.
type TransactionSummaryOutput ¶
type TransactionSummaryOutput struct { Index uint32 Account uint32 Internal bool Amount dcrutil.Amount Address stdaddr.Address OutputScript []byte }
TransactionSummaryOutput describes wallet properties of a transaction output controlled by the wallet. The Index field marks the transaction output index of the transaction (not included here).
type TransactionType ¶
type TransactionType int8
TransactionType describes the which type of transaction is has been observed to be. For instance, if it has a ticket as an input and a stake base reward as an output, it is known to be a vote.
const ( // TransactionTypeRegular transaction type for all regular transactions. TransactionTypeRegular TransactionType = iota // TransactionTypeCoinbase is the transaction type for all coinbase transactions. TransactionTypeCoinbase // TransactionTypeTicketPurchase transaction type for all transactions that // consume regular transactions as inputs and have commitments for future votes // as outputs. TransactionTypeTicketPurchase // TransactionTypeVote transaction type for all transactions that consume a ticket // and also offer a stake base reward output. TransactionTypeVote // TransactionTypeRevocation transaction type for all transactions that consume a // ticket, but offer no stake base reward. TransactionTypeRevocation )
func TxTransactionType ¶
func TxTransactionType(tx *wire.MsgTx) TransactionType
TxTransactionType returns the correct TransactionType given a wire transaction
type TreasuryKeyPolicy ¶
type TreasuryKeyPolicy struct { PiKey []byte Ticket *chainhash.Hash // nil unless for per-ticket VSP policies Policy stake.TreasuryVoteT }
TreasuryKeyPolicy records the voting policy for treasury spend transactions by a particular key, and possibly for a particular ticket being voted on by a VSP.
type Wallet ¶
type Wallet struct { NtfnServer *NotificationServer // contains filtered or unexported fields }
Wallet is a structure containing all the components for a complete wallet. It contains the Armory-style key store addresses and keys),
func Open ¶
Open loads an already-created wallet from the passed database and namespaces configuration options and sets it up it according to the rest of options.
func (*Wallet) AbandonTransaction ¶
AbandonTransaction removes a transaction, identified by its hash, from the wallet if present. All transaction spend chains deriving from the transaction's outputs are also removed. Does not error if the transaction doesn't already exist unmined, but will if the transaction is marked mined in a block on the main chain.
Purged transactions may have already been published to the network and may still appear in future blocks, and new transactions spending the same inputs as purged transactions may be rejected by full nodes due to being double spends. In turn, this can cause the purged transaction to be mined later and replace other transactions authored by the wallet.
func (*Wallet) AccountBalance ¶
func (w *Wallet) AccountBalance(ctx context.Context, account uint32, confirms int32) (Balances, error)
AccountBalance returns the balance breakdown for a single account.
func (*Wallet) AccountBalances ¶
AccountBalances returns the balance breakdowns for a each account.
func (*Wallet) AccountHasPassphrase ¶
func (*Wallet) AccountName ¶
AccountName returns the name of an account.
func (*Wallet) AccountNumber ¶
AccountNumber returns the account number for an account name.
func (*Wallet) AccountUnlocked ¶
AccountUnlocked returns whether an individually-encrypted account is unlocked.
func (*Wallet) AccountXpriv ¶
AccountXpriv returns a BIP0044 account's extended private key. The account must exist and the wallet must be unlocked, otherwise this function fails.
func (*Wallet) AccountXpub ¶
AccountXpub returns a BIP0044 account's extended public key.
func (*Wallet) Accounts ¶
func (w *Wallet) Accounts(ctx context.Context) (*AccountsResult, error)
Accounts returns the current names, numbers, and total balances of all accounts in the wallet. The current chain tip is included in the result for atomicity reasons.
TODO(jrick): Is the chain tip really needed, since only the total balances are included?
func (*Wallet) AddTransaction ¶
func (w *Wallet) AddTransaction(ctx context.Context, tx *wire.MsgTx, blockHash *chainhash.Hash) error
AddTransaction stores tx, marking it as mined in the block described by blockHash, or recording it to the wallet's mempool when nil.
This method will always add ticket transactions to the wallet, even when configured in manual ticket mode. It is up to network syncers to avoid calling this method on unmined tickets.
func (*Wallet) AgendaChoices ¶
func (w *Wallet) AgendaChoices(ctx context.Context, ticketHash *chainhash.Hash) (choices []AgendaChoice, voteBits uint16, err error)
AgendaChoices returns the choice IDs for every agenda of the supported stake version. Abstains are included. Returns choice IDs set for the specified non-nil ticket hash, or the default choice IDs if the ticket hash is nil or there are no choices set for the ticket.
func (*Wallet) AllowsHighFees ¶
AllowsHighFees returns whether the wallet is configured to allow or prevent the creation and publishing of transactions with very large fees.
func (*Wallet) BIP0044BranchNextIndexes ¶
func (w *Wallet) BIP0044BranchNextIndexes(ctx context.Context, account uint32) (extChild, intChild uint32, err error)
BIP0044BranchNextIndexes returns the next external and internal branch child indexes of an account.
func (*Wallet) BlockHeader ¶
func (w *Wallet) BlockHeader(ctx context.Context, blockHash *chainhash.Hash) (*wire.BlockHeader, error)
BlockHeader returns the block header for a block by it's identifying hash, if it is recorded by the wallet.
func (*Wallet) BlockInMainChain ¶
func (w *Wallet) BlockInMainChain(ctx context.Context, hash *chainhash.Hash) (haveBlock, invalidated bool, err error)
BlockInMainChain returns whether hash is a block hash of any block in the wallet's main chain. If the block is in the main chain, invalidated reports whether a child block in the main chain stake invalidates the queried block.
func (*Wallet) BlockLocators ¶
func (w *Wallet) BlockLocators(ctx context.Context, sidechain []*BlockNode) ([]*chainhash.Hash, error)
BlockLocators returns block locators, suitable for use in a getheaders wire message or dcrd JSON-RPC request, for the blocks in sidechain and saved in the wallet's main chain. For memory and lookup efficiency, many older hashes are skipped, with increasing gaps between included hashes.
When sidechain has zero length, locators for only main chain blocks starting from the tip are returned. Otherwise, locators are created starting with the best (last) block of sidechain and sidechain[0] must be a child of a main chain block (sidechain may not contain orphan blocks).
func (*Wallet) CFilterV2 ¶
func (w *Wallet) CFilterV2(ctx context.Context, blockHash *chainhash.Hash) ([gcs2.KeySize]byte, *gcs2.FilterV2, error)
CFilterV2 returns the version 2 regular compact filter for a block along with the key required to query it for matches against committed scripts.
func (*Wallet) ChainParams ¶
func (w *Wallet) ChainParams() *chaincfg.Params
ChainParams returns the network parameters for the blockchain the wallet belongs to.
func (*Wallet) ChainSwitch ¶
func (w *Wallet) ChainSwitch(ctx context.Context, forest *SidechainForest, chain []*BlockNode, relevantTxs map[chainhash.Hash][]*wire.MsgTx) ([]*BlockNode, error)
ChainSwitch updates the wallet's main chain, either by extending the chain with new blocks, or switching to a better sidechain. A sidechain for removed blocks (if any) is returned. If relevantTxs is non-nil, the block marker for the latest block with processed transactions is updated for the new tip block.
func (*Wallet) ChangePrivatePassphrase ¶
ChangePrivatePassphrase attempts to change the passphrase for a wallet from old to new. Changing the passphrase is synchronized with all other address manager locking and unlocking. The lock state will be the same as it was before the password change.
func (*Wallet) ChangePublicPassphrase ¶
ChangePublicPassphrase modifies the public passphrase of the wallet.
func (*Wallet) CoinType ¶
CoinType returns the active BIP0044 coin type. For watching-only wallets, which do not save the coin type keys, this method will return an error with code errors.WatchingOnly.
func (*Wallet) CoinTypePrivKey ¶
CoinTypePrivKey returns the BIP0044 coin type private key.
func (*Wallet) CommittedTickets ¶
func (w *Wallet) CommittedTickets(ctx context.Context, tickets []*chainhash.Hash) ([]*chainhash.Hash, []stdaddr.Address, error)
CommittedTickets takes a list of tickets and returns a filtered list of tickets that are controlled by this wallet.
func (*Wallet) Consolidate ¶
func (w *Wallet) Consolidate(ctx context.Context, inputs int, account uint32, address stdaddr.Address) (*chainhash.Hash, error)
Consolidate consolidates as many UTXOs as are passed in the inputs argument. If that many UTXOs can not be found, it will use the maximum it finds. This will only compress UTXOs in the default account
func (*Wallet) CreateMultisigTx ¶
func (w *Wallet) CreateMultisigTx(ctx context.Context, account uint32, amount dcrutil.Amount, pubkeys [][]byte, nrequired int8, minconf int32) (*CreatedTx, stdaddr.Address, []byte, error)
CreateMultisigTx creates and signs a multisig transaction.
func (*Wallet) CreateSignature ¶
func (w *Wallet) CreateSignature(ctx context.Context, tx *wire.MsgTx, idx uint32, addr stdaddr.Address, hashType txscript.SigHashType, prevPkScript []byte) (sig, pubkey []byte, err error)
CreateSignature returns the raw signature created by the private key of addr for tx's idx'th input script and the serialized compressed pubkey for the address.
func (*Wallet) CurrentAddress ¶
CurrentAddress gets the most recently requested payment address from a wallet. If the address has already been used (there is at least one transaction spending to it in the blockchain or dcrd mempool), the next chained address is returned.
func (*Wallet) DetermineRelevantTxs ¶
func (w *Wallet) DetermineRelevantTxs(ctx context.Context, txs ...*wire.MsgTx) ([]*wire.MsgTx, []*wire.MsgTx, error)
DetermineRelevantTxs splits the given transactions into slices of relevant and non-wallet-relevant transactions (respectively).
func (*Wallet) DisapprovePercent ¶
DisapprovePercent returns the wallet's block disapproval percentage.
func (*Wallet) DiscoverActiveAddresses ¶
func (w *Wallet) DiscoverActiveAddresses(ctx context.Context, p Peer, startBlock *chainhash.Hash, discoverAccts bool, gapLimit uint32) error
DiscoverActiveAddresses searches for future wallet address usage in all blocks starting from startBlock. If discoverAccts is true, used accounts will be discovered as well. This feature requires the wallet to be unlocked in order to derive hardened account extended pubkeys.
If the wallet is currently on the legacy coin type and no address or account usage is observed and coin type upgrades are not disabled, the wallet will be upgraded to the SLIP0044 coin type and the address discovery will occur again.
func (*Wallet) DumpWIFPrivateKey ¶
DumpWIFPrivateKey returns the WIF encoded private key for a single wallet address.
func (*Wallet) EvaluateBestChain ¶
EvaluateBestChain returns block nodes to create the best main chain. These may extend the main chain or require a reorg. An empty slice indicates there is no better chain.
func (*Wallet) FetchMissingCFilters ¶
FetchMissingCFilters records any missing compact filters for main chain blocks. A database upgrade requires all compact filters to be recorded for the main chain before any more blocks may be attached, but this information must be fetched at runtime after the upgrade as it is not already known at the time of upgrade.
func (*Wallet) FetchMissingCFiltersWithProgress ¶
func (w *Wallet) FetchMissingCFiltersWithProgress(ctx context.Context, p Peer, progress chan<- MissingCFilterProgress)
FetchMissingCFiltersWithProgress records any missing compact filters for main chain blocks. A database upgrade requires all compact filters to be recorded for the main chain before any more blocks may be attached, but this information must be fetched at runtime after the upgrade as it is not already known at the time of upgrade. This function reports to a channel with any progress that may have seen.
func (*Wallet) FetchOutput ¶
FetchOutput fetches the associated transaction output given an outpoint. It cannot be used to fetch multi-signature outputs.
func (*Wallet) FetchP2SHMultiSigOutput ¶
func (w *Wallet) FetchP2SHMultiSigOutput(ctx context.Context, outPoint *wire.OutPoint) (*P2SHMultiSigOutput, error)
FetchP2SHMultiSigOutput fetches information regarding a wallet's P2SH multi-signature output.
func (*Wallet) ForUnspentUnexpiredTickets ¶ added in v2.0.1
func (w *Wallet) ForUnspentUnexpiredTickets(ctx context.Context, f func(hash *chainhash.Hash) error) error
ForUnspentUnexpiredTickets performs a function on every unexpired and unspent ticket from the wallet.
func (*Wallet) GenerateVoteTx
deprecated
func (w *Wallet) GenerateVoteTx(ctx context.Context, blockHash *chainhash.Hash, height int32, ticketHash *chainhash.Hash, voteBits stake.VoteBits) (*wire.MsgTx, error)
GenerateVoteTx creates a vote transaction for a chosen ticket purchase hash using the provided votebits. The ticket purchase transaction must be stored by the wallet.
Deprecated: This method will not produce the proper vote subsidy after DCP0010 activation.
func (*Wallet) GetAllTSpends ¶
GetAllTSpends returns all tspends currently in the cache. Note: currently the tspend list does not get culled.
func (*Wallet) GetCoinjoinTxsSumbByAcct ¶
GetCoinjoinTxsSumbByAcct gets all coinjoin outputs sum by accounts. This is done in case we need to guess a mixed account on wallet recovery.
func (*Wallet) GetTicketInfo ¶
func (w *Wallet) GetTicketInfo(ctx context.Context, hash *chainhash.Hash) (*TicketSummary, *wire.BlockHeader, error)
GetTicketInfo returns the ticket summary and the corresponding block header for the provided ticket. The ticket summary is comprised of the transaction summmary for the ticket, the spender (if already spent) and the ticket's current status.
If the ticket is unmined, then the returned block header will be nil.
func (*Wallet) GetTicketInfoPrecise ¶
func (w *Wallet) GetTicketInfoPrecise(ctx context.Context, rpcCaller Caller, hash *chainhash.Hash) (*TicketSummary, *wire.BlockHeader, error)
GetTicketInfoPrecise returns the ticket summary and the corresponding block header for the provided ticket. The ticket summary is comprised of the transaction summmary for the ticket, the spender (if already spent) and the ticket's current status.
If the ticket is unmined, then the returned block header will be nil.
The argument chainClient is always expected to be not nil in this case, otherwise one should use the alternative GetTicketInfo instead. With the ability to use the rpc chain client, this function is able to determine whether a ticket has been missed or not. Otherwise, it is just known to be unspent (possibly live or missed).
func (*Wallet) GetTickets ¶
func (w *Wallet) GetTickets(ctx context.Context, f func([]*TicketSummary, *wire.BlockHeader) (bool, error), startBlock, endBlock *BlockIdentifier) error
GetTickets calls function f for all tickets located in between the given startBlock and endBlock. TicketSummary includes TransactionSummmary for the ticket and the spender (if already spent) and the ticket's current status. The function f also receives block header of the ticket. All tickets on a given call belong to the same block and at least one ticket is present when f is called. If the ticket is unmined, the block header will be nil.
The function f may return an error which, if non-nil, is propagated to the caller. Additionally, a boolean return value allows exiting the function early without reading any additional transactions when true.
The arguments to f may be reused and should not be kept by the caller.
Because this function does not have any chain client argument, tickets are unable to be determined whether or not they have been missed, simply unspent.
func (*Wallet) GetTicketsPrecise ¶
func (w *Wallet) GetTicketsPrecise(ctx context.Context, rpcCaller Caller, f func([]*TicketSummary, *wire.BlockHeader) (bool, error), startBlock, endBlock *BlockIdentifier) error
GetTicketsPrecise calls function f for all tickets located in between the given startBlock and endBlock. TicketSummary includes TransactionSummmary for the ticket and the spender (if already spent) and the ticket's current status. The function f also receives block header of the ticket. All tickets on a given call belong to the same block and at least one ticket is present when f is called. If the ticket is unmined, the block header will be nil.
The function f may return an error which, if non-nil, is propagated to the caller. Additionally, a boolean return value allows exiting the function early without reading any additional transactions when true.
The arguments to f may be reused and should not be kept by the caller.
The argument chainClient is always expected to be not nil in this case, otherwise one should use the alternative GetTickets instead. With the ability to use the rpc chain client, this function is able to determine whether tickets have been missed or not. Otherwise, tickets are just known to be unspent (possibly live or missed).
func (*Wallet) GetTransactions ¶
func (w *Wallet) GetTransactions(ctx context.Context, f func(*Block) (bool, error), startBlock, endBlock *BlockIdentifier) error
GetTransactions runs the function f on all transactions between a starting and ending block. Blocks in the block range may be specified by either a height or a hash.
The function f may return an error which, if non-nil, is propagated to the caller. Additionally, a boolean return value allows exiting the function early without reading any additional transactions when true.
Transaction results are organized by blocks in ascending order and unmined transactions in an unspecified order. Mined transactions are saved in a Block structure which records properties about the block. Unmined transactions are returned on a Block structure with height == -1.
Internally this function uses the udb store RangeTransactions function, therefore the notes and restrictions of that function also apply here.
func (*Wallet) GetTransactionsByHashes ¶
func (w *Wallet) GetTransactionsByHashes(ctx context.Context, txHashes []*chainhash.Hash) (txs []*wire.MsgTx, notFound []*wire.InvVect, err error)
GetTransactionsByHashes returns all known transactions identified by a slice of transaction hashes. It is possible that not all transactions are found, and in this case the known results will be returned along with an inventory vector of all missing transactions and an error with code NotExist.
func (*Wallet) GetVSPTicketsByFeeStatus ¶
func (w *Wallet) GetVSPTicketsByFeeStatus(ctx context.Context, feeStatus int) ([]chainhash.Hash, error)
GetVSPTicketsByFeeStatus returns the ticket hashes of tickets with the informed fee status.
func (*Wallet) HaveAddress ¶
HaveAddress returns whether the wallet is the owner of the address a.
func (*Wallet) ImportCFiltersV2 ¶
func (w *Wallet) ImportCFiltersV2(ctx context.Context, startBlockHeight int32, filterData [][]byte) error
ImportCFiltersV2 imports the provided v2 cfilters starting at the specified block height. Headers for all the provided filters must have already been imported into the wallet, otherwise this method fails. Existing filters for the respective blocks are overridden.
Note: No validation is performed on the contents of the imported filters. Importing filters that do not correspond to the actual contents of a block might cause the wallet to miss relevant transactions.
func (*Wallet) ImportPrivateKey ¶
ImportPrivateKey imports a private key to the wallet and writes the new wallet to disk.
func (*Wallet) ImportScript ¶
ImportScript imports a redeemscript to the wallet. If it also allows the user to specify whether or not they want the redeemscript to be rescanned, and how far back they wish to rescan.
func (*Wallet) ImportVotingAccount ¶
func (w *Wallet) ImportVotingAccount(ctx context.Context, xpriv *hdkeychain.ExtendedKey, passphrase []byte, name string) (uint32, error)
ImportVotingAccount imports a voting account to the wallet. A password and unique name must be supplied. The xpriv must be for the current running network.
func (*Wallet) ImportXpubAccount ¶
func (*Wallet) ImportedAddresses ¶
func (w *Wallet) ImportedAddresses(ctx context.Context, account string) (_ []KnownAddress, err error)
ImportedAddresses returns each of the addresses imported into an account.
func (*Wallet) InitialHeight ¶
InitialHeight is the wallet's tip height prior to syncing with the network.
func (*Wallet) IsVSPTicketConfirmed ¶
func (w *Wallet) IsVSPTicketConfirmed(ctx context.Context, ticketHash *chainhash.Hash) (bool, error)
IsVSPTicketConfirmed returns whether or not a VSP ticket has been confirmed by a VSP.
func (*Wallet) KnownAddress ¶
KnownAddress returns the KnownAddress implementation for an address. The returned address may implement other interfaces (such as, but not limited to, PubKeyHashAddress, BIP0044Address, or P2SHAddress) depending on the script type and account for the address.
func (*Wallet) ListAddressTransactions ¶
func (w *Wallet) ListAddressTransactions(ctx context.Context, pkHashes map[string]struct{}) ([]types.ListTransactionsResult, error)
ListAddressTransactions returns a slice of objects with details about recorded transactions to or from any address belonging to a set. This is intended to be used for listaddresstransactions RPC replies.
func (*Wallet) ListAllTransactions ¶
ListAllTransactions returns a slice of objects with details about a recorded transaction. This is intended to be used for listalltransactions RPC replies.
func (*Wallet) ListSinceBlock ¶
func (w *Wallet) ListSinceBlock(ctx context.Context, start, end, syncHeight int32) ([]types.ListTransactionsResult, error)
ListSinceBlock returns a slice of objects with details about transactions since the given block. If the block is -1 then all transactions are included. This is intended to be used for listsinceblock RPC replies.
func (*Wallet) ListTransactionDetails ¶
func (w *Wallet) ListTransactionDetails(ctx context.Context, txHash *chainhash.Hash) ([]types.ListTransactionsResult, error)
ListTransactionDetails returns the listtransaction results for a single transaction.
func (*Wallet) ListTransactions ¶
func (w *Wallet) ListTransactions(ctx context.Context, from, count int) ([]types.ListTransactionsResult, error)
ListTransactions returns a slice of objects with details about a recorded transaction. This is intended to be used for listtransactions RPC replies.
func (*Wallet) ListUnspent ¶
func (w *Wallet) ListUnspent(ctx context.Context, minconf, maxconf int32, addresses map[string]struct{}, accountName string) ([]*types.ListUnspentResult, error)
ListUnspent returns a slice of objects representing the unspent wallet transactions fitting the given criteria. The confirmations will be more than minconf, less than maxconf and if addresses is populated only the addresses contained within it will be considered. If we know nothing about a transaction an empty array will be returned.
func (*Wallet) LiveTicketHashes ¶
func (w *Wallet) LiveTicketHashes(ctx context.Context, rpcCaller Caller, includeImmature bool) ([]chainhash.Hash, error)
LiveTicketHashes returns the hashes of live tickets that the wallet has purchased or has voting authority for.
func (*Wallet) LoadActiveDataFilters ¶
func (w *Wallet) LoadActiveDataFilters(ctx context.Context, n NetworkBackend, reload bool) (err error)
LoadActiveDataFilters loads filters for all active addresses and unspent outpoints for this wallet.
func (*Wallet) LoadPrivateKey ¶
func (*Wallet) LockAccount ¶
LockAccount locks an individually-encrypted account by removing private key access until unlocked again.
func (*Wallet) LockOutpoint ¶
LockOutpoint marks an outpoint as locked, that is, it should not be used as an input for newly created transactions.
func (*Wallet) LockedOutpoint ¶
LockedOutpoint returns whether an outpoint has been marked as locked and should not be used as an input for created transactions.
func (*Wallet) LockedOutpoints ¶
func (w *Wallet) LockedOutpoints(ctx context.Context, accountName string) ([]dcrdtypes.TransactionInput, error)
LockedOutpoints returns a slice of currently locked outpoints. This is intended to be used by marshaling the result as a JSON array for listlockunspent RPC results.
func (*Wallet) MainChainTip ¶
MainChainTip returns the hash and height of the tip-most block in the main chain that the wallet is synchronized to.
func (*Wallet) ManualTickets ¶
ManualTickets returns whether network syncers should avoid adding ticket transactions to the wallet, instead requiring the wallet administrator to manually record any tickets. This can be used to prevent wallets from voting using tickets bought by others but which reuse our voting address.
func (*Wallet) MixAccount ¶
func (w *Wallet) MixAccount(ctx context.Context, dialTLS DialFunc, csppserver string, changeAccount, mixAccount, mixBranch uint32) error
MixAccount individually mixes outputs of an account into standard denominations, creating newly mixed outputs for a mixed account.
Due to performance concerns of timing out in a CoinShuffle++ run, this function may throttle how many of the outputs are mixed each call.
func (*Wallet) NeedsAccountsSync ¶
NeedsAccountsSync returns whether or not the wallet is void of any generated keys and accounts (other than the default account), and records the genesis block as the main chain tip. When these are both true, an accounts sync should be performed to restore, per BIP0044, any generated accounts and addresses from a restored seed.
func (*Wallet) NetworkBackend ¶
func (w *Wallet) NetworkBackend() (NetworkBackend, error)
NetworkBackend returns the currently associated network backend of the wallet, or an error if the no backend is currently set.
func (*Wallet) NewChangeAddress ¶
NewChangeAddress returns an internal address. This is identical to NewInternalAddress but handles the imported account (which can't create addresses) by using account 0 instead, and always uses the wrapping gap limit policy.
func (*Wallet) NewExternalAddress ¶
func (w *Wallet) NewExternalAddress(ctx context.Context, account uint32, callOpts ...NextAddressCallOption) (stdaddr.Address, error)
NewExternalAddress returns an external address.
func (*Wallet) NewInternalAddress ¶
func (w *Wallet) NewInternalAddress(ctx context.Context, account uint32, callOpts ...NextAddressCallOption) (stdaddr.Address, error)
NewInternalAddress returns an internal address.
func (*Wallet) NewUnsignedTransaction ¶
func (w *Wallet) NewUnsignedTransaction(ctx context.Context, outputs []*wire.TxOut, relayFeePerKb dcrutil.Amount, account uint32, minConf int32, algo OutputSelectionAlgorithm, changeSource txauthor.ChangeSource, inputSource txauthor.InputSource) (*txauthor.AuthoredTx, error)
NewUnsignedTransaction constructs an unsigned transaction using unspent account outputs.
The changeSource and inputSource parameters are optional and can be nil. When the changeSource is nil and change output should be added, an internal change address is created for the account. When the inputSource is nil, the inputs will be selected by the wallet.
func (*Wallet) NextAccount ¶
NextAccount creates the next account and returns its account number. The name must be unique to the account. In order to support automatic seed restoring, new accounts may not be created when all of the previous 100 accounts have no transaction history (this is a deviation from the BIP0044 spec, which allows no unused account gaps).
func (*Wallet) NextStakeDifficulty ¶
NextStakeDifficulty returns the ticket price for the next block after the current main chain tip block. This function only succeeds when DCP0001 is known to be active. As a fallback, the StakeDifficulty method of wallet.NetworkBackend may be used to query the next ticket price from a trusted full node.
func (*Wallet) NextStakeDifficultyAfterHeader ¶
func (w *Wallet) NextStakeDifficultyAfterHeader(ctx context.Context, h *wire.BlockHeader) (dcrutil.Amount, error)
NextStakeDifficultyAfterHeader returns the ticket price for the child of h. All headers of ancestor blocks of h must be recorded by the wallet. This function only succeeds when DCP0001 is known to be active.
func (*Wallet) OutputInfo ¶
OutputInfo queries the wallet for additional transaction output info regarding an outpoint.
func (*Wallet) PrepareRedeemMultiSigOutTxOutput ¶
func (w *Wallet) PrepareRedeemMultiSigOutTxOutput(msgTx *wire.MsgTx, p2shOutput *P2SHMultiSigOutput, pkScript *[]byte) error
PrepareRedeemMultiSigOutTxOutput estimates the tx value for a MultiSigOutTx output and adds it to msgTx.
func (*Wallet) PublishTransaction ¶
func (w *Wallet) PublishTransaction(ctx context.Context, tx *wire.MsgTx, n NetworkBackend) (*chainhash.Hash, error)
PublishTransaction saves (if relevant) and sends the transaction to the consensus RPC server so it can be propagated to other nodes and eventually mined. If the send fails, the transaction is not added to the wallet.
This method does not check if a transaction pays high fees or not, and it is the caller's responsibility to check this using either the current wallet policy or other configuration parameters. See txrules.TxPaysHighFees for a check for insanely high transaction fees.
func (*Wallet) PublishUnminedTransactions ¶
PublishUnminedTransactions rebroadcasts all unmined transactions to the consensus RPC server so it can be propagated to other nodes and eventually mined.
func (*Wallet) PurchaseTickets ¶
func (w *Wallet) PurchaseTickets(ctx context.Context, n NetworkBackend, req *PurchaseTicketsRequest) (*PurchaseTicketsResponse, error)
PurchaseTickets purchases tickets, returning purchase tickets response.
func (*Wallet) RangeCFiltersV2 ¶
func (w *Wallet) RangeCFiltersV2(ctx context.Context, startBlock, endBlock *BlockIdentifier, f func(chainhash.Hash, [gcs2.KeySize]byte, *gcs2.FilterV2) (bool, error)) error
RangeCFiltersV2 calls the function `f` for the set of version 2 committed filters for the main chain within the specificed block range.
The default behavior for an unspecified range is to loop over the entire main chain.
The function `f` may return true for the first argument to indicate no more items should be fetched. Any returned errors by `f` also cause the loop to fail.
Note that the filter passed to `f` is safe for use after `f` returns.
func (*Wallet) RelayFee ¶
func (w *Wallet) RelayFee() dcrutil.Amount
RelayFee returns the current minimum relay fee (per kB of serialized transaction) used when constructing transactions.
func (*Wallet) RenameAccount ¶
RenameAccount sets the name for an account number to newName.
func (*Wallet) Rescan ¶
Rescan starts a rescan of the wallet for all blocks on the main chain beginning at startHash. This function blocks until the rescan completes.
func (*Wallet) RescanFromHeight ¶
RescanFromHeight is an alternative to Rescan that takes a block height instead of a hash. See Rescan for more details.
func (*Wallet) RescanPoint ¶
RescanPoint returns the block hash at which a rescan should begin (inclusive), or nil when no rescan is necessary.
func (*Wallet) RescanProgressFromHeight ¶
func (w *Wallet) RescanProgressFromHeight(ctx context.Context, n NetworkBackend, startHeight int32, p chan<- RescanProgress)
RescanProgressFromHeight rescans for relevant transactions in all blocks in the main chain starting at startHeight. Progress notifications and any errors are sent to the channel p. This function blocks until the rescan completes or ends in an error. p is closed before returning.
func (*Wallet) ReserveOutputsForAmount ¶
func (w *Wallet) ReserveOutputsForAmount(ctx context.Context, account uint32, amount dcrutil.Amount, minconf int32) ([]Input, error)
ReserveOutputsForAmount returns locked spendable outpoints from the given account. It is the responsibility of the caller to unlock the outpoints.
func (*Wallet) ResetLockedOutpoints ¶
func (w *Wallet) ResetLockedOutpoints()
ResetLockedOutpoints resets the set of locked outpoints so all may be used as inputs for new transactions.
func (*Wallet) RevokeExpiredTickets
deprecated
func (*Wallet) RevokeOwnedTickets
deprecated
func (*Wallet) RevokeTicket
deprecated
func (*Wallet) RevokeTickets ¶
RevokeTickets creates and sends revocation transactions for any unrevoked missed and expired tickets. The wallet must be unlocked to generate any revocations.
func (*Wallet) SaveRescanned ¶
SaveRescanned records transactions from a rescanned block. This does not update the network backend with data to watch for future relevant transactions as the rescanner is assumed to handle this task.
func (*Wallet) SelectInputs ¶
func (w *Wallet) SelectInputs(ctx context.Context, targetAmount dcrutil.Amount, policy OutputSelectionPolicy) (inputDetail *txauthor.InputDetail, err error)
SelectInputs selects transaction inputs to redeem unspent outputs stored in the wallet. It returns an input detail summary.
func (*Wallet) SendOutputs ¶
func (w *Wallet) SendOutputs(ctx context.Context, outputs []*wire.TxOut, account, changeAccount uint32, minconf int32) (*chainhash.Hash, error)
SendOutputs creates and sends payment transactions. It returns the transaction hash upon success
func (*Wallet) SendOutputsToTreasury ¶
func (w *Wallet) SendOutputsToTreasury(ctx context.Context, outputs []*wire.TxOut, account, changeAccount uint32, minconf int32) (*chainhash.Hash, error)
transaction hash upon success
func (*Wallet) SetAccountPassphrase ¶
SetAccountPassphrase individually-encrypts or changes the passphrase for account private keys.
If the passphrase has zero length, the private keys are re-encrypted with the manager's global passphrase.
func (*Wallet) SetAgendaChoices ¶
func (w *Wallet) SetAgendaChoices(ctx context.Context, ticketHash *chainhash.Hash, choices ...AgendaChoice) (voteBits uint16, err error)
SetAgendaChoices sets the choices for agendas defined by the supported stake version. If a choice is set multiple times, the last takes preference. The new votebits after each change is made are returned. If a ticketHash is provided, agenda choices are only set for that ticket and the new votebits for that ticket is returned.
func (*Wallet) SetDisapprovePercent ¶
SetDisapprovePercent sets the wallet's block disapproval percentage. Do not set on mainnet.
func (*Wallet) SetNetworkBackend ¶
func (w *Wallet) SetNetworkBackend(n NetworkBackend)
SetNetworkBackend sets the network backend used by various functions of the wallet.
func (*Wallet) SetPublished ¶
SetPublished sets the informed hash as true or false.
func (*Wallet) SetRelayFee ¶
func (w *Wallet) SetRelayFee(relayFee dcrutil.Amount)
SetRelayFee sets a new minimum relay fee (per kB of serialized transaction) used when constructing transactions.
func (*Wallet) SetTSpendPolicy ¶
func (w *Wallet) SetTSpendPolicy(ctx context.Context, tspendHash *chainhash.Hash, policy stake.TreasuryVoteT, ticketHash *chainhash.Hash) error
SetTSpendPolicy sets a tspend vote policy for a specific tspend transaction hash. A non-nil ticket hash may be used by a VSP to set per-ticket policies.
func (*Wallet) SetTreasuryKeyPolicy ¶
func (w *Wallet) SetTreasuryKeyPolicy(ctx context.Context, pikey []byte, policy stake.TreasuryVoteT, ticketHash *chainhash.Hash) error
SetTreasuryKeyPolicy sets a tspend vote policy for a specific Politeia instance key. A non-nil ticket hash may be used by a VSP to set per-ticket policies.
func (*Wallet) SignHashes ¶
func (w *Wallet) SignHashes(ctx context.Context, hashes [][]byte, addr stdaddr.Address) ([][]byte, []byte, error)
SignHashes returns signatures of signed transaction hashes using an address' associated private key.
func (*Wallet) SignMessage ¶
func (w *Wallet) SignMessage(ctx context.Context, msg string, addr stdaddr.Address) (sig []byte, err error)
SignMessage returns the signature of a signed message using an address' associated private key.
func (*Wallet) SignTransaction ¶
func (w *Wallet) SignTransaction(ctx context.Context, tx *wire.MsgTx, hashType txscript.SigHashType, additionalPrevScripts map[wire.OutPoint][]byte, additionalKeysByAddress map[string]*dcrutil.WIF, p2shRedeemScriptsByAddress map[string][]byte) ([]SignatureError, error)
SignTransaction uses secrets of the wallet, as well as additional secrets passed in by the caller, to create and add input signatures to a transaction.
Transaction input script validation is used to confirm that all signatures are valid. For any invalid input, a SignatureError is added to the returns. The final error return is reserved for unexpected or fatal errors, such as being unable to determine a previous output script to redeem.
The transaction pointed to by tx is modified by this function.
func (*Wallet) SortedActivePaymentAddresses ¶
SortedActivePaymentAddresses returns a slice of all active payment addresses in a wallet.
func (*Wallet) Spender ¶
Spender queries for the transaction and input index which spends a Credit. If the output is not a Credit, an error with code ErrInput is returned. If the output is unspent, the ErrNoExist code is used.
func (*Wallet) StakeInfo ¶
func (w *Wallet) StakeInfo(ctx context.Context) (*StakeInfoData, error)
StakeInfo collects and returns staking statistics for this wallet.
func (*Wallet) StakeInfoPrecise ¶
StakeInfoPrecise collects and returns staking statistics for this wallet. It uses RPC to query further information than StakeInfo.
func (*Wallet) StakePoolUserInfo ¶
func (w *Wallet) StakePoolUserInfo(ctx context.Context, userAddress stdaddr.StakeAddress) (*udb.StakePoolUser, error)
StakePoolUserInfo returns the stake pool user information for a user identified by their voting address.
func (*Wallet) SyncLastReturnedAddress ¶
SyncLastReturnedAddress advances the last returned child address for a BIP00044 account branch. The next returned address for the branch will be child+1.
func (*Wallet) TSpendPolicy ¶
TSpendPolicy returns a vote policy for a tspend. If a policy is set for a particular tspend transaction, that policy is returned. Otherwise, if the tspend is known, any policy for the treasury key which signs the tspend is returned. A non-nil ticket hash may be used by a VSP to return per-ticket policies.
func (*Wallet) TSpendPolicyForTicket ¶ added in v2.0.1
TSpendPolicyForTicket returns all of the tspend policies set for a single ticket. It does not consider the global wallet setting.
func (*Wallet) TicketHashesForVotingAddress ¶
func (w *Wallet) TicketHashesForVotingAddress(ctx context.Context, votingAddr stdaddr.Address) ([]chainhash.Hash, error)
TicketHashesForVotingAddress returns the hashes of all tickets with voting rights delegated to votingAddr. This function does not return the hashes of pruned tickets.
func (*Wallet) TotalReceivedForAccounts ¶
func (w *Wallet) TotalReceivedForAccounts(ctx context.Context, minConf int32) ([]AccountTotalReceivedResult, error)
TotalReceivedForAccounts iterates through a wallet's transaction history, returning the total amount of decred received for all accounts.
func (*Wallet) TotalReceivedForAddr ¶
func (w *Wallet) TotalReceivedForAddr(ctx context.Context, addr stdaddr.Address, minConf int32) (dcrutil.Amount, error)
TotalReceivedForAddr iterates through a wallet's transaction history, returning the total amount of decred received for a single wallet address.
func (*Wallet) TransactionSummary ¶
func (w *Wallet) TransactionSummary(ctx context.Context, txHash *chainhash.Hash) (txSummary *TransactionSummary, confs int32, blockHash *chainhash.Hash, err error)
TransactionSummary returns details about a recorded transaction that is relevant to the wallet in some way.
func (*Wallet) TreasuryKeyPolicies ¶
func (w *Wallet) TreasuryKeyPolicies() []TreasuryKeyPolicy
TreasuryKeyPolicies returns all configured policies for treasury keys.
func (*Wallet) TreasuryKeyPolicy ¶
TreasuryKeyPolicy returns a vote policy for provided Pi key. If there is no policy this method returns TreasuryVoteInvalid. A non-nil ticket hash may be used by a VSP to return per-ticket policies.
func (*Wallet) TreasuryKeyPolicyForTicket ¶ added in v2.0.1
TreasuryKeyPolicyForTicket returns all of the treasury key policies set for a single ticket. It does not consider the global wallet setting.
func (*Wallet) TxConfirms ¶
TxConfirms returns the current number of block confirmations a transaction.
func (*Wallet) Unlock ¶
Unlock unlocks the wallet, allowing access to private keys and secret scripts. An unlocked wallet will be locked before returning with a Passphrase error if the passphrase is incorrect. If the wallet is currently unlocked without any timeout, timeout is ignored and read in a background goroutine to avoid blocking sends. If the wallet is locked and a non-nil timeout is provided, the wallet will be locked in the background after reading from the channel. If the wallet is already unlocked with a previous timeout, the new timeout replaces the prior.
func (*Wallet) UnlockAccount ¶
UnlockAccount decrypts a uniquely-encrypted account's private keys.
func (*Wallet) UnlockOutpoint ¶
UnlockOutpoint marks an outpoint as unlocked, that is, it may be used as an input for newly created transactions.
func (*Wallet) UnminedTransactions ¶
UnminedTransactions returns all unmined transactions from the wallet. Transactions are sorted in dependency order making it suitable to range them in order to broadcast at wallet startup. This method skips over any transactions that are recorded as unpublished.
func (*Wallet) UnspentOutput ¶
func (w *Wallet) UnspentOutput(ctx context.Context, op wire.OutPoint, includeMempool bool) (*udb.Credit, error)
UnspentOutput returns information about an unspent received transaction output. Returns error NotExist if the specified outpoint cannot be found or has been spent by a mined transaction. Mined transactions that are spent by a mempool transaction are not affected by this.
func (*Wallet) UnspentOutputs ¶
func (w *Wallet) UnspentOutputs(ctx context.Context, policy OutputSelectionPolicy) ([]*TransactionOutput, error)
UnspentOutputs fetches all unspent outputs from the wallet that match rules described in the passed policy.
func (*Wallet) UpdateVspTicketFeeToConfirmed ¶
func (*Wallet) UpdateVspTicketFeeToErrored ¶
func (*Wallet) UpdateVspTicketFeeToPaid ¶
func (w *Wallet) UpdateVspTicketFeeToPaid(ctx context.Context, ticketHash, feeHash *chainhash.Hash, host string, pubkey []byte) error
UpdateVspTicketFeeToPaid updates a vsp ticket fee status to paid. This is needed when finishing the fee payment on VSPs Process.
func (*Wallet) UpdateVspTicketFeeToStarted ¶
func (*Wallet) UpgradeToSLIP0044CoinType ¶
UpgradeToSLIP0044CoinType upgrades the wallet from the legacy BIP0044 coin type to one of the coin types assigned to Decred in SLIP0044. This should be called after a new wallet is created with a random (not imported) seed.
This function does not register addresses from the new account 0 with the wallet's network backend. This is intentional as it allows offline activities, such as wallet creation, to perform this upgrade.
func (*Wallet) VSPFeeHashForTicket ¶
func (w *Wallet) VSPFeeHashForTicket(ctx context.Context, ticketHash *chainhash.Hash) (chainhash.Hash, error)
VSPFeeHashForTicket returns the hash of the fee transaction associated with a VSP payment.
func (*Wallet) VSPHostForTicket ¶
VSPHostForTicket returns the current vsp host associated with VSP Ticket.
func (*Wallet) VSPTicketInfo ¶
VSPTicketInfo returns the various information for a given vsp ticket
func (*Wallet) ValidateHeaderChainDifficulties ¶
func (w *Wallet) ValidateHeaderChainDifficulties(ctx context.Context, chain []*BlockNode, idx int) ([]*BlockNode, error)
ValidateHeaderChainDifficulties validates the PoW and PoS difficulties of all blocks in chain[idx:]. The parent of chain[0] must be recorded as wallet main chain block. If a consensus violation is caught, a subslice of chain beginning with the invalid block is returned.
func (*Wallet) ValidatePreDCP0005CFilters ¶
ValidatePreDCP0005CFilters verifies that all stored cfilters prior to the DCP0005 activation height are the expected ones.
Verification is done by hashing all stored cfilter data and comparing the resulting hash to a known, hardcoded hash.
func (*Wallet) VoteBits ¶
func (w *Wallet) VoteBits() stake.VoteBits
VoteBits returns the vote bits that are described by the currently set agenda preferences. The previous block valid bit is always set, and must be unset elsewhere if the previous block's regular transactions should be voted against.
func (*Wallet) VoteOnOwnedTickets ¶
func (w *Wallet) VoteOnOwnedTickets(ctx context.Context, winningTicketHashes []*chainhash.Hash, blockHash *chainhash.Hash, blockHeight int32) error
VoteOnOwnedTickets creates and publishes vote transactions for all owned tickets in the winningTicketHashes slice if wallet voting is enabled. The vote is only valid when voting on the block described by the passed block hash and height. When a network backend is associated with the wallet, relevant commitment outputs are loaded as watched data.
func (*Wallet) VotingEnabled ¶
VotingEnabled returns whether the wallet is configured to vote tickets.
func (*Wallet) VotingXprivFromSeed ¶
VotingXprivFromSeed derives a voting xpriv from a byte seed.
func (*Wallet) WatchingOnly ¶
WatchingOnly returns whether the wallet only contains public keys.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
drivers
|
|
bdb
Package bdb registers the bdb driver at init time.
|
Package bdb registers the bdb driver at init time. |
internal
|
|
bdb
Package bdb implements an instance of walletdb that uses boltdb for the backing datastore.
|
Package bdb implements an instance of walletdb that uses boltdb for the backing datastore. |
Package txauthor provides transaction creation code for wallets.
|
Package txauthor provides transaction creation code for wallets. |
Package txrules provides functions that are help establish whether or not a transaction abides by non-consensus rules for things like the daemon and stake pool.
|
Package txrules provides functions that are help establish whether or not a transaction abides by non-consensus rules for things like the daemon and stake pool. |
Package walletdb provides a namespaced database interface for dcrwallet.
|
Package walletdb provides a namespaced database interface for dcrwallet. |