Documentation ¶
Overview ¶
Package wallet provides ... TODO: Flesh out this section
Overview
Index ¶
- Constants
- Variables
- func Create(db walletdb.DB, pubPass, privPass, seed []byte, params *chaincfg.Params) error
- func CreateWatchOnly(db walletdb.DB, extendedPubKey string, pubPass []byte, params *chaincfg.Params) error
- func CurrentAgendas(params *chaincfg.Params) (version uint32, agendas []chaincfg.ConsensusDeployment)
- func DisableLog()
- func EstimateTxSize(numInputs, numOutputs int, account uint32) int
- func FeeForSize(incr hcutil.Amount, sz int) hcutil.Amount
- func UnstableAPI(w *Wallet) unstableAPI
- func UseLogger(logger btclog.Logger)
- func VerifyMessage(msg string, addr hcutil.Address, sig []byte) (bool, error)
- type AccountBalance
- type AccountNotification
- type AccountNotificationsClient
- type AccountResult
- type AccountTotalReceivedResult
- type AccountsResult
- type AgendaChoice
- type Block
- type BlockIdentifier
- type BlockIdentity
- type BlockInfo
- type ConfirmationNotification
- type ConfirmationNotificationsClient
- type CreatedTx
- type CreditCategory
- type GetTicketsResult
- type GetTransactionsResult
- type MainTipChangedNotification
- type MainTipChangedNotificationsClient
- 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) TransactionNotifications() TransactionNotificationsClient
- type OutputInfo
- type OutputKind
- type OutputRedeemer
- type OutputSelectionAlgorithm
- type OutputSelectionPolicy
- type P2SHMultiSigOutput
- type RescanProgress
- 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 Wallet
- func (w *Wallet) AccountBranchAddressRange(account, branch, start, end uint32) ([]hcutil.Address, error)
- func (w *Wallet) AccountName(accountNumber uint32) (string, error)
- func (w *Wallet) AccountNumber(accountName string) (uint32, error)
- func (w *Wallet) AccountOfAddress(a hcutil.Address) (uint32, error)
- func (w *Wallet) AccountProperties(acct uint32) (*udb.AccountProperties, error)
- func (w *Wallet) Accounts() (*AccountsResult, error)
- func (w *Wallet) AddTicket(ticket *wire.MsgTx) error
- func (w *Wallet) AddressInfo(a hcutil.Address) (udb.ManagedAddress, error)
- func (w *Wallet) AgendaChoices() (choices []AgendaChoice, voteBits uint16, err error)
- func (w *Wallet) AssociateConsensusRPC(chainClient *chain.RPCClient)
- func (w *Wallet) BIP0044BranchNextIndexes(account uint32) (extChild, intChild uint32, err error)
- func (w *Wallet) BalanceToMaintain() hcutil.Amount
- func (w *Wallet) BlockConnectEnd(blockMeta *udb.BlockMeta)
- func (w *Wallet) BlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error)
- func (w *Wallet) BlockInMainChain(hash *chainhash.Hash) (haveBlock, invalidated bool, err error)
- func (w *Wallet) BlockInfo(blockID *BlockIdentifier) (*BlockInfo, error)
- func (w *Wallet) CalculateAccountBalance(account uint32, confirms int32) (udb.Balances, error)
- func (w *Wallet) CalculateAccountBalances(confirms int32) (map[uint32]*udb.Balances, error)
- func (w *Wallet) ChainClient() *hcrpcclient.Client
- func (w *Wallet) ChainParams() *chaincfg.Params
- func (w *Wallet) ChangePrivatePassphrase(old, new []byte) error
- func (w *Wallet) ChangePublicPassphrase(old, new []byte) error
- func (w *Wallet) CommittedTickets(tickets []*chainhash.Hash) ([]*chainhash.Hash, []hcutil.Address, error)
- func (w *Wallet) Consolidate(inputs int, account uint32, address hcutil.Address) (*chainhash.Hash, error)
- func (w *Wallet) CreateMultisigTx(account uint32, amount hcutil.Amount, pubkeys []hcutil.Address, nrequired int8, ...) (*CreatedTx, hcutil.Address, []byte, error)
- func (w *Wallet) CreateSSGenTx(ticketHash chainhash.Hash, blockHash chainhash.Hash, height int64, ...) (*CreatedTx, error)
- func (w *Wallet) CreateSSRtx(ticketHash chainhash.Hash) (*CreatedTx, error)
- func (w *Wallet) CreateSStxTx(pair map[string]hcutil.Amount, usedInputs []udb.Credit, ...) (*CreatedTx, error)
- func (w *Wallet) CreateSignature(tx *wire.MsgTx, idx uint32, addr hcutil.Address, hashType txscript.SigHashType, ...) (sig, pubkey []byte, err error)
- func (w *Wallet) CreateSimpleTx(account uint32, outputs []*wire.TxOut, minconf int32, changeAddr string, ...) (*txauthor.AuthoredTx, error)
- func (w *Wallet) CurrentAddress(account uint32) (hcutil.Address, error)
- func (w *Wallet) DiscoverActiveAddresses(chainClient *hcrpcclient.Client, discoverAccts bool) error
- func (w *Wallet) DumpWIFPrivateKey(addr hcutil.Address) (string, error)
- func (w *Wallet) EnableOmni() bool
- func (w *Wallet) ExistsAddressOnChain(address hcutil.Address) (bool, error)
- func (w *Wallet) ExtendWatchedAddresses(account, branch, child uint32) error
- func (w *Wallet) FetchAddressesByAccount(account uint32) ([]string, error)
- func (w *Wallet) FetchAllRedeemScripts() ([][]byte, error)
- func (w *Wallet) FetchHeaders(chainClient *hcrpcclient.Client) (count int, rescanFrom chainhash.Hash, rescanFromHeight int32, ...)
- func (w *Wallet) FetchImortedAccountAddress() ([]string, error)
- func (w *Wallet) FetchP2SHMultiSigOutput(outPoint *wire.OutPoint) (*P2SHMultiSigOutput, error)
- func (w *Wallet) FindEligibleOutputs(account uint32, minconf int32, currentHeight int32) ([]udb.Credit, error)
- func (w *Wallet) FindactiveAddressesForBliss(account, branch, start, count uint32) ([]hcutil.Address, error)
- func (w *Wallet) FirstAddr(account uint32) (*hcutil.AddressPubKeyHash, error)
- func (w *Wallet) GenerateVoteTx(blockHash *chainhash.Hash, height int32, ticketHash *chainhash.Hash, ...) (*wire.MsgTx, error)
- func (w *Wallet) GetTickets(ctx context.Context, chainClient *hcrpcclient.Client, ...) (*GetTicketsResult, error)
- func (w *Wallet) GetTransactions(f func(*Block) (bool, error), startBlock, endBlock *BlockIdentifier) error
- func (w *Wallet) GetTxDetails(op *wire.OutPoint) (*udb.TxDetails, error)
- func (w *Wallet) GetWalletSyncHeight() (uint32, *chainhash.Hash, error)
- func (w *Wallet) HaveAddress(a hcutil.Address) (bool, error)
- func (w *Wallet) ImportP2SHRedeemScript(script []byte) (*hcutil.AddressScriptHash, error)
- func (w *Wallet) ImportPrivateKey(wif *hcutil.WIF) (string, error)
- func (w *Wallet) ImportScript(rs []byte) error
- func (w *Wallet) IsReleventTransaction(dbtx walletdb.ReadWriteTx, rec *udb.TxRecord, blockMeta *udb.BlockMeta) (bool, error)
- func (w *Wallet) IsScanning() bool
- func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]hcjson.ListTransactionsResult, error)
- func (w *Wallet) ListAllTransactions() ([]hcjson.ListTransactionsResult, error)
- func (w *Wallet) ListSinceBlock(start, end, syncHeight int32) ([]hcjson.ListTransactionsResult, error)
- func (w *Wallet) ListTransactionDetails(txHash *chainhash.Hash) ([]hcjson.ListTransactionsResult, error)
- func (w *Wallet) ListTransactions(from, count int) ([]hcjson.ListTransactionsResult, error)
- func (w *Wallet) ListUnspent(minconf, maxconf int32, addresses map[string]struct{}) ([]*hcjson.ListUnspentResult, error)
- func (w *Wallet) LiveTicketHashes(chainClient *hcrpcclient.Client, includeImmature bool) ([]chainhash.Hash, error)
- func (w *Wallet) LoadActiveDataFilters(chainClient *hcrpcclient.Client) error
- func (w *Wallet) Lock()
- func (w *Wallet) LockOutpoint(op wire.OutPoint)
- func (w *Wallet) Locked() bool
- func (w *Wallet) LockedOutpoint(op wire.OutPoint) bool
- func (w *Wallet) LockedOutpoints() []hcjson.TransactionInput
- func (w *Wallet) MainChainTip() (hash chainhash.Hash, height int32)
- func (w *Wallet) MakeMultiSigScript(addrs []hcutil.Address, nRequired int) ([]byte, error)
- func (w *Wallet) MakeNulldataOutput(payLoad []byte) (*wire.TxOut, error)
- func (w *Wallet) MasterPubKey(account uint32) (string, error)
- func (w *Wallet) NeedsAccountsSync() (bool, error)
- func (w *Wallet) NewChangeAddress(account uint32) (hcutil.Address, error)
- func (w *Wallet) NewExternalAddress(account uint32, callOpts ...NextAddressCallOption) (hcutil.Address, error)
- func (w *Wallet) NewInternalAddress(account uint32, callOpts ...NextAddressCallOption) (hcutil.Address, error)
- func (w *Wallet) NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb hcutil.Amount, account uint32, ...) (*txauthor.AuthoredTx, error)
- func (w *Wallet) NextAccount(name string, actype uint8) (uint32, error)
- func (w *Wallet) OmniClear() error
- func (w *Wallet) OutputInfo(op *wire.OutPoint) (OutputInfo, error)
- func (w *Wallet) PoolAddress() hcutil.Address
- func (w *Wallet) PoolFees() float64
- func (w *Wallet) ProcessOminiTransaction(rec *udb.TxRecord, blockMeta *udb.BlockMeta) error
- func (w *Wallet) PubKeyForAddress(a hcutil.Address) (chainec.PublicKey, error)
- func (w *Wallet) PublishTransaction(tx *wire.MsgTx, serializedTx []byte, client *hcrpcclient.Client) (*chainhash.Hash, error)
- func (w *Wallet) PurchaseTickets(minBalance, spendLimit hcutil.Amount, minConf int32, ticketAddr hcutil.Address, ...) ([]*chainhash.Hash, error)
- func (w *Wallet) ReconnectStart()
- func (w *Wallet) RedeemScriptCopy(addr hcutil.Address) ([]byte, error)
- func (w *Wallet) RelayFee() hcutil.Amount
- func (w *Wallet) RenameAccount(account uint32, newName string) error
- func (w *Wallet) Rescan(chainClient *hcrpcclient.Client, startHash *chainhash.Hash) <-chan error
- func (w *Wallet) RescanFromHeight(chainClient *hcrpcclient.Client, startHeight int32) <-chan error
- func (w *Wallet) RescanPoint() (*chainhash.Hash, error)
- func (w *Wallet) RescanProgressFromHeight(chainClient *hcrpcclient.Client, startHeight int32, p chan<- RescanProgress, ...)
- func (w *Wallet) ResetLockedOutpoints()
- func (w *Wallet) RevokeTickets(chainClient *hcrpcclient.Client) error
- func (w *Wallet) RollBack(dbtx walletdb.ReadWriteTx, sideChainForkHeight int32, hashs []chainhash.Hash) error
- func (w *Wallet) RollBackOminiTransaction(height uint32, hashs []chainhash.Hash) error
- func (w *Wallet) SelectInputs(targetAmount hcutil.Amount, policy OutputSelectionPolicy) (total hcutil.Amount, inputs []*wire.TxIn, prevScripts [][]byte, err error)
- func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32, minconf int32, changeAddr string, ...) (*chainhash.Hash, error)
- func (w *Wallet) SetAgendaChoices(choices ...AgendaChoice) (voteBits uint16, err error)
- func (w *Wallet) SetBalanceToMaintain(balance hcutil.Amount)
- func (w *Wallet) SetInitiallyUnlocked(set bool)
- func (w *Wallet) SetRelayFee(relayFee hcutil.Amount)
- func (w *Wallet) SetTicketFeeIncrement(fee hcutil.Amount)
- func (w *Wallet) SetTicketPurchasingEnabled(flag bool)
- func (w *Wallet) ShuttingDown() bool
- func (w *Wallet) SignMessage(msg string, addr hcutil.Address) (sig []byte, err error)
- func (w *Wallet) SignTransaction(tx *wire.MsgTx, hashType txscript.SigHashType, ...) ([]SignatureError, error)
- func (w *Wallet) SortedActivePaymentAddresses() ([]string, error)
- func (w *Wallet) StakeDifficulty() (hcutil.Amount, error)
- func (w *Wallet) StakeInfo(chainClient *hcrpcclient.Client) (*StakeInfoData, error)
- func (w *Wallet) StakePoolUserInfo(userAddress hcutil.Address) (*udb.StakePoolUser, error)
- func (w *Wallet) Start()
- func (w *Wallet) Stop()
- func (w *Wallet) SynchronizeRPC(chainClient *chain.RPCClient)
- func (w *Wallet) SynchronizingToNetwork() bool
- func (w *Wallet) TicketAddress() hcutil.Address
- func (w *Wallet) TicketFeeIncrement() hcutil.Amount
- func (w *Wallet) TicketHashesForVotingAddress(votingAddr hcutil.Address) ([]chainhash.Hash, error)
- func (w *Wallet) TicketPurchasingEnabled() bool
- func (w *Wallet) TotalReceivedForAccounts(minConf int32) ([]AccountTotalReceivedResult, error)
- func (w *Wallet) TotalReceivedForAddr(addr hcutil.Address, minConf int32) (hcutil.Amount, error)
- func (w *Wallet) TransactionSummary(txHash *chainhash.Hash) (*TransactionSummary, error)
- func (w *Wallet) Unlock(passphrase []byte, lock <-chan time.Time) error
- func (w *Wallet) UnlockOutpoint(op wire.OutPoint)
- func (w *Wallet) UnspentOutputs(policy OutputSelectionPolicy) ([]*TransactionOutput, error)
- func (w *Wallet) VoteBits() stake.VoteBits
- func (w *Wallet) VotingEnabled() bool
- func (w *Wallet) WaitForShutdown()
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 availble output. This is useful for sweeping. OutputSelectionAlgorithmAll )
const DefaultGapLimit = 20
DefaultGapLimit is the default unused address gap limit defined by BIP0044.
const EstMaxTicketFeeAmount = 0.1 * 1e8
EstMaxTicketFeeAmount is the estimated max ticket fee to be used for size calculation for eligible utxos for ticket purchasing.
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" )
const MaxAccountForTestNet = 16
Variables ¶
var ErrBlockchainReorganizing = errors.New("blockchain is currently " +
"reorganizing")
ErrBlockchainReorganizing indicates that the blockchain is currently reorganizing.
var ErrNegativeFee = errors.New("fee is negative")
ErrNegativeFee represents an error where a fee is erroneously negative.
var ErrNoOutsToConsolidate = errors.New("no outputs to consolidate")
ErrNoOutsToConsolidate indicates that there were no outputs available to compress.
var ErrNonPositiveAmount = errors.New("amount is not positive")
ErrNonPositiveAmount represents an error where an amount is not positive (either negative, or zero).
var ErrSStxNotEnoughFunds = errors.New("not enough to purchase sstx")
ErrSStxNotEnoughFunds indicates that not enough funds were available in the wallet to purchase a ticket.
var ErrSStxPriceExceedsSpendLimit = errors.New("ticket price exceeds spend limit")
ErrSStxPriceExceedsSpendLimit indicates that the current ticket price exceeds the specified spend maximum spend limit.
var ErrTicketPriceNotSet = errors.New("ticket price not yet established")
ErrTicketPriceNotSet indicates that the wallet was recently connected and that the ticket price has not yet been set.
var ErrUnsupportedTransactionType = errors.New("Only P2PKH transactions " +
"are supported")
ErrUnsupportedTransactionType represents an error where a transaction cannot be signed as the API only supports spending P2PKH outputs.
var ( // SimulationPassphrase is the password for a wallet created for simnet // with --createtemp. SimulationPassphrase = []byte("password") )
Functions ¶
func Create ¶
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(db walletdb.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 DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func EstimateTxSize ¶
EstimateTxSize is the exported version of estimateTxSize which provides an estimate of the tx size based on the number of inputs, outputs, and some assumed overhead.
func FeeForSize ¶
FeeForSize is the exported version of feeForSize which returns a fee based on the provided feeIncrement and provided size.
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 transation (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.
Types ¶
type AccountBalance ¶
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 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 AccountResult ¶
type AccountResult struct { udb.AccountProperties TotalBalance hcutil.Amount }
AccountResult is a single account result for the AccountsResult type.
type AccountTotalReceivedResult ¶
type AccountTotalReceivedResult struct { AccountNumber uint32 AccountName string TotalReceived hcutil.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 AgendaChoice ¶
AgendaChoice describes a user's choice for a consensus deployment agenda.
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 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 hegiht 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 hcutil.Address ChangeIndex int // negative if no change Fee hcutil.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 RecvCategory ¶
func RecvCategory(details *udb.TxDetails, syncHeight int32, chainParams *chaincfg.Params) CreditCategory
RecvCategory returns the category of received credit outputs from a transaction record. The passed block chain height is used to distinguish immature from mature coinbase outputs.
TODO: This is intended for use by the RPC server and should be moved out of this package at a later time.
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 GetTicketsResult ¶
type GetTicketsResult struct {
Tickets []*TicketSummary
}
GetTicketsResult response struct for gettickets rpc request
type GetTransactionsResult ¶
type GetTransactionsResult struct { MinedTransactions []Block UnminedTransactions []TransactionSummary }
GetTransactionsResult is the result of the wallet's GetTransactions method. See GetTransactions for more details.
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 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 apperrors.ErrExceedsGapLimit 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) 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 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 hcutil.Amount ContainingBlock BlockIdentity P2SHAddress *hcutil.AddressScriptHash 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 RescanProgress ¶
RescanProgress records the height the rescan has completed through and any errors during processing of the rescan.
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 PoolSize uint32 AllMempoolTix uint32 OwnMempoolTix uint32 Immature uint32 Live uint32 Voted uint32 Missed uint32 Revoked uint32 Expired uint32 TotalSubsidy hcutil.Amount }
StakeInfoData is a struct containing the data that would be returned from a StakeInfo request to the wallet.
type TicketStatus ¶
type TicketStatus int8
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 // TicketStatusUnmined any not yet mined ticket. TicketStatusUnmined // TicketStatusImmature any so to be live ticket. TicketStatusImmature // TicketStatusLive any currently live ticket. TicketStatusLive // TicketStatusVoted any ticket that was seen to have voted. TicketStatusVoted // TicketStatusRevoked any ticket that has been previously revoked. TicketStatusRevoked // TicketStatusMissed any ticket that has yet to be revoked, and was missed. TicketStatusMissed // TicketStatusExpired any ticket that has yet to be revoked, and was expired. TicketStatusExpired )
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 []*chainhash.Hash 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 hcutil.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 hcutil.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 hcutil.Amount Address hcutil.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 ouput, 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 Wallet ¶
type Wallet struct { Manager *udb.Manager TxStore *udb.Store StakeMgr *udb.StakeStore DisallowFree bool AllowHighFees bool NtfnServer *NotificationServer NtfnServerMutex sync.Mutex //Dll MsgReceiver chan string // 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 ¶
func Open(db walletdb.DB, pubPass []byte, privPass []byte, votingEnabled bool, addressReuse bool, ticketAddress, subsidyAddress hcutil.Address, poolAddress hcutil.Address, poolFees float64, ticketFee float64, gapLimit int, stakePoolColdExtKey string, allowHighFees bool, relayFee float64, enableOmni bool, params *chaincfg.Params) (*Wallet, error)
Open loads an already-created wallet from the passed database and namespaces.
func (*Wallet) AccountBranchAddressRange ¶
func (w *Wallet) AccountBranchAddressRange(account, branch, start, end uint32) ([]hcutil.Address, error)
AccountBranchAddressRange returns all addresses in the range [start, end) belonging to the BIP0044 account and address branch.
func (*Wallet) AccountName ¶
AccountName returns the name of an account.
func (*Wallet) AccountNumber ¶
AccountNumber returns the account number for an account name.
func (*Wallet) AccountOfAddress ¶
AccountOfAddress finds the account that an address is associated with.
func (*Wallet) AccountProperties ¶
func (w *Wallet) AccountProperties(acct uint32) (*udb.AccountProperties, error)
AccountProperties returns the properties of an account, including address indexes and name. It first fetches the desynced information from the address manager, then updates the indexes based on the address pools.
func (*Wallet) Accounts ¶
func (w *Wallet) Accounts() (*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) AddTicket ¶
AddTicket adds a ticket transaction to the stake manager. It is not added to the transaction manager because it is unknown where the transaction belongs on the blockchain. It will be used to create votes.
func (*Wallet) AddressInfo ¶
AddressInfo returns detailed information regarding a wallet address.
func (*Wallet) AgendaChoices ¶
func (w *Wallet) AgendaChoices() (choices []AgendaChoice, voteBits uint16, err error)
AgendaChoices returns the choice IDs for every agenda of the supported stake version. Abstains are included.
func (*Wallet) AssociateConsensusRPC ¶
AssociateConsensusRPC associates the wallet with the consensus JSON-RPC server and begins handling all notifications in a background goroutine. Any previously associated client, if it is a different instance than the passed client, is stopped.
func (*Wallet) BIP0044BranchNextIndexes ¶
BIP0044BranchNextIndexes returns the next external and internal branch child indexes of an account.
func (*Wallet) BalanceToMaintain ¶
BalanceToMaintain is used to get the current balancetomaintain for the wallet.
func (*Wallet) BlockConnectEnd ¶
BlockConnectEnd used to clear some expire data after block connected
func (*Wallet) BlockHeader ¶
BlockHeader returns the block header for a block by it's identifying hash, if it is recorded by the wallet.
func (*Wallet) BlockInMainChain ¶
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) BlockInfo ¶
func (w *Wallet) BlockInfo(blockID *BlockIdentifier) (*BlockInfo, error)
BlockInfo returns info regarding a block recorded by the wallet.
func (*Wallet) CalculateAccountBalance ¶
CalculateAccountBalance sums the amounts of all unspent transaction outputs to the given account of a wallet and returns the balance.
func (*Wallet) CalculateAccountBalances ¶
CalculateAccountBalances calculates the values for the wtxmgr struct Balance, which includes the total balance, the spendable balance, and the balance which has yet to mature.
func (*Wallet) ChainClient ¶
func (w *Wallet) ChainClient() *hcrpcclient.Client
ChainClient returns the optional consensus RPC client associated with the wallet.
This function is unstable and will be removed once sync logic is moved out of the wallet.
func (*Wallet) ChainParams ¶
ChainParams returns the network parameters for the blockchain the wallet belongs to.
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) CommittedTickets ¶
func (w *Wallet) CommittedTickets(tickets []*chainhash.Hash) ([]*chainhash.Hash, []hcutil.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(inputs int, account uint32, address hcutil.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(account uint32, amount hcutil.Amount, pubkeys []hcutil.Address, nrequired int8, minconf int32) (*CreatedTx, hcutil.Address, []byte, error)
CreateMultisigTx receives a request from the RPC and ships it to txCreator to generate a new multisigtx.
func (*Wallet) CreateSSGenTx ¶
func (w *Wallet) CreateSSGenTx(ticketHash chainhash.Hash, blockHash chainhash.Hash, height int64, voteBits uint16) (*CreatedTx, error)
CreateSSGenTx receives a request from the RPC and ships it to txCreator to generate a new SSGen.
func (*Wallet) CreateSSRtx ¶
CreateSSRtx receives a request from the RPC and ships it to txCreator to generate a new SSRtx.
func (*Wallet) CreateSStxTx ¶
func (w *Wallet) CreateSStxTx(pair map[string]hcutil.Amount, usedInputs []udb.Credit, inputs []hcjson.SStxInput, couts []hcjson.SStxCommitOut, minconf int32) (*CreatedTx, error)
CreateSStxTx receives a request from the RPC and ships it to txCreator to generate a new SStx.
func (*Wallet) CreateSignature ¶
func (w *Wallet) CreateSignature(tx *wire.MsgTx, idx uint32, addr hcutil.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) CreateSimpleTx ¶
func (w *Wallet) CreateSimpleTx(account uint32, outputs []*wire.TxOut, minconf int32, changeAddr string, fromAddress string) (*txauthor.AuthoredTx, error)
CreateSimpleTx creates a new signed transaction spending unspent P2PKH outputs with at laest minconf confirmations spending to any number of address/amount pairs. Change and an appropriate transaction fee are automatically included, if necessary. All transaction creation through this function is serialized to prevent the creation of many transactions which spend the same outputs.
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 hcd mempool), the next chained address is returned.
func (*Wallet) DiscoverActiveAddresses ¶
func (w *Wallet) DiscoverActiveAddresses(chainClient *hcrpcclient.Client, discoverAccts bool) error
DiscoverActiveAddresses accesses the consensus RPC server to discover all the addresses that have been used by an HD keychain stemming from this wallet. 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.
A transaction filter (re)load and rescan should be performed after discovery.
func (*Wallet) DumpWIFPrivateKey ¶
DumpWIFPrivateKey returns the WIF encoded private key for a single wallet address.
func (*Wallet) ExistsAddressOnChain ¶
ExistsAddressOnChain is the exported version of existsAddressOnChain that is safe for concurrent access.
func (*Wallet) ExtendWatchedAddresses ¶
ExtendWatchedAddresses derives and watches additional addresses for an account branch they have not yet been derived. This does not modify the next generated address for the branch.
func (*Wallet) FetchAddressesByAccount ¶
func (*Wallet) FetchAllRedeemScripts ¶
FetchAllRedeemScripts returns all P2SH redeem scripts saved by the wallet.
func (*Wallet) FetchHeaders ¶
func (w *Wallet) FetchHeaders(chainClient *hcrpcclient.Client) (count int, rescanFrom chainhash.Hash, rescanFromHeight int32, mainChainTipBlockHash chainhash.Hash, mainChainTipBlockHeight int32, err error)
FetchHeaders fetches headers from the consensus RPC server and updates the main chain tip with the latest block. The number of new headers fetched is returned, along with the hash of the first previously-unseen block hash now in the main chain. This is the block a rescan should begin at (inclusive), and is only relevant when the number of fetched headers is not zero.
func (*Wallet) FetchImortedAccountAddress ¶
fetch imported account address
func (*Wallet) FetchP2SHMultiSigOutput ¶
func (w *Wallet) FetchP2SHMultiSigOutput(outPoint *wire.OutPoint) (*P2SHMultiSigOutput, error)
FetchP2SHMultiSigOutput fetches information regarding a wallet's P2SH multi-signature output.
func (*Wallet) FindEligibleOutputs ¶
func (w *Wallet) FindEligibleOutputs(account uint32, minconf int32, currentHeight int32) ([]udb.Credit, error)
FindEligibleOutputs is the exported version of findEligibleOutputs (which tried to find unspent outputs that pass a maturity check).
func (*Wallet) FindactiveAddressesForBliss ¶
func (*Wallet) FirstAddr ¶
func (w *Wallet) FirstAddr(account uint32) (*hcutil.AddressPubKeyHash, error)
get wallet first addr for reuse addr
func (*Wallet) GenerateVoteTx ¶
func (w *Wallet) GenerateVoteTx(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.
func (*Wallet) GetTickets ¶
func (w *Wallet) GetTickets(ctx context.Context, chainClient *hcrpcclient.Client, startBlock, endBlock *BlockIdentifier) (*GetTicketsResult, error)
GetTickets returns a list of TicketSummarys that are 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.
func (*Wallet) GetTransactions ¶
func (w *Wallet) GetTransactions(f func(*Block) (bool, error), startBlock, endBlock *BlockIdentifier) error
GetTransactions returns transaction results between a starting and ending block. Blocks in the block range may be specified by either a height or a hash.
Because this is a possibly lenghtly operation, a cancel channel is provided to cancel the task. If this channel unblocks, the results created thus far will be returned.
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.
func (*Wallet) GetTxDetails ¶
OutputInfo queries the wallet for additional transaction output info regarding an outpoint.
func (*Wallet) GetWalletSyncHeight ¶
func (*Wallet) HaveAddress ¶
HaveAddress returns whether the wallet is the owner of the address a.
func (*Wallet) ImportP2SHRedeemScript ¶
func (w *Wallet) ImportP2SHRedeemScript(script []byte) (*hcutil.AddressScriptHash, error)
ImportP2SHRedeemScript adds a P2SH redeem script to the wallet.
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) IsReleventTransaction ¶
func (*Wallet) IsScanning ¶
func (*Wallet) ListAddressTransactions ¶
func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]hcjson.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 ¶
func (w *Wallet) ListAllTransactions() ([]hcjson.ListTransactionsResult, error)
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(start, end, syncHeight int32) ([]hcjson.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(txHash *chainhash.Hash) ([]hcjson.ListTransactionsResult, error)
ListTransactionDetails returns the listtransaction results for a single transaction.
func (*Wallet) ListTransactions ¶
func (w *Wallet) ListTransactions(from, count int) ([]hcjson.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(minconf, maxconf int32, addresses map[string]struct{}) ([]*hcjson.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(chainClient *hcrpcclient.Client, 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(chainClient *hcrpcclient.Client) error
LoadActiveDataFilters loads the consensus RPC server's websocket client transaction filter with all active addresses and unspent outpoints for this wallet.
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() []hcjson.TransactionInput
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) MakeMultiSigScript ¶
MakeMultiSigScript creates a multi-signature script that can be redeemed with nRequired signatures of the passed keys and addresses. If the address is a P2PKH address, the associated pubkey is looked up by the wallet if possible, otherwise an error is returned for a missing pubkey.
This function only works with secp256k1 pubkeys and P2PKH addresses derived from them.
func (*Wallet) MakeNulldataOutput ¶
func (*Wallet) MasterPubKey ¶
MasterPubKey returns the BIP0044 master public key for the passed account.
TODO: This should not be returning the key as a string.
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) 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(account uint32, callOpts ...NextAddressCallOption) (hcutil.Address, error)
NewExternalAddress returns an external address.
func (*Wallet) NewInternalAddress ¶
func (w *Wallet) NewInternalAddress(account uint32, callOpts ...NextAddressCallOption) (hcutil.Address, error)
NewInternalAddress returns an internal address.
func (*Wallet) NewUnsignedTransaction ¶
func (w *Wallet) NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb hcutil.Amount, account uint32, minConf int32, algo OutputSelectionAlgorithm, changeSource txauthor.ChangeSource) (*txauthor.AuthoredTx, error)
NewUnsignedTransaction constructs an unsigned transaction using unspent account outputs.
The changeSource parameter is optional and can be nil. When nil, and if a change output should be added, an internal change address is created for the account.
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) OutputInfo ¶
func (w *Wallet) OutputInfo(op *wire.OutPoint) (OutputInfo, error)
OutputInfo queries the wallet for additional transaction output info regarding an outpoint.
func (*Wallet) PoolAddress ¶
PoolAddress gets the pool address for the wallet to give ticket fees to.
func (*Wallet) ProcessOminiTransaction ¶
func (*Wallet) PubKeyForAddress ¶
PubKeyForAddress looks up the associated public key for a P2PKH address.
func (*Wallet) PublishTransaction ¶
func (w *Wallet) PublishTransaction(tx *wire.MsgTx, serializedTx []byte, client *hcrpcclient.Client) (*chainhash.Hash, error)
PublishTransaction saves (if relevant) and sends the transaction to the consensus RPC server so it can be propigated to other nodes and eventually mined. If the send fails, the transaction is not added to the wallet.
func (*Wallet) PurchaseTickets ¶
func (w *Wallet) PurchaseTickets(minBalance, spendLimit hcutil.Amount, minConf int32, ticketAddr hcutil.Address, account uint32, numTickets int, poolAddress hcutil.Address, poolFees float64, expiry int32, txFee hcutil.Amount, ticketFee hcutil.Amount) ([]*chainhash.Hash, error)
PurchaseTickets receives a request from the RPC and ships it to txCreator to purchase a new ticket. It returns a slice of the hashes of the purchased tickets.
func (*Wallet) ReconnectStart ¶
func (w *Wallet) ReconnectStart()
func (*Wallet) RedeemScriptCopy ¶
RedeemScriptCopy returns a copy of a redeem script to redeem outputs payed to a P2SH address.
func (*Wallet) RelayFee ¶
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.
An error channel is returned for consumers of this API, but it is not required to be read. If the error can not be immediately written to the returned channel, the error will be logged and the channel will be closed.
func (*Wallet) RescanFromHeight ¶
func (w *Wallet) RescanFromHeight(chainClient *hcrpcclient.Client, startHeight int32) <-chan error
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(chainClient *hcrpcclient.Client, startHeight int32, p chan<- RescanProgress, cancel <-chan struct{})
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) ResetLockedOutpoints ¶
func (w *Wallet) ResetLockedOutpoints()
ResetLockedOutpoints resets the set of locked outpoints so all may be used as inputs for new transactions.
func (*Wallet) RevokeTickets ¶
func (w *Wallet) RevokeTickets(chainClient *hcrpcclient.Client) error
RevokeTickets creates and sends revocation transactions for any unrevoked missed and expired tickets. The wallet must be unlocked to generate any revocations.
func (*Wallet) RollBackOminiTransaction ¶
for temp test
func (*Wallet) SelectInputs ¶
func (w *Wallet) SelectInputs(targetAmount hcutil.Amount, policy OutputSelectionPolicy) (total hcutil.Amount, inputs []*wire.TxIn, prevScripts [][]byte, err error)
SelectInputs selects transaction inputs to redeem unspent outputs stored in the wallet. It returns the total input amount referenced by the previous transaction outputs, a slice of transaction inputs referencing these outputs, and a slice of previous output scripts from each previous output referenced by the corresponding input.
func (*Wallet) SendOutputs ¶
func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32, minconf int32, changeAddr string, fromAddress string) (*chainhash.Hash, error)
SendOutputs creates and sends payment transactions. It returns the transaction hash upon success
func (*Wallet) SetAgendaChoices ¶
func (w *Wallet) SetAgendaChoices(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.
func (*Wallet) SetBalanceToMaintain ¶
SetBalanceToMaintain is used to set the current w.balancetomaintain for the wallet.
func (*Wallet) SetInitiallyUnlocked ¶
SetInitiallyUnlocked sets whether or not the wallet is initially unlocked. This allows the user to resync accounts, dictating some of the start up syncing behaviour. It should only be called before the wallet RPC servers are accessible. It is not safe for concurrent access.
func (*Wallet) SetRelayFee ¶
SetRelayFee sets a new minimum relay fee (per kB of serialized transaction) used when constructing transactions.
func (*Wallet) SetTicketFeeIncrement ¶
SetTicketFeeIncrement is used to set the current w.ticketFeeIncrement for the wallet.
func (*Wallet) SetTicketPurchasingEnabled ¶
SetTicketPurchasingEnabled is used to enable or disable ticket purchasing in the wallet.
func (*Wallet) ShuttingDown ¶
ShuttingDown returns whether the wallet is currently in the process of shutting down or not.
func (*Wallet) SignMessage ¶
SignMessage returns the signature of a signed message using an address' associated private key.
func (*Wallet) SignTransaction ¶
func (w *Wallet) SignTransaction(tx *wire.MsgTx, hashType txscript.SigHashType, additionalPrevScripts map[wire.OutPoint][]byte, additionalKeysByAddress map[string]*hcutil.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) StakeDifficulty ¶
StakeDifficulty is used to get the current stake difficulty from the daemon.
func (*Wallet) StakeInfo ¶
func (w *Wallet) StakeInfo(chainClient *hcrpcclient.Client) (*StakeInfoData, error)
StakeInfo collects and returns staking statistics for this wallet to the end user. This includes:
PoolSize uint32 Number of live tickets in the ticket pool AllMempoolTix uint32 Number of tickets currently in the mempool OwnMempoolTix uint32 Number of tickets in mempool that are from this wallet Immature uint32 Number of tickets from this wallet that are in the blockchain but which are not yet mature Live uint32 Number of mature, active tickets owned by this wallet Voted uint32 Number of votes cast by this wallet Missed uint32 Number of missed tickets (failing to vote) Expired uint32 Number of expired tickets Revoked uint32 Number of missed tickets that were missed and then revoked TotalSubsidy int64 Total amount of coins earned by stake mining
Getting this information is extremely costly as in involves a massive number of chain server calls.
func (*Wallet) StakePoolUserInfo ¶
StakePoolUserInfo returns the stake pool user information for a user identified by their P2SH voting address.
func (*Wallet) Start ¶
func (w *Wallet) Start()
Start starts the goroutines necessary to manage a wallet.
func (*Wallet) SynchronizeRPC ¶
SynchronizeRPC associates the wallet with the consensus RPC client, synchronizes the wallet with the latest changes to the blockchain, and continuously updates the wallet through RPC notifications.
This method is unstable and will be removed when all syncing logic is moved outside of the wallet package.
func (*Wallet) SynchronizingToNetwork ¶
SynchronizingToNetwork returns whether the wallet is currently synchronizing with the Bitcoin network.
func (*Wallet) TicketAddress ¶
TicketAddress gets the ticket address for the wallet to give the ticket voting rights to.
func (*Wallet) TicketFeeIncrement ¶
TicketFeeIncrement is used to get the current feeIncrement for the wallet.
func (*Wallet) TicketHashesForVotingAddress ¶
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) TicketPurchasingEnabled ¶
TicketPurchasingEnabled returns whether the wallet is configured to purchase tickets.
func (*Wallet) TotalReceivedForAccounts ¶
func (w *Wallet) TotalReceivedForAccounts(minConf int32) ([]AccountTotalReceivedResult, error)
TotalReceivedForAccounts iterates through a wallet's transaction history, returning the total amount of hcd received for all accounts.
func (*Wallet) TotalReceivedForAddr ¶
TotalReceivedForAddr iterates through a wallet's transaction history, returning the total amount of hcd received for a single wallet address.
func (*Wallet) TransactionSummary ¶
func (w *Wallet) TransactionSummary(txHash *chainhash.Hash) (*TransactionSummary, error)
TransactionSummary returns details about a recorded transaction that is relevant to the wallet in some way.
func (*Wallet) Unlock ¶
Unlock unlocks the wallet's address manager and relocks it after timeout has expired. If the wallet is already unlocked and the new passphrase is correct, the current timeout is replaced with the new one. The wallet will be locked if the passphrase is incorrect or any other error occurs during the unlock.
func (*Wallet) UnlockOutpoint ¶
UnlockOutpoint marks an outpoint as unlocked, that is, it may be used as an input for newly created transactions.
func (*Wallet) UnspentOutputs ¶
func (w *Wallet) UnspentOutputs(policy OutputSelectionPolicy) ([]*TransactionOutput, error)
UnspentOutputs fetches all unspent outputs from the wallet that match rules described in the passed policy.
func (*Wallet) 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) VotingEnabled ¶
VotingEnabled returns whether the wallet is configured to vote tickets.
func (*Wallet) WaitForShutdown ¶
func (w *Wallet) WaitForShutdown()
WaitForShutdown blocks until all wallet goroutines have finished executing.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
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. |