Documentation ¶
Index ¶
- Constants
- func InitGlobalLogging(externalLogDir string, errorLogger assetlog.ParentLogger) error
- func ParseChainParams(network asset.Network) (*chaincfg.Params, error)
- func WalletExistsAt(dataDir string) (bool, error)
- type Input
- type Output
- type Wallet
- func (w *Wallet) AccountPubkey(ctx context.Context, acct string) (string, error)
- func (w *Wallet) AddressesByAccount(ctx context.Context, account string) ([]string, error)
- func (w *Wallet) CloseWallet() error
- func (w *Wallet) CreateSignedTransaction(ctx context.Context, outputs []*Output, inputs, ignoreInputs []*Input, ...) (signedTx []byte, txid *chainhash.Hash, fee uint64, err error)
- func (w *Wallet) FetchFeeFromOracle(ctx context.Context, nBlocks uint64) (float64, error)
- func (w *Wallet) IsSynced(ctx context.Context) (bool, int32)
- func (w *Wallet) IsSyncing(ctx context.Context) bool
- func (w *Wallet) MainWallet() *wallet.Wallet
- func (w *Wallet) OpenWallet(ctx context.Context) error
- func (w *Wallet) RescanProgressFromHeight(ctx context.Context, startHeight int32, p chan<- dcrwallet.RescanProgress)
- func (w *Wallet) SendRawTransaction(ctx context.Context, txHex string) (*chainhash.Hash, error)
- func (w *Wallet) Shutdown() error
- func (w *Wallet) StartSync(ctx context.Context, ntfns *spv.Notifications, connectPeers ...string) error
- func (w *Wallet) WalletOpened() bool
Constants ¶
const LogFileName = "external.log"
Variables ¶
This section is empty.
Functions ¶
func InitGlobalLogging ¶
func InitGlobalLogging(externalLogDir string, errorLogger assetlog.ParentLogger) error
InitGlobalLogging initializes logging in the dcrwallet packages, writing the logs to a log file in the specified logDir. If desired, log messages with level >= warn can be additionally written to a separate logger. To achieve this, pass a non-nil ParentLogger that can be used to create error-only loggers.
Logging only has to be initialized once, so an atomic flag is used internally to return early on subsequent invocations.
TODO: See if the below precaution is even necessary for dcrwallet. In theory, the the rotating file logger must be Close'd at some point, but there are concurrency issues with that since btcd and btcwallet have unsupervised goroutines still running after shutdown. So we leave the rotator running at the risk of losing some logs.
func ParseChainParams ¶
func WalletExistsAt ¶
WalletExistsAt returns whether a wallet database file exists at the specified directory. This may return an error for unexpected I/O failures.
Types ¶
type Wallet ¶
type Wallet struct { *asset.WalletBase // contains filtered or unexported fields }
func CreateWallet ¶
func CreateWallet(ctx context.Context, params asset.CreateWalletParams, recovery *asset.RecoveryCfg) (*Wallet, error)
CreateWallet creates and opens an SPV wallet. If recovery params is not provided, a new seed is generated and used. The seed is encrypted with the provided passphrase and can be revealed for backup later by providing the passphrase.
func CreateWatchOnlyWallet ¶
func CreateWatchOnlyWallet(ctx context.Context, extendedPubKey string, params asset.CreateWalletParams) (*Wallet, error)
CreateWatchOnlyWallet creates and opens a watchonly SPV wallet.
func LoadWallet ¶
LoadWallet loads a previously created SPV wallet. The wallet must be opened via its OpenWallet method before it can be used.
func (*Wallet) AccountPubkey ¶
AccountPubkey returns an account's extended pubkey encoded for the network.
func (*Wallet) AddressesByAccount ¶
AddressesByAccount handles a getaddressesbyaccount request by returning all addresses for an account, or an error if the requested account does not exist. Does not include the current address that can be retrieved with w.mainWallet.CurrentAddress.
func (*Wallet) CloseWallet ¶
CloseWallet stops any active network synchronization and closes the wallet database.
func (*Wallet) CreateSignedTransaction ¶
func (w *Wallet) CreateSignedTransaction(ctx context.Context, outputs []*Output, inputs, ignoreInputs []*Input, feeRate uint64) (signedTx []byte, txid *chainhash.Hash, fee uint64, err error)
CreateSignedTransaction creates a signed transaction. The wallet must be unlocked before calling.
func (*Wallet) FetchFeeFromOracle ¶
FetchFeeFromOracle gets the fee rate from the external API.
func (*Wallet) IsSynced ¶
IsSynced returns true if the wallet has synced up to the best block on the mainchain.
func (*Wallet) IsSyncing ¶
IsSyncing returns true if the wallet is catching up to the mainchain's best block.
func (*Wallet) MainWallet ¶
MainWallet returns the main dcr wallet with the core wallet functionalities.
func (*Wallet) OpenWallet ¶
OpenWallet opens the wallet database and the main wallet.
func (*Wallet) RescanProgressFromHeight ¶ added in v1.0.3
func (w *Wallet) RescanProgressFromHeight(ctx context.Context, startHeight int32, p chan<- dcrwallet.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) SendRawTransaction ¶
SendRawTransaction broadcasts the provided transaction to the Decred network.
func (*Wallet) StartSync ¶
func (w *Wallet) StartSync(ctx context.Context, ntfns *spv.Notifications, connectPeers ...string) error
StartSync connects the wallet to the blockchain network via SPV and returns immediately. The wallet stays connected in the background until the provided ctx is canceled or either StopSync or CloseWallet is called.
func (*Wallet) WalletOpened ¶
WalletOpened returns true if the main wallet has been opened.