5#ifndef BITCOIN_INTERFACES_WALLET_H
6#define BITCOIN_INTERFACES_WALLET_H
110 std::string &str_sig) = 0;
120 const std::string &
name,
121 const std::string &purpose) = 0;
128 isminetype *is_mine, std::string *purpose) = 0;
135 const std::string &value) = 0;
139 const std::string &key) = 0;
142 virtual std::vector<std::string>
146 virtual void lockCoin(
const COutPoint &output) = 0;
161 int &change_pos,
Amount &fee) = 0;
185 int &num_blocks, int64_t &block_time) = 0;
191 bool &in_mempool,
int &num_blocks) = 0;
194 virtual std::optional<common::PSBTError>
226 std::vector<std::tuple<COutPoint, WalletTxOut>>>;
230 virtual std::vector<WalletTxOut>
231 getCoins(
const std::vector<COutPoint> &outputs) = 0;
267 std::function<void(
const std::string &title,
int progress)>;
272 virtual std::unique_ptr<Handler>
277 const CTxDestination &address,
const std::string &label,
bool is_mine,
278 const std::string &purpose,
ChangeType status)>;
279 virtual std::unique_ptr<Handler>
285 virtual std::unique_ptr<Handler>
290 virtual std::unique_ptr<Handler>
295 virtual std::unique_ptr<Handler>
310 uint64_t wallet_creation_flags,
311 std::vector<bilingual_str> &warnings) = 0;
316 std::vector<bilingual_str> &warnings) = 0;
324 std::vector<bilingual_str> &warnings) = 0;
330 virtual std::vector<std::unique_ptr<Wallet>>
getWallets() = 0;
350 std::string nameIn, std::string purposeIn)
415 const std::shared_ptr<CWallet> &
wallet);
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
An encapsulated secp256k1 private key.
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
An encapsulated public key.
CTransaction()
Construct a CTransaction that qualifies as IsNull()
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Signature hash type wrapper class.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Interface to let node manage chain clients (wallets, or maybe tools for monitoring and analysis in th...
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Wallet chain client that in addition to having chain client methods for starting up,...
virtual WalletContext * context()
Return pointer to internal context, useful for testing.
virtual std::vector< std::string > listWalletDir()=0
Return available wallets in wallet directory.
virtual util::Result< std::unique_ptr< Wallet > > restoreWallet(const fs::path &backup_file, const std::string &wallet_name, std::vector< bilingual_str > &warnings)=0
Restore backup wallet.
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
virtual std::string getWalletDir()=0
Return default wallet directory.
std::function< void(std::unique_ptr< Wallet > wallet)> LoadWalletFn
Register handler for load wallet messages.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
virtual util::Result< std::unique_ptr< Wallet > > loadWallet(const std::string &name, std::vector< bilingual_str > &warnings)=0
Load existing wallet.
virtual util::Result< std::unique_ptr< Wallet > > createWallet(const std::string &name, const SecureString &passphrase, uint64_t wallet_creation_flags, std::vector< bilingual_str > &warnings)=0
Create new wallet.
Interface for accessing a wallet.
std::function< void(const TxId &txid, ChangeType status)> TransactionChangedFn
Register handler for transaction changed messages.
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual CoinsList listCoins()=0
virtual bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key)=0
Get public key.
virtual std::vector< WalletAddress > getAddresses()=0
Get wallet address list.
virtual bool encryptWallet(const SecureString &wallet_passphrase)=0
Encrypt wallet.
std::function< void(bool have_watch_only)> WatchOnlyChangedFn
Register handler for watchonly changed messages.
virtual bool isLegacy()=0
Return whether is a legacy wallet.
virtual std::unique_ptr< Handler > handleStatusChanged(StatusChangedFn fn)=0
virtual util::Result< CTransactionRef > createTransaction(const std::vector< CRecipient > &recipients, const CCoinControl &coin_control, bool sign, int &change_pos, Amount &fee)=0
Create transaction.
virtual std::vector< WalletTx > getWalletTxs()=0
Get list of all wallet transactions.
virtual bool canGetAddresses() const =0
virtual Amount getAvailableBalance(const CCoinControl &coin_control)=0
Get available balance.
virtual std::vector< WalletTxOut > getCoins(const std::vector< COutPoint > &outputs)=0
Return wallet transaction output information.
virtual bool transactionCanBeAbandoned(const TxId &txid)=0
Return whether transaction can be abandoned.
std::function< void()> UnloadFn
Register handler for unload message.
virtual bool isLocked()=0
Return whether wallet is locked.
virtual std::unique_ptr< Handler > handleAddressBookChanged(AddressBookChangedFn fn)=0
virtual WalletTx getWalletTxDetails(const TxId &txid, WalletTxStatus &tx_status, WalletOrderForm &order_form, bool &in_mempool, int &num_blocks)=0
Get transaction details.
virtual std::unique_ptr< Handler > handleCanGetAddressesChanged(CanGetAddressesChangedFn fn)=0
virtual WalletTx getWalletTx(const TxId &txid)=0
Get transaction information.
virtual CWallet * wallet()
Return pointer to internal wallet class, useful for testing.
virtual void unlockCoin(const COutPoint &output)=0
Unlock coin.
virtual std::optional< common::PSBTError > fillPSBT(SigHashType sighash_type, bool sign, bool bip32derivs, PartiallySignedTransaction &psbtx, bool &complete) const =0
Fill PSBT.
virtual util::Result< CTxDestination > getNewDestination(const OutputType type, const std::string &label)=0
virtual isminetype txinIsMine(const CTxIn &txin)=0
Return whether transaction input belongs to wallet.
virtual bool addDestData(const CTxDestination &dest, const std::string &key, const std::string &value)=0
Add dest data.
virtual void abortRescan()=0
Abort a rescan.
virtual bool unlock(const SecureString &wallet_passphrase)=0
Unlock wallet.
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 bool changeWalletPassphrase(const SecureString &old_wallet_passphrase, const SecureString &new_wallet_passphrase)=0
Change wallet passphrase.
virtual const CChainParams & getChainParams()=0
Get chainparams.
virtual std::string getWalletName()=0
Get wallet name.
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::string &purpose)=0
Add or update address.
std::function< void(const std::string &title, int progress)> ShowProgressFn
Register handler for show progress messages.
virtual bool isSpendable(const CTxDestination &dest)=0
Return whether wallet has private key.
virtual std::vector< std::string > getDestValues(const std::string &prefix)=0
Get dest values with prefix.
virtual bool hdEnabled()=0
virtual bool isLockedCoin(const COutPoint &output)=0
Return whether coin is locked.
std::map< CTxDestination, std::vector< std::tuple< COutPoint, WalletTxOut > > > CoinsList
Return AvailableCoins + LockedCoins grouped by wallet address.
virtual WalletBalances getBalances()=0
Get balances.
virtual OutputType getDefaultAddressType()=0
virtual bool tryGetBalances(WalletBalances &balances, BlockHash &block_hash)=0
Get balances if possible without blocking.
virtual Amount getDebit(const CTxIn &txin, isminefilter filter)=0
Return debit amount if transaction input belongs to wallet.
virtual bool backupWallet(const std::string &filename)=0
Back up wallet.
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
virtual void listLockedCoins(std::vector< COutPoint > &outputs)=0
List locked coins.
virtual CTransactionRef getTx(const TxId &txid)=0
Get a transaction.
virtual bool abandonTransaction(const TxId &txid)=0
Abandon transaction.
virtual Amount getBalance()=0
Get balance.
virtual std::unique_ptr< Handler > handleUnload(UnloadFn fn)=0
virtual ~Wallet()=default
virtual bool eraseDestData(const CTxDestination &dest, const std::string &key)=0
Erase dest data.
virtual bool delAddressBook(const CTxDestination &dest)=0
std::function< void()> StatusChangedFn
Register handler for status changed messages.
virtual bool haveWatchOnly()=0
Return whether wallet has watch only keys.
virtual isminetype txoutIsMine(const CTxOut &txout)=0
Return whether transaction output belongs to wallet.
virtual bool tryGetTxStatus(const TxId &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.
virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
Sign message.
virtual bool privateKeysDisabled()=0
virtual bool getAddress(const CTxDestination &dest, std::string *name, isminetype *is_mine, std::string *purpose)=0
Look up address in wallet, return whether exists.
virtual Amount getCredit(const CTxOut &txout, isminefilter filter)=0
Return credit amount if transaction input belongs to wallet.
virtual bool lock()=0
Lock wallet.
virtual std::unique_ptr< Handler > handleWatchOnlyChanged(WatchOnlyChangedFn fn)=0
virtual void lockCoin(const COutPoint &output)=0
Lock coin.
virtual Amount getMinimumFee(unsigned int tx_bytes, const CCoinControl &coin_control)=0
Get minimum fee.
std::function< void()> CanGetAddressesChangedFn
Register handler for keypool changed messages.
virtual bool isCrypted()=0
Return whether wallet is encrypted.
virtual Amount getDefaultMaxTxFee()=0
Get max tx fee.
virtual Amount getRequiredFee(unsigned int tx_bytes)=0
Get required fee.
isminetype
IsMine() return codes.
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
std::vector< std::pair< std::string, std::string > > WalletOrderForm
std::unique_ptr< WalletClient > MakeWalletClient(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet client.
std::map< std::string, std::string > WalletValueMap
Implement std::hash so RCUPtr can be used as a key for maps or sets.
std::shared_ptr< const CTransaction > CTransactionRef
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
A version of CTransaction with the PSBT format.
A TxId is the identifier of a transaction.
WalletContext struct containing references to state shared between CWallet instances,...
Information about one wallet address.
WalletAddress(CTxDestination destIn, isminetype isMineIn, std::string nameIn, std::string purposeIn)
Collection of wallet balances.
Amount immature_watch_only_balance
Amount unconfirmed_watch_only_balance
Amount unconfirmed_balance
Amount watch_only_balance
bool balanceChanged(const WalletBalances &prev) const
std::vector< CTxDestination > txout_address
std::vector< isminetype > txout_is_mine
std::map< std::string, std::string > value_map
std::vector< isminetype > txout_address_is_mine
std::vector< isminetype > txin_is_mine
Wallet transaction output.
Updated transaction status.
unsigned int time_received
ChangeType
General change type (added, updated, removed).