dcr

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2024 License: BlueOak-1.0.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
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 ParseChainParams(network asset.Network) (*chaincfg.Params, error)

func WalletExistsAt

func WalletExistsAt(dataDir string) (bool, error)

WalletExistsAt returns whether a wallet database file exists at the specified directory. This may return an error for unexpected I/O failures.

Types

type Input

type Input struct {
	TxID string
	Vout uint32
}

func (Input) String

func (in Input) String() string

type Output

type Output struct {
	Address string
	Amount  uint64
}

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

func LoadWallet(ctx context.Context, params asset.OpenWalletParams) (*Wallet, error)

LoadWallet loads a previously created SPV wallet. The wallet must be opened via its OpenWallet method before it can be used.

func (*Wallet) AccountPubkey

func (w *Wallet) AccountPubkey(ctx context.Context, acct string) (string, error)

AccountPubkey returns an account's extended pubkey encoded for the network.

func (*Wallet) AddressesByAccount

func (w *Wallet) AddressesByAccount(ctx context.Context, account string) ([]string, error)

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

func (w *Wallet) CloseWallet() error

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

func (w *Wallet) FetchFeeFromOracle(ctx context.Context, nBlocks uint64) (float64, error)

FetchFeeFromOracle gets the fee rate from the external API.

func (*Wallet) IsSynced

func (w *Wallet) IsSynced(ctx context.Context) (bool, int32)

IsSynced returns true if the wallet has synced up to the best block on the mainchain.

func (*Wallet) IsSyncing

func (w *Wallet) IsSyncing(ctx context.Context) bool

IsSyncing returns true if the wallet is catching up to the mainchain's best block.

func (*Wallet) MainWallet

func (w *Wallet) MainWallet() *wallet.Wallet

MainWallet returns the main dcr wallet with the core wallet functionalities.

func (*Wallet) OpenWallet

func (w *Wallet) OpenWallet(ctx context.Context) error

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

func (w *Wallet) SendRawTransaction(ctx context.Context, txHex string) (*chainhash.Hash, error)

SendRawTransaction broadcasts the provided transaction to the Decred network.

func (*Wallet) Shutdown

func (w *Wallet) Shutdown() error

Shutdown closes the main wallet and any other resources in use.

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

func (w *Wallet) WalletOpened() bool

WalletOpened returns true if the main wallet has been opened.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL