Bitcoin Core  27.99.0
P2P Digital Currency
Public Types | Public Member Functions | List of all members
interfaces::Wallet Class Referenceabstract

Interface for accessing a wallet. More...

#include <wallet.h>

Public Types

using CoinsList = std::map< CTxDestination, std::vector< std::tuple< COutPoint, WalletTxOut > >>
 Return AvailableCoins + LockedCoins grouped by wallet address. More...
 
using UnloadFn = std::function< void()>
 Register handler for unload message. More...
 
using ShowProgressFn = std::function< void(const std::string &title, int progress)>
 Register handler for show progress messages. More...
 
using StatusChangedFn = std::function< void()>
 Register handler for status changed messages. More...
 
using AddressBookChangedFn = std::function< void(const CTxDestination &address, const std::string &label, bool is_mine, wallet::AddressPurpose purpose, ChangeType status)>
 Register handler for address book changed messages. More...
 
using TransactionChangedFn = std::function< void(const uint256 &txid, ChangeType status)>
 Register handler for transaction changed messages. More...
 
using WatchOnlyChangedFn = std::function< void(bool have_watch_only)>
 Register handler for watchonly changed messages. More...
 
using CanGetAddressesChangedFn = std::function< void()>
 Register handler for keypool changed messages. More...
 

Public Member Functions

virtual ~Wallet ()
 
virtual bool encryptWallet (const SecureString &wallet_passphrase)=0
 Encrypt wallet. More...
 
virtual bool isCrypted ()=0
 Return whether wallet is encrypted. More...
 
virtual bool lock ()=0
 Lock wallet. More...
 
virtual bool unlock (const SecureString &wallet_passphrase)=0
 Unlock wallet. More...
 
virtual bool isLocked ()=0
 Return whether wallet is locked. More...
 
virtual bool changeWalletPassphrase (const SecureString &old_wallet_passphrase, const SecureString &new_wallet_passphrase)=0
 Change wallet passphrase. More...
 
virtual void abortRescan ()=0
 Abort a rescan. More...
 
virtual bool backupWallet (const std::string &filename)=0
 Back up wallet. More...
 
virtual std::string getWalletName ()=0
 Get wallet name. More...
 
virtual util::Result< CTxDestinationgetNewDestination (const OutputType type, const std::string &label)=0
 
virtual bool getPubKey (const CScript &script, const CKeyID &address, CPubKey &pub_key)=0
 Get public key. More...
 
