 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #ifndef BITCOIN_INTERFACES_WALLET_H
6 #define BITCOIN_INTERFACES_WALLET_H
23 #include <type_traits>
47 struct WalletBalances;
50 struct WalletTxStatus;
68 virtual bool lock() = 0;
84 virtual bool backupWallet(
const std::string& filename) = 0;
114 std::string* purpose) = 0;
165 std::vector<bilingual_str>& errors,
176 std::vector<bilingual_str>& errors,
192 int64_t& block_time) = 0;
199 int& num_blocks) = 0;
235 using CoinsList = std::map<CTxDestination, std::vector<std::tuple<COutPoint, WalletTxOut>>>;
239 virtual std::vector<WalletTxOut>
getCoins(
const std::vector<COutPoint>& outputs) = 0;
247 int* returned_target,
275 virtual void remove() = 0;
285 using ShowProgressFn = std::function<void(
const std::string& title,
int progress)>;
294 const std::string& label,
296 const std::string& purpose,
338 virtual std::vector<std::unique_ptr<Wallet>>
getWallets() = 0;
433 #endif // BITCOIN_INTERFACES_WALLET_H
virtual bool isLocked()=0
Return whether wallet is locked.
An input of a transaction.
virtual wallet::WalletContext * context()
Return pointer to internal context, useful for testing.
virtual WalletTx getWalletTx(const uint256 &txid)=0
Get transaction information.
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
std::function< void(const std::string &title, int progress)> ShowProgressFn
Register handler for show progress messages.
std::underlying_type< isminetype >::type isminefilter
used for bitflags of isminetype
std::function< void()> UnloadFn
Register handler for unload message.
virtual bool hasExternalSigner()=0
virtual unsigned int getConfirmTarget()=0
Get tx confirm target.
virtual wallet::CWallet * wallet()
Return pointer to internal wallet class, useful for testing.
virtual CAmount getDebit(const CTxIn &txin, wallet::isminefilter filter)=0
Return debit amount if transaction input belongs to wallet.
virtual bool taprootEnabled()=0
virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
Sign message.
virtual bool setAddressReceiveRequest(const CTxDestination &dest, const std::string &id, const std::string &value)=0
Save or remove receive request.
virtual bool displayAddress(const CTxDestination &dest)=0
Display address on external signer.
virtual void listLockedCoins(std::vector< COutPoint > &outputs)=0
List locked coins.
std::function< void()> StatusChangedFn
Register handler for status changed messages.
CAmount unconfirmed_balance
bool balanceChanged(const WalletBalances &prev) const
virtual bool unlockCoin(const COutPoint &output)=0
Unlock coin.
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.
Wallet transaction output.
A reference to a CKey: the Hash160 of its serialized public key.
CAmount immature_watch_only_balance
virtual CAmount getMinimumFee(unsigned int tx_bytes, const wallet::CCoinControl &coin_control, int *returned_target, FeeReason *reason)=0
Get minimum fee.
std::shared_ptr< const CTransaction > CTransactionRef
virtual std::vector< WalletTx > getWalletTxs()=0
Get list of all wallet transactions.
Fee rate in satoshis per kilobyte: CAmount / kB.
virtual CTransactionRef createTransaction(const std::vector< wallet::CRecipient > &recipients, const wallet::CCoinControl &coin_control, bool sign, int &change_pos, CAmount &fee, bilingual_str &fail_reason)=0
Create transaction.
virtual std::vector< std::string > getAddressReceiveRequests()=0
Get receive requests.
virtual bool unlock(const SecureString &wallet_passphrase)=0
Unlock wallet.
virtual std::unique_ptr< Handler > handleWatchOnlyChanged(WatchOnlyChangedFn fn)=0
std::vector< wallet::isminetype > txout_is_mine
virtual bool lockCoin(const COutPoint &output, const bool write_to_db)=0
Lock coin.
virtual bool commitBumpTransaction(const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)=0
Commit bump transaction.
CAmount watch_only_balance
virtual CAmount getBalance()=0
Get balance.
std::map< std::string, std::string > value_map
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
ChangeType
General change type (added, updated, removed).
Collection of wallet balances.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
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.
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
virtual CAmount getRequiredFee(unsigned int tx_bytes)=0
Get required fee.
An output of a transaction.
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
virtual CAmount getCredit(const CTxOut &txout, wallet::isminefilter filter)=0
Return credit amount if transaction input belongs to wallet.
virtual bool getAddress(const CTxDestination &dest, std::string *name, wallet::isminetype *is_mine, std::string *purpose)=0
Look up address in wallet, return whether exists.
virtual std::unique_ptr< Wallet > createWallet(const std::string &name, const SecureString &passphrase, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Create new wallet.
virtual std::unique_ptr< Handler > handleAddressBookChanged(AddressBookChangedFn fn)=0
virtual bool isLockedCoin(const COutPoint &output)=0
Return whether coin is locked.
virtual bool transactionCanBeBumped(const uint256 &txid)=0
Return whether transaction can be bumped.
virtual std::unique_ptr< Wallet > restoreWallet(const fs::path &backup_file, const std::string &wallet_name, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Restore backup wallet.
virtual bool tryGetBalances(WalletBalances &balances, uint256 &block_hash)=0
Get balances if possible without blocking.
std::function< void()> CanGetAddressesChangedFn
Register handler for keypool changed messages.
Wallet chain client that in addition to having chain client methods for starting up,...
std::function< void(const uint256 &txid, ChangeType status)> TransactionChangedFn
Register handler for transaction changed messages.
int64_t CAmount
Amount in satoshis (Can be negative)
virtual std::string getWalletDir()=0
Return default wallet directory.
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual bool canGetAddresses()=0
virtual bool backupWallet(const std::string &filename)=0
Back up wallet.
std::vector< wallet::isminetype > txin_is_mine
virtual std::unique_ptr< Handler > handleStatusChanged(StatusChangedFn fn)=0
virtual WalletTx getWalletTxDetails(const uint256 &txid, WalletTxStatus &tx_status, WalletOrderForm &order_form, bool &in_mempool, int &num_blocks)=0
Get transaction details.
virtual std::vector< std::string > listWalletDir()=0
Return available wallets in wallet directory.
virtual WalletBalances getBalances()=0
Get balances.
Updated transaction status.
virtual bool delAddressBook(const CTxDestination &dest)=0
Interface for accessing a wallet.
virtual bool getNewDestination(const OutputType type, const std::string label, CTxDestination &dest)=0
Serialized script, used inside transaction inputs and outputs.
std::vector< std::pair< std::string, std::string > > WalletOrderForm
WalletAddress(CTxDestination dest, wallet::isminetype is_mine, std::string name, std::string purpose)
virtual CAmount getDefaultMaxTxFee()=0
Get max tx fee.
std::function< void(bool have_watch_only)> WatchOnlyChangedFn
Register handler for watchonly changed messages.
virtual std::string getWalletName()=0
Get wallet name.
virtual bool encryptWallet(const SecureString &wallet_passphrase)=0
Encrypt wallet.
std::map< CTxDestination, std::vector< std::tuple< COutPoint, WalletTxOut > >> CoinsList
Return AvailableCoins + LockedCoins grouped by wallet address.
virtual OutputType getDefaultAddressType()=0
An encapsulated public key.
Interface to let node manage chain clients (wallets, or maybe tools for monitoring and analysis in th...
std::function< void(std::unique_ptr< Wallet > wallet)> LoadWalletFn
Register handler for load wallet messages.
virtual std::unique_ptr< Handler > handleUnload(UnloadFn fn)=0
virtual CoinsList listCoins()=0
virtual std::vector< WalletAddress > getAddresses()=0
Get wallet address list.
virtual bool haveWatchOnly()=0
Return whether wallet has watch only keys.
An encapsulated private key.
virtual bool hdEnabled()=0
A version of CTransaction with the PSBT format.
std::map< std::string, std::string > WalletValueMap
virtual void abortRescan()=0
Abort a rescan.
virtual bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key)=0
Get public key.
virtual bool signBumpTransaction(CMutableTransaction &mtx)=0
Sign bump transaction.
std::vector< CTxDestination > txout_address
virtual bool changeWalletPassphrase(const SecureString &old_wallet_passphrase, const SecureString &new_wallet_passphrase)=0
Change wallet passphrase.
virtual bool transactionCanBeAbandoned(const uint256 &txid)=0
Return whether transaction can be abandoned.
virtual std::unique_ptr< Wallet > loadWallet(const std::string &name, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Load existing wallet.
CAmount unconfirmed_watch_only_balance
virtual wallet::isminetype txoutIsMine(const CTxOut &txout)=0
Return whether transaction output belongs to wallet.
std::vector< wallet::isminetype > txout_address_is_mine
virtual wallet::isminetype txinIsMine(const CTxIn &txin)=0
Return whether transaction input belongs to wallet.
An outpoint - a combination of a transaction hash and an index n into its vout.
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::string &purpose)=0
Add or update address.
wallet::isminetype is_mine
std::unique_ptr< Wallet > MakeWallet(wallet::WalletContext &context, const std::shared_ptr< wallet::CWallet > &wallet)
Return implementation of Wallet interface.
unsigned int time_received
virtual CTransactionRef getTx(const uint256 &txid)=0
Get a transaction.
WalletContext struct containing references to state shared between CWallet instances,...
virtual bool isSpendable(const CTxDestination &dest)=0
Return whether wallet has private key.
bool error(const char *fmt, const Args &... args)
virtual bool abandonTransaction(const uint256 &txid)=0
Abandon transaction.
A mutable version of CTransaction.
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
virtual bool isCrypted()=0
Return whether wallet is encrypted.
virtual TransactionError fillPSBT(int sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
virtual bool privateKeysDisabled()=0
virtual std::unique_ptr< Handler > handleCanGetAddressesChanged(CanGetAddressesChangedFn fn)=0
virtual std::vector< WalletTxOut > getCoins(const std::vector< COutPoint > &outputs)=0
Return wallet transaction output information.
virtual bool lock()=0
Lock wallet.
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
virtual bool isLegacy()=0
Return whether is a legacy wallet.
Information about one wallet address.
std::function< void(const CTxDestination &address, const std::string &label, bool is_mine, const std::string &purpose, ChangeType status)> AddressBookChangedFn
Register handler for address book changed messages.
virtual CAmount getAvailableBalance(const wallet::CCoinControl &coin_control)=0
Get available balance.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).