Documentation ¶
Index ¶
- func DisableLog()
- func UseLogger(logger slog.Logger)
- type Config
- type DcrWallet
- func (b *DcrWallet) BackEnd() string
- func (b *DcrWallet) BestBlock() (int64, chainhash.Hash, int64, error)
- func (b *DcrWallet) Bip44AddressInfo(addr dcrutil.Address) (uint32, uint32, uint32, error)
- func (b *DcrWallet) ComputeInputScript(tx *wire.MsgTx, signDesc *input.SignDescriptor) (*input.Script, error)
- func (b *DcrWallet) ConfirmedBalance(confs int32) (dcrutil.Amount, error)
- func (b *DcrWallet) CreateSimpleTx(outputs []*wire.TxOut, feeRate lnwallet.AtomPerKByte, dryRun bool) (*txauthor.AuthoredTx, error)
- func (b *DcrWallet) FetchInputInfo(prevOut *wire.OutPoint) (*lnwallet.Utxo, error)
- func (b *DcrWallet) InitialSyncChannel() <-chan struct{}
- func (b *DcrWallet) IsOurAddress(a dcrutil.Address) bool
- func (b *DcrWallet) IsSynced() (bool, int64, error)
- func (b *DcrWallet) LastUnusedAddress(addrType lnwallet.AddressType) (dcrutil.Address, error)
- func (b *DcrWallet) ListTransactionDetails() ([]*lnwallet.TransactionDetail, error)
- func (b *DcrWallet) ListUnspentWitness(minConfs, maxConfs int32) ([]*lnwallet.Utxo, error)
- func (b *DcrWallet) LockOutpoint(o wire.OutPoint)
- func (b *DcrWallet) NewAddress(t lnwallet.AddressType, change bool) (dcrutil.Address, error)
- func (b *DcrWallet) PublishTransaction(tx *wire.MsgTx) error
- func (b *DcrWallet) SendOutputs(outputs []*wire.TxOut, feeRate lnwallet.AtomPerKByte) (*wire.MsgTx, error)
- func (b *DcrWallet) SignMessage(pubKey *secp256k1.PublicKey, msg []byte) (*secp256k1.Signature, error)
- func (b *DcrWallet) SignOutputRaw(tx *wire.MsgTx, signDesc *input.SignDescriptor) ([]byte, error)
- func (b *DcrWallet) Start() error
- func (b *DcrWallet) Stop() error
- func (b *DcrWallet) SubscribeTransactions() (lnwallet.TransactionSubscription, error)
- func (b *DcrWallet) UnlockOutpoint(o wire.OutPoint)
- type WalletSyncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type Config ¶
type Config struct { // PrivatePass is the private password to the underlying dcrwallet // instance. Without this, the wallet cannot be decrypted and operated. PrivatePass []byte // FeeEstimator is an instance of the fee estimator interface which // will be used by the wallet to dynamically set transaction fees when // crafting transactions. FeeEstimator lnwallet.FeeEstimator // NetParams is the net parameters for the target chain. NetParams *chaincfg.Params // Conn is a grpc connection to an already opened wallet. This needs to // be filled for the wallet to work. Conn *grpc.ClientConn // AccountNumber is the account number to use to perform the ln // operations. AccountNumber int32 // ChainIO is a direct connection to the blockchain IO driver needed by // the wallet. // // TODO(decred) Ideally this should be performed by wallet operations // but not all operations needed by the drivers are currently // implemented in the wallet. ChainIO lnwallet.BlockChainIO DB *channeldb.DB }
Config is a struct which houses configuration parameters which modify the instance of DcrWallet generated by the New() function.
type DcrWallet ¶
type DcrWallet struct {
// contains filtered or unexported fields
}
func (*DcrWallet) BackEnd ¶
BackEnd returns the underlying ChainService's name as a string.
This is a part of the WalletController interface.
func (*DcrWallet) Bip44AddressInfo ¶
Bip44AddressInfo returns the BIP44 relevant (account, branch and index) of the given wallet address.
func (*DcrWallet) ComputeInputScript ¶
func (b *DcrWallet) ComputeInputScript(tx *wire.MsgTx, signDesc *input.SignDescriptor) (*input.Script, error)
ComputeInputScript generates a complete InputScript for the passed transaction with the signature as defined within the passed input.SignDescriptor. This method is capable of generating the proper input script only for regular p2pkh outputs.
This is a part of the WalletController interface.
func (*DcrWallet) ConfirmedBalance ¶
ConfirmedBalance returns the sum of all the wallet's unspent outputs that have at least confs confirmations. If confs is set to zero, then all unspent outputs, including those currently in the mempool will be included in the final sum.
This is a part of the WalletController interface.
func (*DcrWallet) CreateSimpleTx ¶
func (b *DcrWallet) CreateSimpleTx(outputs []*wire.TxOut, feeRate lnwallet.AtomPerKByte, dryRun bool) (*txauthor.AuthoredTx, error)
CreateSimpleTx creates a Bitcoin transaction paying to the specified outputs. The transaction is not broadcasted to the network, but a new change address might be created in the wallet database. In the case the wallet has insufficient funds, or the outputs are non-standard, an error should be returned. This method also takes the target fee expressed in sat/kw that should be used when crafting the transaction.
NOTE: The dryRun argument can be set true to create a tx that doesn't alter the database. A tx created with this set to true SHOULD NOT be broadcasted.
This is a part of the WalletController interface.
func (*DcrWallet) FetchInputInfo ¶
FetchInputInfo queries for the WalletController's knowledge of the passed outpoint. If the base wallet determines this output is under its control, then the original txout should be returned. Otherwise, a non-nil error value of ErrNotMine should be returned instead.
This is a part of the WalletController interface.
func (*DcrWallet) InitialSyncChannel ¶
func (b *DcrWallet) InitialSyncChannel() <-chan struct{}
InitialSyncChannel returns the channel used to signal that wallet init has finished.
This is a part of the WalletController interface.
func (*DcrWallet) IsOurAddress ¶
IsOurAddress checks if the passed address belongs to this wallet
This is a part of the WalletController interface.
func (*DcrWallet) IsSynced ¶
IsSynced returns a boolean indicating if from the PoV of the wallet, it has fully synced to the current best block in the main chain.
This is a part of the WalletController interface.
func (*DcrWallet) LastUnusedAddress ¶
func (b *DcrWallet) LastUnusedAddress(addrType lnwallet.AddressType) ( dcrutil.Address, error)
LastUnusedAddress returns the last *unused* address known by the wallet. An address is unused if it hasn't received any payments. This can be useful in UIs in order to continually show the "freshest" address without having to worry about "address inflation" caused by continual refreshing. Similar to NewAddress it can derive a specified address type, and also optionally a change address.
func (*DcrWallet) ListTransactionDetails ¶
func (b *DcrWallet) ListTransactionDetails() ([]*lnwallet.TransactionDetail, error)
ListTransactionDetails returns a list of all transactions which are relevant to the wallet.
This is a part of the WalletController interface.
func (*DcrWallet) ListUnspentWitness ¶
ListUnspentWitness returns a slice of all the unspent outputs the wallet controls which pay to witness programs either directly or indirectly.
This is a part of the WalletController interface.
func (*DcrWallet) LockOutpoint ¶
LockOutpoint marks an outpoint as locked meaning it will no longer be deemed as eligible for coin selection. Locking outputs are utilized in order to avoid race conditions when selecting inputs for usage when funding a channel.
This is a part of the WalletController interface.
func (*DcrWallet) NewAddress ¶
func (b *DcrWallet) NewAddress(t lnwallet.AddressType, change bool) (dcrutil.Address, error)
NewAddress returns the next external or internal address for the wallet dictated by the value of the `change` parameter. If change is true, then an internal address will be returned, otherwise an external address should be returned.
This is a part of the WalletController interface.
func (*DcrWallet) PublishTransaction ¶
PublishTransaction performs cursory validation (dust checks, etc), then finally broadcasts the passed transaction to the Decred network. If publishing the transaction fails, an error describing the reason is returned (currently ErrDoubleSpend). If the transaction is already published to the network (either in the mempool or chain) no error will be returned.
This is a part of the WalletController interface.
func (*DcrWallet) SendOutputs ¶
func (b *DcrWallet) SendOutputs(outputs []*wire.TxOut, feeRate lnwallet.AtomPerKByte) (*wire.MsgTx, error)
SendOutputs funds, signs, and broadcasts a Decred transaction paying out to the specified outputs. In the case the wallet has insufficient funds, or the outputs are non-standard, a non-nil error will be returned.
This is a part of the WalletController interface.
func (*DcrWallet) SignMessage ¶
func (b *DcrWallet) SignMessage(pubKey *secp256k1.PublicKey, msg []byte) (*secp256k1.Signature, error)
SignMessage attempts to sign a target message with the private key that corresponds to the passed public key. If the target private key is unable to be found, then an error will be returned. The actual digest signed is the chainhash (blake256r14) of the passed message.
NOTE: This is a part of the Messageinput.Signer interface.
func (*DcrWallet) SignOutputRaw ¶
SignOutputRaw generates a signature for the passed transaction according to the data within the passed input.SignDescriptor.
This is a part of the WalletController interface.
func (*DcrWallet) Start ¶
Start initializes the underlying rpc connection, the wallet itself, and begins syncing to the current available blockchain state.
This is a part of the WalletController interface.
func (*DcrWallet) Stop ¶
Stop signals the wallet for shutdown. Shutdown may entail closing any active sockets, database handles, stopping goroutines, etc.
This is a part of the WalletController interface.
func (*DcrWallet) SubscribeTransactions ¶
func (b *DcrWallet) SubscribeTransactions() (lnwallet.TransactionSubscription, error)
SubscribeTransactions returns a TransactionSubscription client which is capable of receiving async notifications as new transactions related to the wallet are seen within the network, or found in blocks.
This is a part of the WalletController interface.
func (*DcrWallet) UnlockOutpoint ¶
UnlockOutpoint unlocks a previously locked output, marking it eligible for coin selection.
This is a part of the WalletController interface.
type WalletSyncer ¶
type WalletSyncer interface { lnwallet.BlockChainIO // contains filtered or unexported methods }
WalletSyncer is an exported interface for the available wallet sync backends (RPC, SPV, etc). While this interface is exported to ease construction of a Config structure, only implementations provided by this package are supported, since currently the implementation is tightly coupled to the DcrWallet struct.
The current backend implementations also implement the BlockChainIO interface.