5 #ifndef BITCOIN_INTERFACES_WALLET_H 6 #define BITCOIN_INTERFACES_WALLET_H 26 #include <type_traits> 43 struct CreatedTransactionResult;
55 struct WalletBalances;
58 struct WalletTxStatus;
59 struct WalletMigrationResult;
77 virtual bool lock() = 0;
93 virtual bool backupWallet(
const std::string& filename) = 0;
149 std::optional<unsigned int> change_pos) = 0;
168 std::vector<bilingual_str>& errors,
179 std::vector<bilingual_str>& errors,
180 Txid& bumped_txid) = 0;
195 int64_t& block_time) = 0;
202 int& num_blocks) = 0;
205 virtual std::optional<common::PSBTError>
fillPSBT(std::optional<int> sighash_type,
238 using CoinsList = std::map<CTxDestination, std::vector<std::tuple<COutPoint, WalletTxOut>>>;
242 virtual std::vector<WalletTxOut>
getCoins(
const std::vector<COutPoint>& outputs) = 0;
250 int* returned_target,
278 virtual void remove() = 0;
285 using ShowProgressFn = std::function<void(const std::string& title, int progress)>;
294 const std::string& label,
334 virtual bool isEncrypted(
const std::string& wallet_name) = 0;
337 virtual std::vector<std::pair<std::string, std::string>>
listWalletDir() = 0;
340 virtual std::vector<std::unique_ptr<Wallet>>
getWallets() = 0;
441 #endif // BITCOIN_INTERFACES_WALLET_H std::shared_ptr< const CTransaction > CTransactionRef
virtual bool isCrypted()=0
Return whether wallet is encrypted.
virtual bool privateKeysDisabled()=0
virtual bool 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 CoinsList listCoins()=0
std::function< void(const CTxDestination &address, const std::string &label, bool is_mine, wallet::AddressPurpose purpose, ChangeType status)> AddressBookChangedFn
Register handler for address book changed messages.
virtual bool canGetAddresses()=0
std::vector< CTxDestination > txout_address
virtual bool isLocked()=0
Return whether wallet is locked.
virtual OutputType getDefaultAddressType()=0
unsigned int time_received
virtual bool txinIsMine(const CTxIn &txin)=0
Return whether transaction input belongs to wallet.
virtual util::Result< std::unique_ptr< Wallet > > loadWallet(const std::string &name, std::vector< bilingual_str > &warnings)=0
Load existing wallet.
virtual std::unique_ptr< Handler > handleAddressBookChanged(AddressBookChangedFn fn)=0
virtual bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key)=0
Get public key.
std::vector< bool > txout_is_mine
virtual CAmount getDefaultMaxTxFee()=0
Get max tx fee.
std::function< void()> UnloadFn
Register handler for unload message.
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
virtual std::optional< common::PSBTError > fillPSBT(std::optional< int > sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
virtual bool backupWallet(const std::string &filename)=0
Back up wallet.
virtual util::Result< void > displayAddress(const CTxDestination &dest)=0
Display address on external signer.
std::function< void()> CanGetAddressesChangedFn
Register handler for keypool changed messages.
std::unique_ptr< Wallet > MakeWallet(wallet::WalletContext &context, const std::shared_ptr< wallet::CWallet > &wallet)
Return implementation of Wallet interface.
virtual WalletTx getWalletTxDetails(const Txid &txid, WalletTxStatus &tx_status, WalletOrderForm &order_form, bool &in_mempool, int &num_blocks)=0
Get transaction details.
A version of CTransaction with the PSBT format.
std::function< void(const Txid &txid, ChangeType status)> TransactionChangedFn
Register handler for transaction changed messages.
wallet::AddressPurpose purpose
std::map< std::string, std::string > WalletValueMap
virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
Sign message.
virtual util::Result< wallet::CreatedTransactionResult > createTransaction(const std::vector< wallet::CRecipient > &recipients, const wallet::CCoinControl &coin_control, bool sign, std::optional< unsigned int > change_pos)=0
Create transaction.
virtual bool changeWalletPassphrase(const SecureString &old_wallet_passphrase, const SecureString &new_wallet_passphrase)=0
Change wallet passphrase.
virtual bool isSpendable(const CTxDestination &dest)=0
Return whether wallet has private key.
std::function< void()> StatusChangedFn
Register handler for status changed messages.
virtual bool hasExternalSigner()=0
int64_t CAmount
Amount in satoshis (Can be negative)
std::map< CTxDestination, std::vector< std::tuple< COutPoint, WalletTxOut > >> CoinsList
Return AvailableCoins + LockedCoins grouped by wallet address.
std::vector< bool > txout_is_change
virtual std::unique_ptr< Handler > handleUnload(UnloadFn fn)=0
std::optional< std::string > watchonly_wallet_name
virtual wallet::WalletContext * context()
Return pointer to internal context, useful for testing.
AddressPurpose
Address purpose field that has been been stored with wallet sending and receiving addresses since BIP...
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
virtual std::vector< std::pair< std::string, std::string > > listWalletDir()=0
Return available wallets in wallet directory.
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.
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
virtual bool hdEnabled()=0
std::optional< std::string > solvables_wallet_name
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual bool lockCoin(const COutPoint &output, bool write_to_db)=0
Lock coin.
virtual std::unique_ptr< Handler > handleCanGetAddressesChanged(CanGetAddressesChangedFn fn)=0
virtual std::unique_ptr< Handler > handleStatusChanged(StatusChangedFn fn)=0
Collection of wallet balances.
virtual bool unlockCoin(const COutPoint &output)=0
Unlock coin.
An input of a transaction.
virtual bool setAddressReceiveRequest(const CTxDestination &dest, const std::string &id, const std::string &value)=0
Save or remove receive request.
virtual bool getAddress(const CTxDestination &dest, std::string *name, wallet::AddressPurpose *purpose)=0
Look up address in wallet, return whether exists.
An encapsulated public key.
Interface for accessing a wallet.
virtual bool encryptWallet(const SecureString &wallet_passphrase)=0
Encrypt wallet.
virtual ~Wallet()=default
std::unique_ptr< Wallet > wallet
virtual bool isEncrypted(const std::string &wallet_name)=0
Returns true if wallet stores encryption keys.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
WalletAddress(CTxDestination dest, bool is_mine, wallet::AddressPurpose purpose, std::string name)
An output of a transaction.
virtual CTransactionRef getTx(const Txid &txid)=0
Get a transaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
Wallet chain client that in addition to having chain client methods for starting up, shutting down, and registering RPCs, also has additional methods (called by the GUI) to load and create wallets.
virtual wallet::CWallet * wallet()
Return pointer to internal wallet class, useful for testing.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
virtual std::vector< WalletTxOut > getCoins(const std::vector< COutPoint > &outputs)=0
Return wallet transaction output information.
virtual CAmount getAvailableBalance(const wallet::CCoinControl &coin_control)=0
Get available balance.
static int sign(const secp256k1_context *ctx, struct signer_secrets *signer_secrets, struct signer *signer, const secp256k1_musig_keyagg_cache *cache, const unsigned char *msg32, unsigned char *sig64)
virtual std::set< WalletTx > getWalletTxs()=0
Get list of all wallet transactions.
CAmount unconfirmed_balance
virtual CAmount getDebit(const CTxIn &txin)=0
Return debit amount if transaction input belongs to wallet.
virtual bool taprootEnabled()=0
virtual bool signBumpTransaction(CMutableTransaction &mtx)=0
Sign bump transaction.
virtual bool delAddressBook(const CTxDestination &dest)=0
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...
virtual void listLockedCoins(std::vector< COutPoint > &outputs)=0
List locked coins.
std::vector< bool > txin_is_mine
Serialized script, used inside transaction inputs and outputs.
std::vector< bool > txout_address_is_mine
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
virtual bool tryGetBalances(WalletBalances &balances, uint256 &block_hash)=0
Get balances if possible without blocking.
A reference to a CKey: the Hash160 of its serialized public key.
virtual std::string getWalletDir()=0
Return default wallet directory.
std::function< void(const std::string &title, int progress)> ShowProgressFn
Register handler for show progress messages.
virtual util::Result< CTxDestination > getNewDestination(OutputType type, const std::string &label)=0
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
virtual bool isLockedCoin(const COutPoint &output)=0
Return whether coin is locked.
std::vector< std::pair< std::string, std::string > > WalletOrderForm
Information about one wallet address.
virtual bool lock()=0
Lock wallet.
A mutable version of CTransaction.
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::optional< wallet::AddressPurpose > &purpose)=0
Add or update address.
virtual unsigned int getConfirmTarget()=0
Get tx confirm target.
virtual CAmount getBalance()=0
Get balance.
virtual std::vector< std::string > getAddressReceiveRequests()=0
Get receive requests.
std::map< std::string, std::string > value_map
virtual bool transactionCanBeAbandoned(const Txid &txid)=0
Return whether transaction can be abandoned.
bool operator<(const WalletTx &a) const
An encapsulated private key.
virtual void abortRescan()=0
Abort a rescan.
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
virtual WalletBalances getBalances()=0
Get balances.
virtual bool abandonTransaction(const Txid &txid)=0
Abandon transaction.
virtual CAmount getCredit(const CTxOut &txout)=0
Return credit amount if transaction input belongs to wallet.
ChangeType
General change type (added, updated, removed).
virtual util::Result< std::unique_ptr< Wallet > > restoreWallet(const fs::path &backup_file, const std::string &wallet_name, std::vector< bilingual_str > &warnings, bool load_after_restore)=0
Restore backup wallet.
Wallet transaction output.
virtual WalletTx getWalletTx(const Txid &txid)=0
Get transaction information.
virtual CAmount getRequiredFee(unsigned int tx_bytes)=0
Get required fee.
bool balanceChanged(const WalletBalances &prev) const
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
virtual std::string getWalletName()=0
Get wallet name.
Updated transaction status.
virtual CAmount getMinimumFee(unsigned int tx_bytes, const wallet::CCoinControl &coin_control, int *returned_target, FeeReason *reason)=0
Get minimum fee.
virtual bool createBumpTransaction(const Txid &txid, const wallet::CCoinControl &coin_control, std::vector< bilingual_str > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)=0
Create bump transaction.
std::function< void(std::unique_ptr< Wallet > wallet)> LoadWalletFn
Register handler for load wallet messages.
virtual bool commitBumpTransaction(const Txid &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, Txid &bumped_txid)=0
Commit bump transaction.
virtual bool transactionCanBeBumped(const Txid &txid)=0
Return whether transaction can be bumped.
virtual bool unlock(const SecureString &wallet_passphrase)=0
Unlock wallet.
virtual std::vector< WalletAddress > getAddresses()=0
Get wallet address list.
virtual util::Result< WalletMigrationResult > migrateWallet(const std::string &name, const SecureString &passphrase)=0
Migrate a wallet.