btc

package
v0.0.0-...-a0f938d Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: BlueOak-1.0.0 Imports: 18 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.

In theory, the rotating file logger must be Closed 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(net asset.Network) (*chaincfg.Params, error)

func WalletExistsAt

func WalletExistsAt(dir string) (bool, error)

WalletExistsAt checks if a wallet exists at the specified directory.

Types

type Wallet

type Wallet[Tx any] struct {
	*asset.WalletBase[Tx]
	// contains filtered or unexported fields
}

func CreateWallet

func CreateWallet[Tx any](ctx context.Context, params asset.CreateWalletParams[Tx], recovery *asset.RecoveryCfg) (*Wallet[Tx], 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[Tx any](ctx context.Context, extendedPubKey string, params asset.CreateWalletParams[Tx]) (*Wallet[Tx], error)

CreateWatchOnlyWallet creates and opens a watchonly SPV wallet.

func LoadWallet

func LoadWallet[Tx any](ctx context.Context, params asset.OpenWalletParams[Tx]) (*Wallet[Tx], error)

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

func (*Wallet[_]) CloseWallet

func (w *Wallet[_]) CloseWallet() error

CloseWallet stops any active network synchronization and unloads the main wallet.

func (*Wallet[_]) IsSynced

func (w *Wallet[_]) IsSynced() bool

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

func (*Wallet[_]) IsSyncing

func (w *Wallet[_]) IsSyncing() 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 btc wallet with the core wallet functionalities.

func (*Wallet[_]) OpenWallet

func (w *Wallet[_]) OpenWallet() error

OpenWallet opens the main wallet.

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, connectPeers []string, savedPeersFilePath 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. TODO: Accept sync ntfn listeners.

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