virtual SigningResult signMessage (const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
 Sign message. More...
 
virtual bool isSpendable (const CTxDestination &dest)=0
 Return whether wallet has private key. More...
 
virtual bool haveWatchOnly ()=0
 Return whether wallet has watch only keys. More...
 
virtual bool setAddressBook (const CTxDestination &dest, const std::string &name, const std::optional< wallet::AddressPurpose > &purpose)=0
 Add or update address. More...
 
virtual bool delAddressBook (const CTxDestination &dest)=0
 
virtual bool getAddress (const CTxDestination &dest, std::string *name, wallet::isminetype *is_mine, wallet::AddressPurpose *purpose)=0
 Look up address in wallet, return whether exists. More...
 
virtual std::vector< WalletAddressgetAddresses ()=0
 Get wallet address list. More...
 
virtual std::vector< std::string > getAddressReceiveRequests ()=0
 Get receive requests. More...
 
virtual bool setAddressReceiveRequest (const CTxDestination &dest, const std::string &id, const std::string &value)=0
 Save or remove receive request. More...
 
virtual bool displayAddress (const CTxDestination &dest)=0
 Display address on external signer. More...
 
virtual bool lockCoin (const COutPoint &output, const bool write_to_db)=0
 Lock coin. More...
 
virtual bool unlockCoin (const COutPoint &output)=0
 Unlock coin. More...
 
virtual bool isLockedCoin (const COutPoint &output)=0
 Return whether coin is locked. More...
 
virtual void listLockedCoins (std::vector< COutPoint > &outputs)=0
 List locked coins. More...
 
virtual util::Result< CTransactionRefcreateTransaction (const std::vector< wallet::CRecipient > &recipients, const wallet::CCoinControl &coin_control, bool sign, int &change_pos, CAmount &fee)=0
 Create transaction. More...
 
virtual void commitTransaction (CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
 Commit transaction. More...
 
virtual bool transactionCanBeAbandoned (const uint256 &txid)=0
 Return whether transaction can be abandoned. More...
 
virtual bool abandonTransaction (const uint256 &txid)=0
 Abandon transaction. More...
 
virtual bool transactionCanBeBumped (const uint256 &txid)=0
 Return whether transaction can be bumped. More...
 
virtual bool createBumpTransaction (const uint256 &txid, const wallet::CCoinControl &coin_control, std::vector< bilingual_str > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)=0
 Create bump transaction. More...
 
virtual bool signBumpTransaction (CMutableTransaction &mtx)=0
 Sign bump transaction. More...
 
virtual bool commitBumpTransaction (const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)=0
 Commit bump transaction. More...
 
virtual CTransactionRef getTx (const uint256 &txid)=0
 Get a transaction. More...
 
virtual WalletTx getWalletTx (const uint256 &txid)=0
 Get transaction information. More...
 
virtual std::set< WalletTxgetWalletTxs ()=0
 Get list of all wallet transactions. More...
 
virtual bool tryGetTxStatus (const uint256 &txid, WalletTxStatus &tx_status, int &num_blocks, int64_t &block_time)=0
 Try to get updated status for a particular transaction, if possible without blocking. More...
 
virtual WalletTx getWalletTxDetails (const uint256 &txid, WalletTxStatus &tx_status, WalletOrderForm &order_form, bool &in_mempool, int &num_blocks)=0
 Get transaction details. More...
 
virtual TransactionError fillPSBT (int sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
 Fill PSBT. More...
 
virtual WalletBalances getBalances ()=0
 Get balances. More...
 
virtual bool tryGetBalances (WalletBalances &balances, uint256 &block_hash)=0
 Get balances if possible without blocking. More...
 
virtual CAmount getBalance ()=0
 Get balance. More...
 
virtual CAmount getAvailableBalance (const wallet::CCoinControl &coin_control)=0
 Get available balance. More...
 
virtual wallet::isminetype txinIsMine (const CTxIn &txin)=0
 Return whether transaction input belongs to wallet. More...
 
virtual wallet::isminetype txoutIsMine (const CTxOut &txout)=0
 Return whether transaction output belongs to wallet. More...
 
virtual CAmount getDebit (const CTxIn &txin, wallet::isminefilter filter)=0
 Return debit amount if transaction input belongs to wallet. More...
 
virtual CAmount getCredit (const CTxOut &txout, wallet::isminefilter filter)=0
 Return credit amount if transaction input belongs to wallet. More...
 
virtual CoinsList listCoins ()=0
 
virtual std::vector< WalletTxOutgetCoins (const std::vector< COutPoint > &outputs)=0
 Return wallet transaction output information. More...
 
virtual CAmount getRequiredFee (unsigned int tx_bytes)=0
 Get required fee. More...
 
virtual CAmount getMinimumFee (unsigned int tx_bytes, const wallet::CCoinControl &coin_control, int *returned_target, FeeReason *reason)=0
 Get minimum fee. More...
 
virtual unsigned int getConfirmTarget ()=0
 Get tx confirm target. More...
 
virtual bool hdEnabled ()=0
 
virtual bool canGetAddresses ()=0
 
virtual bool privateKeysDisabled ()=0
 
virtual bool taprootEnabled ()=0
 
virtual bool hasExternalSigner ()=0
 
virtual OutputType getDefaultAddressType ()=0
 
virtual CAmount getDefaultMaxTxFee ()=0
 Get max tx fee. More...
 
virtual void remove ()=0
 
virtual bool isLegacy ()=0
 Return whether is a legacy wallet. More...
 
virtual std::unique_ptr< HandlerhandleUnload (UnloadFn fn)=0
 
virtual std::unique_ptr< HandlerhandleShowProgress (ShowProgressFn fn)=0
 
virtual std::unique_ptr< HandlerhandleStatusChanged (StatusChangedFn fn)=0
 
virtual std::unique_ptr< HandlerhandleAddressBookChanged (AddressBookChangedFn fn)=0
 
virtual std::unique_ptr< HandlerhandleTransactionChanged (TransactionChangedFn fn)=0
 
virtual std::unique_ptr< HandlerhandleWatchOnlyChanged (WatchOnlyChangedFn fn)=0
 
virtual std::unique_ptr< HandlerhandleCanGetAddressesChanged (CanGetAddressesChangedFn fn)=0
 
virtual wallet::CWalletwallet ()
 Return pointer to internal wallet class, useful for testing. More...
 

Detailed Description

Interface for accessing a wallet.

Definition at line 60 of file wallet.h.

Member Typedef Documentation

◆ AddressBookChangedFn

using interfaces::Wallet::AddressBookChangedFn = std::function<void(const CTxDestination& address, const std::string& label, bool is_mine, wallet::AddressPurpose purpose, ChangeType status)>

Register handler for address book changed messages.

Definition at line 296 of file wallet.h.

◆ CanGetAddressesChangedFn

using interfaces::Wallet::CanGetAddressesChangedFn = std::function<void()>

Register handler for keypool changed messages.

Definition at line 312 of file wallet.h.

◆ CoinsList

using interfaces::Wallet::CoinsList = std::map<CTxDestination, std::vector<std::tuple<COutPoint, WalletTxOut> >>

Return AvailableCoins + LockedCoins grouped by wallet address.

(put change in one group with wallet address)

Definition at line 238 of file wallet.h.

◆ ShowProgressFn

using interfaces::Wallet::ShowProgressFn = std::function<void(const std::string& title, int progress)>

Register handler for show progress messages.

Definition at line 288 of file wallet.h.

◆ StatusChangedFn

using interfaces::Wallet::StatusChangedFn = std::function<void()>

Register handler for status changed messages.

Definition at line 292 of file wallet.h.

◆ TransactionChangedFn

using interfaces::Wallet::TransactionChangedFn = std::function<void(const uint256& txid, ChangeType status)>

Register handler for transaction changed messages.

Definition at line 304 of file wallet.h.

◆ UnloadFn

using interfaces::Wallet::UnloadFn = std::function<void()>

Register handler for unload message.

Definition at line 284 of file wallet.h.

◆ WatchOnlyChangedFn

using interfaces::Wallet::WatchOnlyChangedFn = std::function<void(bool have_watch_only)>

Register handler for watchonly changed messages.

Definition at line 308 of file wallet.h.

Constructor & Destructor Documentation

◆ ~Wallet()

virtual interfaces::Wallet::~Wallet ( )
inlinevirtual

Definition at line 63 of file wallet.h.

Member Function Documentation

◆ abandonTransaction()

virtual bool interfaces::Wallet::abandonTransaction ( const uint256 txid)
pure virtual

Abandon transaction.

Here is the caller graph for this function:

◆ abortRescan()

virtual void interfaces::Wallet::abortRescan ( )
pure virtual

Abort a rescan.

Here is the caller graph for this function:

◆ backupWallet()

virtual bool interfaces::Wallet::backupWallet ( const std::string &  filename)
pure virtual

Back up wallet.

Here is the caller graph for this function:

◆ canGetAddresses()

virtual bool interfaces::Wallet::canGetAddresses ( )
pure virtual
Here is the caller graph for this function:

◆ changeWalletPassphrase()

virtual bool interfaces::Wallet::changeWalletPassphrase ( const SecureString old_wallet_passphrase,
const SecureString new_wallet_passphrase 
)
pure virtual

Change wallet passphrase.

◆ commitBumpTransaction()

virtual bool interfaces::Wallet::commitBumpTransaction ( const uint256 txid,
CMutableTransaction &&  mtx,
std::vector< bilingual_str > &  errors,
uint256 bumped_txid 
)
pure virtual

Commit bump transaction.

◆ commitTransaction()

virtual void interfaces::Wallet::commitTransaction ( CTransactionRef  tx,
WalletValueMap  value_map,
WalletOrderForm  order_form 
)
pure virtual

Commit transaction.

Here is the caller graph for this function:

◆ createBumpTransaction()

virtual bool interfaces::Wallet::createBumpTransaction ( const uint256 txid,
const wallet::CCoinControl coin_control,
std::vector< bilingual_str > &  errors,
CAmount old_fee,
CAmount new_fee,
CMutableTransaction mtx 
)
pure virtual

Create bump transaction.

◆ createTransaction()

virtual util::Result<CTransactionRef> interfaces::Wallet::createTransaction ( const std::vector< wallet::CRecipient > &  recipients,
const wallet::CCoinControl coin_control,
bool  sign,
int &  change_pos,
CAmount fee 
)
pure virtual

Create transaction.

◆ delAddressBook()

virtual bool interfaces::Wallet::delAddressBook ( const CTxDestination dest)
pure virtual
Here is the caller graph for this function:

◆ displayAddress()

virtual bool interfaces::Wallet::displayAddress ( const CTxDestination dest)
pure virtual

Display address on external signer.

◆ encryptWallet()

virtual bool interfaces::Wallet::encryptWallet ( const SecureString wallet_passphrase)
pure virtual

Encrypt wallet.

◆ fillPSBT()

virtual TransactionError interfaces::Wallet::fillPSBT ( int  sighash_type,
bool  sign,
bool  bip32derivs,
size_t *  n_signed,
PartiallySignedTransaction psbtx,
bool &  complete 
)
pure virtual

Fill PSBT.

Here is the caller graph for this function:

◆ getAddress()

virtual bool interfaces::Wallet::getAddress ( const CTxDestination dest,
std::string *  name,
wallet::isminetype is_mine,
wallet::AddressPurpose purpose 
)
pure virtual

Look up address in wallet, return whether exists.

Here is the caller graph for this function:

◆ getAddresses()

virtual std::vector<WalletAddress> interfaces::Wallet::getAddresses ( )
pure virtual

Get wallet address list.

◆ getAddressReceiveRequests()

virtual std::vector<std::string> interfaces::Wallet::getAddressReceiveRequests ( )
pure virtual

Get receive requests.

Here is the caller graph for this function:

◆ getAvailableBalance()

virtual CAmount interfaces::Wallet::getAvailableBalance ( const wallet::CCoinControl coin_control)
pure virtual

Get available balance.

Here is the caller graph for this function:

◆ getBalance()

virtual CAmount interfaces::Wallet::getBalance ( )
pure virtual

Get balance.

◆ getBalances()

virtual WalletBalances interfaces::Wallet::getBalances ( )
pure virtual

Get balances.

◆ getCoins()

virtual std::vector<WalletTxOut> interfaces::Wallet::getCoins ( const std::vector< COutPoint > &  outputs)
pure virtual

Return wallet transaction output information.

Here is the caller graph for this function:

◆ getConfirmTarget()

virtual unsigned int interfaces::Wallet::getConfirmTarget ( )
pure virtual

Get tx confirm target.

Here is the caller graph for this function:

◆ getCredit()

virtual CAmount interfaces::Wallet::getCredit ( const CTxOut txout,
wallet::isminefilter  filter 
)
pure virtual

Return credit amount if transaction input belongs to wallet.

◆ getDebit()

virtual CAmount interfaces::Wallet::getDebit ( const CTxIn txin,
wallet::isminefilter  filter 
)
pure virtual

Return debit amount if transaction input belongs to wallet.

◆ getDefaultAddressType()

virtual OutputType interfaces::Wallet::getDefaultAddressType ( )
pure virtual
Here is the caller graph for this function:

◆ getDefaultMaxTxFee()

virtual CAmount interfaces::Wallet::getDefaultMaxTxFee ( )
pure virtual

Get max tx fee.

Here is the caller graph for this function:

◆ getMinimumFee()

virtual CAmount interfaces::Wallet::getMinimumFee ( unsigned int  tx_bytes,
const wallet::CCoinControl coin_control,
int *  returned_target,
FeeReason reason 
)
pure virtual

Get minimum fee.

Here is the caller graph for this function:

◆ getNewDestination()

virtual util::Result<CTxDestination> interfaces::Wallet::getNewDestination ( const OutputType  type,
const std::string &  label 
)
pure virtual
Here is the caller graph for this function:

◆ getPubKey()

virtual bool interfaces::Wallet::getPubKey ( const CScript script,
const CKeyID address,
CPubKey pub_key 
)
pure virtual

Get public key.

Here is the caller graph for this function:

◆ getRequiredFee()

virtual CAmount interfaces::Wallet::getRequiredFee ( unsigned int  tx_bytes)
pure virtual

Get required fee.

Here is the caller graph for this function:

◆ getTx()

virtual CTransactionRef interfaces::Wallet::getTx ( const uint256 txid)
pure virtual

Get a transaction.

◆ getWalletName()

virtual std::string interfaces::Wallet::getWalletName ( )
pure virtual

Get wallet name.

Here is the caller graph for this function:

◆ getWalletTx()

virtual WalletTx interfaces::Wallet::getWalletTx ( const uint256 txid)
pure virtual

Get transaction information.

◆ getWalletTxDetails()

virtual WalletTx interfaces::Wallet::getWalletTxDetails ( const uint256 txid,
WalletTxStatus tx_status,
WalletOrderForm order_form,
bool &  in_mempool,
int &  num_blocks 
)
pure virtual

Get transaction details.

◆ getWalletTxs()

virtual std::set<WalletTx> interfaces::Wallet::getWalletTxs ( )
pure virtual

Get list of all wallet transactions.

◆ handleAddressBookChanged()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleAddressBookChanged ( AddressBookChangedFn  fn)
pure virtual

◆ handleCanGetAddressesChanged()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleCanGetAddressesChanged ( CanGetAddressesChangedFn  fn)
pure virtual

◆ handleShowProgress()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleShowProgress ( ShowProgressFn  fn)
pure virtual
Here is the caller graph for this function:

◆ handleStatusChanged()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleStatusChanged ( StatusChangedFn  fn)
pure virtual

◆ handleTransactionChanged()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleTransactionChanged ( TransactionChangedFn  fn)
pure virtual
Here is the caller graph for this function:

◆ handleUnload()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleUnload ( UnloadFn  fn)
pure virtual

◆ handleWatchOnlyChanged()

virtual std::unique_ptr<Handler> interfaces::Wallet::handleWatchOnlyChanged ( WatchOnlyChangedFn  fn)
pure virtual

◆ hasExternalSigner()

virtual bool interfaces::Wallet::hasExternalSigner ( )
pure virtual
Here is the caller graph for this function:

◆ haveWatchOnly()

virtual bool interfaces::Wallet::haveWatchOnly ( )
pure virtual

Return whether wallet has watch only keys.

Here is the caller graph for this function:

◆ hdEnabled()

virtual bool interfaces::Wallet::hdEnabled ( )
pure virtual

◆ isCrypted()

virtual bool interfaces::Wallet::isCrypted ( )
pure virtual

Return whether wallet is encrypted.

◆ isLegacy()

virtual bool interfaces::Wallet::isLegacy ( )
pure virtual

Return whether is a legacy wallet.

Here is the caller graph for this function:

◆ isLocked()

virtual bool interfaces::Wallet::isLocked ( )
pure virtual

Return whether wallet is locked.

◆ isLockedCoin()

virtual bool interfaces::Wallet::isLockedCoin ( const COutPoint output)
pure virtual

Return whether coin is locked.

Here is the caller graph for this function:

◆ isSpendable()

virtual bool interfaces::Wallet::isSpendable ( const CTxDestination dest)
pure virtual

Return whether wallet has private key.

Here is the caller graph for this function:

◆ listCoins()

virtual CoinsList interfaces::Wallet::listCoins ( )
pure virtual
Here is the caller graph for this function:

◆ listLockedCoins()

virtual void interfaces::Wallet::listLockedCoins ( std::vector< COutPoint > &  outputs)
pure virtual

List locked coins.

Here is the caller graph for this function:

◆ lock()

virtual bool interfaces::Wallet::lock ( )
pure virtual

Lock wallet.

◆ lockCoin()

virtual bool interfaces::Wallet::lockCoin ( const COutPoint output,
const bool  write_to_db 
)
pure virtual

Lock coin.

Here is the caller graph for this function:

◆ privateKeysDisabled()

virtual bool interfaces::Wallet::privateKeysDisabled ( )
pure virtual
Here is the caller graph for this function:

◆ remove()

virtual void interfaces::Wallet::remove ( )
pure virtual
Here is the caller graph for this function:

◆ setAddressBook()

virtual bool interfaces::Wallet::setAddressBook ( const CTxDestination dest,
const std::string &  name,
const std::optional< wallet::AddressPurpose > &  purpose 
)
pure virtual

Add or update address.

Here is the caller graph for this function:

◆ setAddressReceiveRequest()

virtual bool interfaces::Wallet::setAddressReceiveRequest ( const CTxDestination dest,
const std::string &  id,
const std::string &  value 
)
pure virtual

Save or remove receive request.

Here is the caller graph for this function:

◆ signBumpTransaction()

virtual bool interfaces::Wallet::signBumpTransaction ( CMutableTransaction mtx)
pure virtual

Sign bump transaction.

◆ signMessage()

virtual SigningResult interfaces::Wallet::signMessage ( const std::string &  message,
const PKHash pkhash,
std::string &  str_sig 
)
pure virtual

Sign message.

Here is the caller graph for this function:

◆ taprootEnabled()

virtual bool interfaces::Wallet::taprootEnabled ( )
pure virtual
Here is the caller graph for this function:

◆ transactionCanBeAbandoned()

virtual bool interfaces::Wallet::transactionCanBeAbandoned ( const uint256 txid)
pure virtual

Return whether transaction can be abandoned.

Here is the caller graph for this function:

◆ transactionCanBeBumped()

virtual bool interfaces::Wallet::transactionCanBeBumped ( const uint256 txid)
pure virtual

Return whether transaction can be bumped.

Here is the caller graph for this function:

◆ tryGetBalances()

virtual bool interfaces::Wallet::tryGetBalances ( WalletBalances balances,
uint256 block_hash 
)
pure virtual

Get balances if possible without blocking.

◆ tryGetTxStatus()

virtual bool interfaces::Wallet::tryGetTxStatus ( const uint256 txid,
WalletTxStatus tx_status,
int &  num_blocks,
int64_t &  block_time 
)
pure virtual

Try to get updated status for a particular transaction, if possible without blocking.

◆ txinIsMine()

virtual wallet::isminetype interfaces::Wallet::txinIsMine ( const CTxIn txin)
pure virtual

Return whether transaction input belongs to wallet.

◆ txoutIsMine()

virtual wallet::isminetype interfaces::Wallet::txoutIsMine ( const CTxOut txout)
pure virtual

Return whether transaction output belongs to wallet.

Here is the caller graph for this function:

◆ unlock()

virtual bool interfaces::Wallet::unlock ( const SecureString wallet_passphrase)
pure virtual

Unlock wallet.

◆ unlockCoin()

virtual bool interfaces::Wallet::unlockCoin ( const COutPoint output)
pure virtual

Unlock coin.

Here is the caller graph for this function:

◆ wallet()

virtual wallet::CWallet* interfaces::Wallet::wallet ( )
inlinevirtual

Return pointer to internal wallet class, useful for testing.

Definition at line 316 of file wallet.h.


The documentation for this class was generated from the following file: