-
- All Implemented Interfaces:
public final class Wallet
A Bitcoin wallet. The Wallet acts as a way of coherently interfacing with output descriptors and related transactions. Its main components are:
Output descriptors from which it can derive addresses.
A Database where it tracks transactions and utxos related to the descriptors.
Signers that can contribute signatures to addresses instantiated from the descriptors.
-
-
Constructor Summary
Constructors Constructor Description Wallet(Descriptor descriptor, Descriptor changeDescriptor, Network network, DatabaseConfig databaseConfig)
Create a BDK wallet.
-
Method Summary
Modifier and Type Method Description final AddressInfo
getAddress(AddressIndex addressIndex)
Return a derived address using the external descriptor, see AddressIndex for available address index selection strategies. final AddressInfo
getInternalAddress(AddressIndex addressIndex)
Return a derived address using the internal (change) descriptor. final Boolean
isMine(Script script)
Return whether or not a script is part of this wallet (either internal or external). final Balance
getBalance()
Return the wallet's balance, across different categories. final Boolean
sign(PartiallySignedTransaction psbt, SignOptions signOptions)
Sign a transaction with all the wallet's signers, in the order specified by every signer's SignerOrdering
.final List<TransactionDetails>
listTransactions(Boolean includeRaw)
Return the list of transactions made and received by the wallet. final Network
network()
Get the Bitcoin network the wallet is using. final Unit
sync(Blockchain blockchain, Progress progress)
Sync the internal database with the blockchain. final List<LocalUtxo>
listUnspent()
Return the list of unspent outputs of this wallet.
-
-
-
Constructor Detail
-
Wallet
Wallet(Descriptor descriptor, Descriptor changeDescriptor, Network network, DatabaseConfig databaseConfig)
Create a BDK wallet.- Parameters:
descriptor
- The main (or "external") descriptor.changeDescriptor
- ?network
- The network to act on.databaseConfig
- The database configuration.
-
-
Method Detail
-
getAddress
final AddressInfo getAddress(AddressIndex addressIndex)
Return a derived address using the external descriptor, see AddressIndex for available address index selection strategies. If none of the keys in the descriptor are derivable (i.e. the descriptor does not end with a * character) then the same address will always be returned for any AddressIndex.
-
getInternalAddress
final AddressInfo getInternalAddress(AddressIndex addressIndex)
Return a derived address using the internal (change) descriptor. If the wallet doesn't have an internal descriptor it will use the external descriptor. See AddressIndex for available address index selection strategies. If none of the keys in the descriptor are derivable (i.e. does not end with /\*) then the same address will always be returned for any AddressIndex.
-
isMine
final Boolean isMine(Script script)
Return whether or not a script is part of this wallet (either internal or external).
-
getBalance
final Balance getBalance()
Return the wallet's balance, across different categories. See Balance for the categories. Note that this method only operates on the internal database, which first needs to be Wallet.sync manually.
-
sign
final Boolean sign(PartiallySignedTransaction psbt, SignOptions signOptions)
Sign a transaction with all the wallet's signers, in the order specified by every signer's
SignerOrdering
.The
SignOptions
can be used to tweak the behavior of the software signers, and the way the transaction is finalized at the end. Note that it can't be guaranteed that every signers will follow the options, but the "software signers" (WIF keys andxprv
) defined in this library will.- Parameters:
psbt
- PSBT to be signedsignOptions
- signing options
-
listTransactions
final List<TransactionDetails> listTransactions(Boolean includeRaw)
Return the list of transactions made and received by the wallet. Note that this method only operate on the internal database, which first needs to be Wallet.sync manually.
-
sync
final Unit sync(Blockchain blockchain, Progress progress)
Sync the internal database with the blockchain.
-
listUnspent
final List<LocalUtxo> listUnspent()
Return the list of unspent outputs of this wallet. Note that this method only operates on the internal database, which first needs to be Wallet.sync manually.
-
-