![]() |
Bitcoin Core 32.99.0
P2P Digital Currency
|
A CWallet maintains a set of transactions and balances, and provides the ability to create new transactions. More...
#include <wallet.h>
Classes | |
| struct | AddrBookFilter |
Public Types | |
| enum class | SpendType { UNSPENT , CONFIRMED , MEMPOOL , NONMEMPOOL } |
| enum class | HDKeyFilter { Active , All , UnusedKey } |
| Which descriptors GetHDPubKeys() should consider. More... | |
| typedef std::map< unsigned int, CMasterKey > | MasterKeyMap |
| typedef std::multimap< int64_t, CWalletTx * > | TxItems |
| using | UpdateWalletTxFn = std::function< bool(CWalletTx &wtx, bool new_tx)> |
| Callback for updating transaction metadata in mapWallet. More... | |
| using | ListAddrBookFunc = std::function< void(const CTxDestination &dest, const std::string &label, bool is_change, const std::optional< AddressPurpose > purpose)> |
| Walk-through the address book entries. More... | |
| using | HDPubKeyMap = std::map< CExtPubKey, std::set< DescriptorScriptPubKeyMan * > > |
Public Member Functions | |
| WalletDatabase & | GetDatabase () const override |
| const std::string & | GetName () const |
| Get a name for this wallet for logging/debugging purposes. More... | |
| CWallet (interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > database) | |
| Construct wallet with specified name and database implementation. More... | |
| ~CWallet () | |
| bool | IsLocked () const override |
| bool | Lock () |
| bool | HaveChain () const |
| Interface to assert chain access. More... | |
| std::unordered_map< Txid, CWalletTx, SaltedTxidHasher > mapWallet | GUARDED_BY (cs_wallet) |
| Map from txid to CWalletTx for all transactions this wallet is interested in, including received and sent transactions. More... | |
| int64_t nOrderPosNext | GUARDED_BY (cs_wallet)=0 |
| std::map< CTxDestination, CAddressBookData > m_address_book | GUARDED_BY (cs_wallet) |
| const CAddressBookData * | FindAddressBookEntry (const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| std::map< COutPoint, bool > m_locked_coins | GUARDED_BY (cs_wallet) |
| Set of Coins owned by this wallet that we won't try to spend from. More... | |
| interfaces::Chain & | chain () const |
| Interface for accessing chain state. More... | |
| const CWalletTx * | GetWalletTx (const Txid &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| std::set< Txid > | GetTxConflicts (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| const std::unordered_map< COutPoint, WalletTXO, SaltedOutpointHasher > & | GetTXOs () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| std::optional< WalletTXO > | GetTXO (const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | RefreshTXOsFromTx (const CWalletTx &wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Cache outputs that belong to the wallet from a single transaction. More... | |
| void | RefreshAllTXOs () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Cache outputs that belong to the wallet for all transactions in the wallet. More... | |
| int | GetTxDepthInMainChain (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockchain 0 : in memory pool, waiting to be included in a block >=1 : this many blocks deep in the main chain. More... | |
| int | GetTxBlocksToMaturity (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | IsTxImmatureCoinBase (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| SpendType | HowSpent (const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | IsSpent (const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Outpoint is spent if any non-conflicted transaction spends it: More... | |
| bool | IsSpentKey (const CScript &scriptPubKey) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | SetSpentKeyState (WalletBatch &batch, const Txid &hash, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| util::Result< void > | DisplayAddress (const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Display address on an external signer. More... | |
| bool | IsLockedCoin (const COutPoint &output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | LoadLockedCoin (const COutPoint &coin, bool persistent) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | LockCoin (const COutPoint &output, bool persist) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | UnlockCoin (const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | UnlockAllCoins () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | ListLockedCoins (std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| ChainScanner & | Scanner () |
| const ChainScanner & | Scanner () const |
| void | UpgradeDescriptorCache () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Upgrade DescriptorCaches. More... | |
| void | LoadAddressPreviouslySpent (const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Marks destination as previously spent. More... | |
| void | LoadAddressReceiveRequest (const CTxDestination &dest, const std::string &id, const std::string &request) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Appends payment request to destination. More... | |
| int64_t nRelockTime | GUARDED_BY (cs_wallet) |
| Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock(). More... | |
| util::Expected< void, WalletError > | Unlock (const SecureString &strWalletPassphrase) |
| util::Expected< void, WalletError > | ChangeWalletPassphrase (const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase) |
| bool | EncryptWallet (const SecureString &strWalletPassphrase) |
| unsigned int | ComputeTimeSmart (const CWalletTx &wtx, bool rescanning_old_block) const |
| Compute smart timestamp for a transaction being added to the wallet. More... | |
| int64_t | IncOrderPosNext (WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Increment the next transaction order id. More... | |
| DBErrors | ReorderTransactions () |
| void | MarkDirty () |
| CWalletTx * | AddToWallet (CTransactionRef tx, const TxState &state, const UpdateWalletTxFn &update_wtx=nullptr, bool rescanning_old_block=false) |
| Add the transaction to the wallet, wrapping it up inside a CWalletTx. More... | |
| bool | AddToWalletIfInvolvingMe (const CTransactionRef &tx, const SyncTxState &state, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Add a transaction to the wallet, or update it. More... | |
| bool | LoadToWallet (CWalletTx &&wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | transactionAddedToMempool (const CTransactionRef &tx) override |
| void | blockConnected (const kernel::ChainstateRole &role, const interfaces::BlockInfo &block) override |
| void | blockDisconnected (const interfaces::BlockInfo &block) override |
| void | updatedBlockTip () override |
| void | transactionRemovedFromMempool (const CTransactionRef &tx, MemPoolRemovalReason reason) override |
| void | SetNextResend () |
| Set the next time this wallet should resend transactions to 12-36 hours from now, ~1 day on average. More... | |
| bool | ShouldResend () const |
| Return true if all conditions for periodically resending transactions are met. More... | |
| void | ResubmitWalletTransactions (node::TxBroadcast broadcast_method, bool force) |
| OutputType | TransactionChangeType (const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const |
| bool | SignTransaction (CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Fetch the inputs and sign with SIGHASH_ALL. More... | |
| bool | SignTransaction (CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, bilingual_str > &input_errors) const |
| Sign the tx given the input coins and sighash. More... | |
| SigningResult | SignMessage (const std::string &message, const PKHash &pkhash, std::string &str_sig) const |
| std::optional< common::PSBTError > | FillPSBT (PartiallySignedTransaction &psbtx, const common::PSBTFillOptions &options, bool &complete, size_t *n_signed=nullptr) const |
| Fills out a PSBT with information from the wallet. More... | |
| void | CommitTransaction (CTransactionRef tx, std::optional< Txid > replaces_txid=std::nullopt, std::optional< std::string > comment=std::nullopt, std::optional< std::string > comment_to=std::nullopt, const std::vector< std::string > &messages={}, const std::vector< std::string > &payment_requests={}) |
| Submit the transaction to the node's mempool and then relay to peers. More... | |
| bool | SubmitTxMemoryPoolAndRelay (CWalletTx &wtx, std::string &err_string, node::TxBroadcast broadcast_method) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Pass this transaction to node for optional mempool insertion and relay to peers. More... | |
| void | MaybeUpdateBirthTime (int64_t time) |
| Updates wallet birth time if 'time' is below it. More... | |
| size_t | KeypoolCountExternalKeys () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | TopUpKeyPool (unsigned int kpSize=0) |
| std::vector< CTxDestination > | ListAddrBookAddresses (const std::optional< AddrBookFilter > &filter) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Filter and retrieve destinations stored in the addressbook. More... | |
| std::set< std::string > | ListAddrBookLabels (std::optional< AddressPurpose > purpose) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Retrieve all the known labels in the address book. More... | |
| void | ForEachAddrBookEntry (const ListAddrBookFunc &func) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | MarkDestinationsDirty (const std::set< CTxDestination > &destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Marks all outputs in each one of the destinations dirty, so their cache is reset and does not return outdated information. More... | |
| util::Result< CTxDestination > | GetNewDestination (OutputType type, const std::string &label) |
| util::Result< CTxDestination > | GetNewChangeDestination (OutputType type) |
| bool | IsMine (const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | IsMine (const CScript &script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| CAmount | GetDebit (const CTxIn &txin) const |
| Returns amount of debit, i.e. More... | |
| bool | IsMine (const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | IsMine (const CTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | IsMine (const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | IsFromMe (const CTransaction &tx) const |
| should probably be renamed to IsRelevantToMe More... | |
| CAmount | GetDebit (const CTransaction &tx) const |
| DBErrors | PopulateWalletFromDB (bilingual_str &error, std::vector< bilingual_str > &warnings) |
| util::Result< void > | RemoveTxs (std::vector< Txid > &txs_to_remove) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Erases the provided transactions from the wallet. More... | |
| util::Result< void > | RemoveTxs (WalletBatch &batch, std::vector< Txid > &txs_to_remove) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | SetAddressBook (const CTxDestination &address, const std::string &strName, const std::optional< AddressPurpose > &purpose) |
| bool | DelAddressBook (const CTxDestination &address) |
| bool | DelAddressBookWithDB (WalletBatch &batch, const CTxDestination &address) |
| bool | IsAddressPreviouslySpent (const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | SetAddressPreviouslySpent (WalletBatch &batch, const CTxDestination &dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| std::vector< std::string > | GetAddressReceiveRequests () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | SetAddressReceiveRequest (WalletBatch &batch, const CTxDestination &dest, const std::string &id, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | EraseAddressReceiveRequest (WalletBatch &batch, const CTxDestination &dest, const std::string &id) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| unsigned int | GetKeyPoolSize () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| std::set< Txid > | GetConflicts (const Txid &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Get wallet transactions that conflict with given transaction (spend same outputs) More... | |
| bool | HasWalletSpend (const CTransactionRef &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Check if a given transaction has any of its outputs spent by another transaction in the wallet. More... | |
| void | Close () |
| Close wallet database. More... | |
| bool | GetBroadcastTransactions () const |
| Inquire whether this wallet broadcasts transactions. More... | |
| void | SetBroadcastTransactions (bool broadcast) |
| Set whether this wallet broadcasts transactions. More... | |
| bool | TransactionCanBeAbandoned (const Txid &hashTx) const |
| Return whether transaction can be abandoned. More... | |
| bool | AbandonTransaction (const Txid &hashTx) |
| bool | AbandonTransaction (CWalletTx &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | MarkReplaced (const Txid &originalHash, const Txid &newHash) |
| Mark a transaction as replaced by another transaction. More... | |
| void | postInitProcess () |
| Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init tasks. More... | |
| bool | BackupWallet (const std::string &strDest) const |
| bool | IsHDEnabled () const |
| bool | CanGetAddresses (bool internal=false) const |
| int64_t | GetBirthTime () const |
| void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void | SetWalletFlag (uint64_t flags) |
| Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function is entered Obviously holding cs_main/cs_wallet when going into this call may cause deadlock. More... | |
| void | UnsetWalletFlag (uint64_t flag) |
| Unsets a single wallet flag. More... | |
| bool | IsWalletFlagSet (uint64_t flag) const override |
| check if a certain wallet flag is set More... | |
| void | InitWalletFlags (uint64_t flags) |
| overwrite all flags by the given uint64_t flags must be uninitialised (or 0) only known flags may be present More... | |
| bool | LoadWalletFlags (uint64_t flags) |
| Loads the flags into the wallet. More... | |
| uint64_t | GetWalletFlags () const |
| Retrieve all of the wallet's flags. More... | |
| std::string | LogName () const override |
| Return wallet name for use in logs, will return "default wallet" if the wallet has no name. More... | |
| std::string | DisplayName () const |
| Return wallet name for display, like LogName() but translates "default wallet" string. More... | |
| template<typename... Params> | |
| void | WalletLogPrintf (util::ConstevalFormatString< sizeof...(Params)> wallet_fmt, const Params &... params) const |
| Prepends the wallet name in logging output to ease debugging in multi-wallet use cases. More... | |
| void | LogStats () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| std::set< ScriptPubKeyMan * > | GetActiveScriptPubKeyMans () const |
| Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers. More... | |
| bool | IsActiveScriptPubKeyMan (const ScriptPubKeyMan &spkm) const |
| std::set< ScriptPubKeyMan * > | GetAllScriptPubKeyMans () const |
| Returns all unique ScriptPubKeyMans. More... | |
| ScriptPubKeyMan * | GetScriptPubKeyMan (const OutputType &type, bool internal) const |
| Get the ScriptPubKeyMan for the given OutputType and internal/external chain. More... | |
| std::set< ScriptPubKeyMan * > | GetScriptPubKeyMans (const CScript &script) const |
| Get all the ScriptPubKeyMans for a script. More... | |
| ScriptPubKeyMan * | GetScriptPubKeyMan (const uint256 &id) const |
| Get the ScriptPubKeyMan by id. More... | |
| std::unique_ptr< SigningProvider > | GetSolvingProvider (const CScript &script) const |
| Get the SigningProvider for a script. More... | |
| std::unique_ptr< SigningProvider > | GetSolvingProvider (const CScript &script, SignatureData &sigdata) const |
| std::vector< WalletDescriptor > | GetWalletDescriptors (const CScript &script) const |
| Get the wallet descriptors for a script. More... | |
| LegacyDataSPKM * | GetLegacyDataSPKM () const |
| Get the LegacyDataSPKM used for all legacy output types and both internal and external chains. More... | |
| LegacyDataSPKM * | GetOrCreateLegacyDataSPKM () |
| void | SetupLegacyDataSPKM () |
| Create a LegacyDataSPKM and set it for all legacy output types and both internal and external chains. More... | |
| bool | WithEncryptionKey (std::function< bool(const CKeyingMaterial &)> cb) const override |
| Pass the encryption key to cb(). More... | |
| bool | HasEncryptionKeys () const override |
| bool | HaveCryptedKeys () const |
| int | GetLastBlockHeight () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Get last block processed height. More... | |
| uint256 | GetLastBlockHash () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | SetLastBlockProcessed (int block_height, uint256 block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Set last block processed height, and write to database. More... | |
| void | WriteBestBlock () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Write the current best block to database. More... | |
| void | ConnectScriptPubKeyManNotifiers () |
| Connect the signals from ScriptPubKeyMans to the signals in CWallet. More... | |
| void | LoadDescriptorScriptPubKeyMan (uint256 id, WalletDescriptor &desc, const KeyMap &keys, const CryptedKeyMap &ckeys) |
| Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it. More... | |
| void | AddActiveScriptPubKeyMan (uint256 id, OutputType type, bool internal) |
| Adds the active ScriptPubKeyMan for the specified type and internal. More... | |
| void | LoadActiveScriptPubKeyMan (uint256 id, OutputType type, bool internal) |
| Loads an active ScriptPubKeyMan for the specified type and internal. More... | |
| void | DeactivateScriptPubKeyMan (uint256 id, OutputType type, bool internal) |
| Remove specified ScriptPubKeyMan from set of active SPK managers. More... | |
| DescriptorScriptPubKeyMan & | SetupDescriptorScriptPubKeyMan (WalletBatch &batch, const CExtKey &master_key, const OutputType &output_type, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Create new DescriptorScriptPubKeyMan and add it to the wallet. More... | |
| void | SetupDescriptorScriptPubKeyMans (WalletBatch &batch, const CExtKey &master_key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Create new DescriptorScriptPubKeyMans and add them to the wallet. More... | |
| void | SetupDescriptorScriptPubKeyMans () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | SetupOwnDescriptorScriptPubKeyMans (WalletBatch &batch) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Create new seed and default DescriptorScriptPubKeyMans for this wallet. More... | |
| void | SetupWalletGeneration () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Setup new descriptors or seed for new address generation. More... | |
| DescriptorScriptPubKeyMan * | GetDescriptorScriptPubKeyMan (const WalletDescriptor &desc) const |
| Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet. More... | |
| std::optional< bool > | IsInternalScriptPubKeyMan (ScriptPubKeyMan *spk_man) const |
| Returns whether the provided ScriptPubKeyMan is internal. More... | |
| util::Result< std::reference_wrapper< DescriptorScriptPubKeyMan > > | AddWalletDescriptor (WalletDescriptor &desc, const FlatSigningProvider &signing_provider, const std::string &label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type. More... | |
| util::Expected< CExtPubKey, WalletError > | AddHDKey (const std::optional< CExtKey > &key) |
| Add an HD key to the wallet and return its master xpub. More... | |
| bool | MigrateToSQLite (bilingual_str &error) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Move all records from the BDB database to a new SQLite database for storage. More... | |
| std::optional< MigrationData > | GetDescriptorsForLegacy (bilingual_str &error) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Get all of the descriptors from a legacy wallet. More... | |
| util::Result< void > | ApplyMigrationData (WalletBatch &local_wallet_batch, MigrationData &data) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Adds the ScriptPubKeyMans from MigrationData to this wallet, removes the LegacyDataSPKM, and moves transaction and address book entries to watchonly_wallet or solvable_wallet as needed. More... | |
| bool | CanGrindR () const |
| Whether the (external) signer performs R-value signature grinding. More... | |
| void | CacheNewScriptPubKeys (const std::set< CScript > &spks, ScriptPubKeyMan *spkm) |
| Add scriptPubKeys for this ScriptPubKeyMan into the scriptPubKey cache. More... | |
| void | TopUpCallback (const std::set< CScript > &spks, ScriptPubKeyMan *spkm) override |
| Callback function for after TopUp completes containing any scripts that were added by a SPKMan. More... | |
| HDPubKeyMap | GetHDPubKeys (HDKeyFilter filter) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Retrieve descriptor xpubs matching the requested filter. More... | |
| std::optional< CKey > | GetKey (const CKeyID &keyid) const |
| Find the private key for the given key id from the wallet's descriptors, if available Returns nullopt when no descriptor has the key or if the wallet is locked. More... | |
| std::optional< CExtKey > | GetExtKey (const CExtPubKey &xpub) const |
| Reconstruct the extended private key for an HD xpub. More... | |
| void | DisconnectChainNotifications () |
| Disconnect chain notifications and wait for all notifications to be processed. More... | |
Public Member Functions inherited from wallet::WalletStorage | |
| virtual | ~WalletStorage ()=default |
| virtual std::string | LogName () const =0 |
| virtual WalletDatabase & | GetDatabase () const =0 |
| virtual bool | IsWalletFlagSet (uint64_t) const =0 |
| virtual void | UnsetBlankWalletFlag (WalletBatch &)=0 |
| virtual bool | WithEncryptionKey (std::function< bool(const CKeyingMaterial &)> cb) const =0 |
| Pass the encryption key to cb(). More... | |
| virtual bool | HasEncryptionKeys () const =0 |
| virtual bool | IsLocked () const =0 |
| virtual void | TopUpCallback (const std::set< CScript > &, ScriptPubKeyMan *)=0 |
| Callback function for after TopUp completes containing any scripts that were added by a SPKMan. More... | |
Public Member Functions inherited from interfaces::Chain::Notifications | |
| virtual | ~Notifications ()=default |
| virtual void | transactionAddedToMempool (const CTransactionRef &tx) |
| virtual void | transactionRemovedFromMempool (const CTransactionRef &tx, MemPoolRemovalReason reason) |
| virtual void | blockConnected (const kernel::ChainstateRole &role, const BlockInfo &block) |
| virtual void | blockDisconnected (const BlockInfo &block) |
| virtual void | updatedBlockTip () |
| virtual void | chainStateFlushed (const kernel::ChainstateRole &role, const CBlockLocator &locator) |
Static Public Member Functions | |
| static bool | LoadWalletArgs (std::shared_ptr< CWallet > wallet, const WalletContext &context, bilingual_str &error, std::vector< bilingual_str > &warnings) |
| static std::shared_ptr< CWallet > | CreateNew (WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bool born_encrypted, bilingual_str &error, std::vector< bilingual_str > &warnings) |
| static std::shared_ptr< CWallet > | LoadExisting (WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, bilingual_str &error, std::vector< bilingual_str > &warnings) |
Public Attributes | |
| RecursiveMutex | cs_wallet |
| Main wallet lock. More... | |
| MasterKeyMap | mapMasterKeys |
| unsigned int | nMasterKeyMaxID = 0 |
| TxItems | wtxOrdered |
| std::unique_ptr< interfaces::Handler > | m_chain_notifications_handler |
| Registered interfaces::Chain::Notifications handler. More... | |
| Mutex | m_unlock_mutex |
| RecursiveMutex | m_relock_mutex |
| unsigned int | m_confirm_target {DEFAULT_TX_CONFIRM_TARGET} |
| bool | m_spend_zero_conf_change {DEFAULT_SPEND_ZEROCONF_CHANGE} |
| Allow Coin Selection to pick unconfirmed UTXOs that were sent from our own wallet if it cannot fund the transaction otherwise. More... | |
| bool | m_signal_rbf {DEFAULT_WALLET_RBF} |
| bool | m_allow_fallback_fee {true} |
| will be false if -fallbackfee=0 More... | |
| CFeeRate | m_min_fee {DEFAULT_TRANSACTION_MINFEE} |
| CFeeRate | m_fallback_fee {DEFAULT_FALLBACK_FEE} |
| If fee estimation does not have enough data to provide estimates, use this fee instead. More... | |
| CFeeRate | m_discard_rate {DEFAULT_DISCARD_FEE} |
| If the cost to spend a change output at this feerate is greater than the value of the output itself, just drop it to fees. More... | |
| CFeeRate | m_consolidate_feerate {DEFAULT_CONSOLIDATE_FEERATE} |
| When the actual feerate is less than the consolidate feerate, we will tend to make transactions which consolidate inputs. More... | |
| CAmount | m_max_aps_fee {DEFAULT_MAX_AVOIDPARTIALSPEND_FEE} |
| The maximum fee amount we're willing to pay to prioritize partial spend avoidance. More... | |
| OutputType | m_default_address_type {DEFAULT_ADDRESS_TYPE} |
| std::optional< OutputType > | m_default_change_type {} |
| Default output type for change outputs. More... | |
| CAmount | m_max_tx_fee {DEFAULT_TRANSACTION_MAXFEE} |
| Absolute maximum transaction fee (in satoshis) used by the wallet. More... | |
| CFeeRate | m_max_tx_fee_rate {DEFAULT_MAX_TRANSACTION_FEERATE} |
| Maximum transaction fee rate used for the wallet. More... | |
| int64_t | m_keypool_size {DEFAULT_KEYPOOL_SIZE} |
| Number of pre-generated keys/scripts by each spkm (part of the look-ahead process, used to detect payments) More... | |
| std::string | m_notify_tx_changed_script |
| Notify external script when a wallet transaction comes in or is updated (handled by -walletnotify) More... | |
| btcsignals::signal< void()> | NotifyUnload |
| Wallet is about to be unloaded. More... | |
| btcsignals::signal< void(const CTxDestination &address, const std::string &label, bool isMine, AddressPurpose purpose, ChangeType status)> | NotifyAddressBookChanged |
| Address book entry changed. More... | |
| btcsignals::signal< void(const Txid &hashTx, ChangeType status)> | NotifyTransactionChanged |
| Wallet transaction added, removed or updated. More... | |
| btcsignals::signal< void(const std::string &title, int nProgress)> | ShowProgress |
| Show progress e.g. More... | |
| btcsignals::signal< void()> | NotifyCanGetAddressesChanged |
| Keypool has new keys. More... | |
| btcsignals::signal< void(CWallet *wallet)> | NotifyStatusChanged |
| Wallet status (encrypted, locked) changed. More... | |
Private Types | |
| enum class | TxUpdate { UNCHANGED , CHANGED , NOTIFY_CHANGED } |
| typedef std::unordered_multimap< COutPoint, Txid, SaltedOutpointHasher > | TxSpends |
| Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated transactions where the mutant gets mined). More... | |
| using | TryUpdatingStateFn = std::function< TxUpdate(CWalletTx &wtx)> |
Private Member Functions | |
| CKeyingMaterial vMasterKey | GUARDED_BY (cs_wallet) |
| bool | Unlock (const CKeyingMaterial &vMasterKeyIn) |
| TxSpends mapTxSpends | GUARDED_BY (cs_wallet) |
| void | AddToSpends (const COutPoint &outpoint, const Txid &txid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | AddToSpends (const CWalletTx &wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | MarkConflicted (const uint256 &hashBlock, int conflicting_height, const Txid &hashTx) |
| Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. More... | |
| void | RecursiveUpdateTxState (const Txid &tx_hash, const TryUpdatingStateFn &try_updating_state) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Mark a transaction (and its in-wallet descendants) as a particular tx state. More... | |
| void | RecursiveUpdateTxState (WalletBatch *batch, const Txid &tx_hash, const TryUpdatingStateFn &try_updating_state) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | MarkInputsDirty (const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed. More... | |
| std::set< CWalletTx *, WalletTxOrderComparator > | GetMalleatedVariants (const CWalletTx &wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Collects all wallet txs that differ from wtx only in their scriptSigs (i.e. More... | |
| void | SyncMalleatedTxMetadata (WalletBatch &batch, const CWalletTx &wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | SyncTransaction (const CTransactionRef &tx, const SyncTxState &state, bool rescanning_old_block=false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| bool | SetAddressBookWithDB (WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::optional< AddressPurpose > &strPurpose) |
| void | UnsetWalletFlagWithDB (WalletBatch &batch, uint64_t flag) |
| Unsets a wallet flag and saves it to disk. More... | |
| void | UnsetBlankWalletFlag (WalletBatch &batch) override |
| Unset the blank wallet flag and saves it to disk. More... | |
| uint256 m_last_block_processed | GUARDED_BY (cs_wallet) |
| The following is used to keep track of how far behind the wallet is from the chain sync, and to allow clients to block on us being caught up. More... | |
| int m_last_block_processed_height | GUARDED_BY (cs_wallet) |
| Height of last block processed is used by wallet to know depth of transactions without relying on Chain interface beyond asynchronous updates. More... | |
| void | AddScriptPubKeyMan (const uint256 &id, std::unique_ptr< ScriptPubKeyMan > spkm_man) |
| void | AddActiveScriptPubKeyManWithDb (WalletBatch &batch, uint256 id, OutputType type, bool internal) |
| void | SetWalletFlagWithDB (WalletBatch &batch, uint64_t flags) |
| Store wallet flags. More... | |
| std::unordered_map< COutPoint, WalletTXO, SaltedOutpointHasher > m_txos | GUARDED_BY (cs_wallet) |
| Set of both spent and unspent transaction outputs owned by this wallet. More... | |
| void | SetLastBlockProcessedInMem (int block_height, uint256 block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| void | UpdateTrucSiblingConflicts (const CWalletTx &parent_wtx, const Txid &child_txid, bool add_conflict) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
| Update mempool conflicts for TRUC sibling transactions. More... | |
Static Private Member Functions | |
| static bool | AttachChain (const std::shared_ptr< CWallet > &wallet, interfaces::Chain &chain, bool rescan_required, bilingual_str &error, std::vector< bilingual_str > &warnings) |
| Catch wallet up to current chain, scanning new blocks, updating the best block locator and m_last_block_processed, and registering for notifications about new blocks and transactions. More... | |
| static NodeClock::time_point | GetDefaultNextResend () |
Private Attributes | |
| NodeClock::time_point | m_next_resend {GetDefaultNextResend()} |
| The next scheduled rebroadcast of wallet transactions. More... | |
| bool | fBroadcastTransactions = false |
| Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadcasts (see ResendWalletTransactions()). More... | |
| std::atomic< int64_t > | m_best_block_time {0} |
| std::atomic< int64_t > | m_birth_time {std::numeric_limits<int64_t>::max()} |
| std::atomic< uint64_t > | m_wallet_flags {0} |
| WalletFlags set on this wallet. More... | |
| interfaces::Chain * | m_chain |
| Interface for accessing chain state. More... | |
| std::string | m_name |
| Wallet name: relative directory name or "" for default wallet. More... | |
| std::unique_ptr< WalletDatabase > | m_database |
| Internal database handle. More... | |
| std::unique_ptr< ChainScanner > | m_scanner |
| std::map< OutputType, ScriptPubKeyMan * > | m_external_spk_managers |
| std::map< OutputType, ScriptPubKeyMan * > | m_internal_spk_managers |
| std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > | m_spk_managers |
| std::unordered_map< CScript, std::vector< ScriptPubKeyMan * >, SaltedSipHasher > | m_cached_spks |
| Cache of descriptor ScriptPubKeys used for IsMine. Maps ScriptPubKey to set of spkms. More... | |
Friends | |
| class | ChainScanner |
A CWallet maintains a set of transactions and balances, and provides the ability to create new transactions.
| using wallet::CWallet::HDPubKeyMap = std::map<CExtPubKey, std::set<DescriptorScriptPubKeyMan*> > |
| using wallet::CWallet::ListAddrBookFunc = std::function<void(const CTxDestination& dest, const std::string& label, bool is_change, const std::optional<AddressPurpose> purpose)> |
| typedef std::map<unsigned int, CMasterKey> wallet::CWallet::MasterKeyMap |
|
private |
| typedef std::multimap<int64_t, CWalletTx*> wallet::CWallet::TxItems |
|
private |
| using wallet::CWallet::UpdateWalletTxFn = std::function<bool(CWalletTx& wtx, bool new_tx)> |
Callback for updating transaction metadata in mapWallet.
| wtx | - reference to mapWallet transaction to update |
| new_tx | - true if wtx is newly inserted, false if it previously existed |
|
strong |
Which descriptors GetHDPubKeys() should consider.
| Enumerator | |
|---|---|
| Active | Only active descriptors. |
| All | All descriptors. |
| UnusedKey | Only unused(KEY) descriptors. |
|
strong |
|
strongprivate |
| wallet::CWallet::CWallet | ( | interfaces::Chain * | chain, |
| const std::string & | name, | ||
| std::unique_ptr< WalletDatabase > | database | ||
| ) |
Construct wallet with specified name and database implementation.
Definition at line 485 of file wallet.cpp.
| wallet::CWallet::~CWallet | ( | ) |
| void wallet::CWallet::AddActiveScriptPubKeyMan | ( | uint256 | id, |
| OutputType | type, | ||
| bool | internal | ||
| ) |
Adds the active ScriptPubKeyMan for the specified type and internal.
Writes it to the wallet file
| [in] | id | The unique id for the ScriptPubKeyMan |
| [in] | type | The OutputType this ScriptPubKeyMan provides addresses for |
| [in] | internal | Whether this ScriptPubKeyMan provides change addresses |
Definition at line 3530 of file wallet.cpp.
|
private |
Definition at line 3536 of file wallet.cpp.
| util::Expected< CExtPubKey, WalletError > wallet::CWallet::AddHDKey | ( | const std::optional< CExtKey > & | key | ) |
Add an HD key to the wallet and return its master xpub.
Requires the wallet to be unlocked. Returns a WalletError with code WalletErrorCode::UnlockNeeded if the wallet is locked.
| [in] | key | Optional extended private key to add. If not provided, a new random HD key will be generated. |
WalletError on failure. Definition at line 3668 of file wallet.cpp.
|
private |
Definition at line 3353 of file wallet.cpp.
| util::Result< std::reference_wrapper< DescriptorScriptPubKeyMan > > wallet::CWallet::AddWalletDescriptor | ( | WalletDescriptor & | desc, |
| const FlatSigningProvider & | signing_provider, | ||
| const std::string & | label, | ||
| bool | internal | ||
| ) |
Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type.
Definition at line 3614 of file wallet.cpp.
| util::Result< void > wallet::CWallet::ApplyMigrationData | ( | WalletBatch & | local_wallet_batch, |
| MigrationData & | data | ||
| ) |
Adds the ScriptPubKeyMans from MigrationData to this wallet, removes the LegacyDataSPKM, and moves transaction and address book entries to watchonly_wallet or solvable_wallet as needed.
Definition at line 3832 of file wallet.cpp.
|
staticprivate |
Catch wallet up to current chain, scanning new blocks, updating the best block locator and m_last_block_processed, and registering for notifications about new blocks and transactions.
Definition at line 3024 of file wallet.cpp.
| bool wallet::CWallet::BackupWallet | ( | const std::string & | strDest | ) | const |
| void wallet::CWallet::CacheNewScriptPubKeys | ( | const std::set< CScript > & | spks, |
| ScriptPubKeyMan * | spkm | ||
| ) |
Add scriptPubKeys for this ScriptPubKeyMan into the scriptPubKey cache.
Definition at line 4415 of file wallet.cpp.
| bool wallet::CWallet::CanGrindR | ( | ) | const |
Whether the (external) signer performs R-value signature grinding.
Definition at line 4041 of file wallet.cpp.
|
inline |
| void wallet::CWallet::CommitTransaction | ( | CTransactionRef | tx, |
| std::optional< Txid > | replaces_txid = std::nullopt, |
||
| std::optional< std::string > | comment = std::nullopt, |
||
| std::optional< std::string > | comment_to = std::nullopt, |
||
| const std::vector< std::string > & | messages = {}, |
||
| const std::vector< std::string > & | payment_requests = {} |
||
| ) |
Submit the transaction to the node's mempool and then relay to peers.
Should be called after CreateTransaction unless you want to abort broadcasting the transaction.
| [in] | tx | The transaction to be broadcast. |
| [in] | replaces_txid | The txid of the transaction that this transaction replaces |
| [in] | comment | The user's comment for this transaction |
| [in] | comment_to | The comment for this transaction indicating where coins are sent to |
| [in] | messages | The BIP 21 URI messages to attach to this transaction |
Definition at line 2127 of file wallet.cpp.
| unsigned int wallet::CWallet::ComputeTimeSmart | ( | const CWalletTx & | wtx, |
| bool | rescanning_old_block | ||
| ) | const |
Compute smart timestamp for a transaction being added to the wallet.
Logic:
For more information see CWalletTx::nTimeSmart, https://bitcointalk.org/?topic=54527, or https://github.com/bitcoin/bitcoin/pull/1393.
Definition at line 2621 of file wallet.cpp.
| void wallet::CWallet::ConnectScriptPubKeyManNotifiers | ( | ) |
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition at line 3405 of file wallet.cpp.
|
static |
Definition at line 2925 of file wallet.cpp.
| void wallet::CWallet::DeactivateScriptPubKeyMan | ( | uint256 | id, |
| OutputType | type, | ||
| bool | internal | ||
| ) |
Remove specified ScriptPubKeyMan from set of active SPK managers.
Writes the change to the wallet file.
| [in] | id | The unique id for the ScriptPubKeyMan |
| [in] | type | The OutputType this ScriptPubKeyMan provides addresses for |
| [in] | internal | Whether this ScriptPubKeyMan provides change addresses |
Definition at line 3564 of file wallet.cpp.
| bool wallet::CWallet::DelAddressBook | ( | const CTxDestination & | address | ) |
| bool wallet::CWallet::DelAddressBookWithDB | ( | WalletBatch & | batch, |
| const CTxDestination & | address | ||
| ) |
Definition at line 2338 of file wallet.cpp.
| void wallet::CWallet::DisconnectChainNotifications | ( | ) |
Disconnect chain notifications and wait for all notifications to be processed.
Definition at line 4521 of file wallet.cpp.
| util::Result< void > wallet::CWallet::DisplayAddress | ( | const CTxDestination & | dest | ) |
Display address on an external signer.
Definition at line 2525 of file wallet.cpp.
|
inline |
| bool wallet::CWallet::EraseAddressReceiveRequest | ( | WalletBatch & | batch, |
| const CTxDestination & | dest, | ||
| const std::string & | id | ||
| ) |
| std::optional< PSBTError > wallet::CWallet::FillPSBT | ( | PartiallySignedTransaction & | psbtx, |
| const common::PSBTFillOptions & | options, | ||
| bool & | complete, | ||
| size_t * | n_signed = nullptr |
||
| ) | const |
Fills out a PSBT with information from the wallet.
Fills in UTXOs if we have them. Tries to sign if options.sign=true. Sets complete if the PSBT is now complete (i.e. has all required signatures or signature-parts, and is ready to finalize.)
| [in] | psbtx | PartiallySignedTransaction to fill in |
| [in] | options | options for filling or signing |
| [out] | complete | indicates whether the PSBT is now complete |
| [out] | n_signed | the number of inputs signed by this wallet |
Definition at line 1998 of file wallet.cpp.
| const CAddressBookData * wallet::CWallet::FindAddressBookEntry | ( | const CTxDestination & | dest, |
| bool | allow_change = false |
||
| ) | const |
| void wallet::CWallet::ForEachAddrBookEntry | ( | const ListAddrBookFunc & | func | ) | const |
Definition at line 2451 of file wallet.cpp.
| std::set< ScriptPubKeyMan * > wallet::CWallet::GetActiveScriptPubKeyMans | ( | ) | const |
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition at line 3245 of file wallet.cpp.
| std::vector< std::string > wallet::CWallet::GetAddressReceiveRequests | ( | ) | const |
Definition at line 2702 of file wallet.cpp.
| std::set< ScriptPubKeyMan * > wallet::CWallet::GetAllScriptPubKeyMans | ( | ) | const |
Returns all unique ScriptPubKeyMans.
Definition at line 3270 of file wallet.cpp.
|
inline |
|
inlineoverridevirtual |
Implements wallet::WalletStorage.
Definition at line 453 of file wallet.h.
| DescriptorScriptPubKeyMan * wallet::CWallet::GetDescriptorScriptPubKeyMan | ( | const WalletDescriptor & | desc | ) | const |
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition at line 3581 of file wallet.cpp.
| std::optional< MigrationData > wallet::CWallet::GetDescriptorsForLegacy | ( | bilingual_str & | error | ) | const |
Get all of the descriptors from a legacy wallet.
Definition at line 3813 of file wallet.cpp.
| std::optional< CExtKey > wallet::CWallet::GetExtKey | ( | const CExtPubKey & | xpub | ) | const |
Reconstruct the extended private key for an HD xpub.
Returns nullopt when no descriptor has the private key, or the wallet is locked.
Definition at line 4466 of file wallet.cpp.
| CWallet::HDPubKeyMap wallet::CWallet::GetHDPubKeys | ( | HDKeyFilter | filter | ) | const |
Retrieve descriptor xpubs matching the requested filter.
Definition at line 4428 of file wallet.cpp.
Find the private key for the given key id from the wallet's descriptors, if available Returns nullopt when no descriptor has the key or if the wallet is locked.
Definition at line 4451 of file wallet.cpp.
| unsigned int wallet::CWallet::GetKeyPoolSize | ( | ) | const |
Definition at line 2389 of file wallet.cpp.
|
inline |
|
inline |
| LegacyDataSPKM * wallet::CWallet::GetLegacyDataSPKM | ( | ) | const |
Get the LegacyDataSPKM used for all legacy output types and both internal and external chains.
Definition at line 3343 of file wallet.cpp.
|
inline |
| util::Result< CTxDestination > wallet::CWallet::GetNewChangeDestination | ( | OutputType | type | ) |
| util::Result< CTxDestination > wallet::CWallet::GetNewDestination | ( | OutputType | type, |
| const std::string & | label | ||
| ) |
Definition at line 2410 of file wallet.cpp.
| LegacyDataSPKM * wallet::CWallet::GetOrCreateLegacyDataSPKM | ( | ) |
Definition at line 3363 of file wallet.cpp.
| ScriptPubKeyMan * wallet::CWallet::GetScriptPubKeyMan | ( | const OutputType & | type, |
| bool | internal | ||
| ) | const |
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition at line 3279 of file wallet.cpp.
| ScriptPubKeyMan * wallet::CWallet::GetScriptPubKeyMan | ( | const uint256 & | id | ) | const |
Get the ScriptPubKeyMan by id.
Definition at line 3304 of file wallet.cpp.
| std::set< ScriptPubKeyMan * > wallet::CWallet::GetScriptPubKeyMans | ( | const CScript & | script | ) | const |
Get all the ScriptPubKeyMans for a script.
Definition at line 3289 of file wallet.cpp.
| std::unique_ptr< SigningProvider > wallet::CWallet::GetSolvingProvider | ( | const CScript & | script | ) | const |
Get the SigningProvider for a script.
Definition at line 3312 of file wallet.cpp.
| std::unique_ptr< SigningProvider > wallet::CWallet::GetSolvingProvider | ( | const CScript & | script, |
| SignatureData & | sigdata | ||
| ) | const |
Definition at line 3318 of file wallet.cpp.
| int wallet::CWallet::GetTxBlocksToMaturity | ( | const CWalletTx & | wtx | ) | const |
Definition at line 3184 of file wallet.cpp.
| int wallet::CWallet::GetTxDepthInMainChain | ( | const CWalletTx & | wtx | ) | const |
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockchain 0 : in memory pool, waiting to be included in a block >=1 : this many blocks deep in the main chain.
Preconditions: it is only valid to call this function when the wallet is online and the block index is loaded. So this cannot be called by bitcoin-wallet tool code or by wallet migration code. If this is called without the wallet being online, it won't be able able to determine the the height of the last block processed, or the heights of blocks referenced in transaction, and might cause assert failures.
Definition at line 3170 of file wallet.cpp.
Definition at line 4511 of file wallet.cpp.
|
inline |
| std::vector< WalletDescriptor > wallet::CWallet::GetWalletDescriptors | ( | const CScript & | script | ) | const |
Get the wallet descriptors for a script.
Definition at line 3331 of file wallet.cpp.
|
private |
The following is used to keep track of how far behind the wallet is from the chain sync, and to allow clients to block on us being caught up.
Processed hash is a pointer on node's tip and doesn't imply that the wallet has scanned sequentially all blocks up to this one.
|
private |
Height of last block processed is used by wallet to know depth of transactions without relying on Chain interface beyond asynchronous updates.
For safety, we initialize it to -1. Height is a pointer on node's tip and doesn't imply that the wallet has scanned sequentially all blocks up to this one.
|
private |
Set of both spent and unspent transaction outputs owned by this wallet.
| std::unordered_map< Txid, CWalletTx, SaltedTxidHasher > mapWallet wallet::CWallet::GUARDED_BY | ( | cs_wallet | ) |
Map from txid to CWalletTx for all transactions this wallet is interested in, including received and sent transactions.
| std::map< CTxDestination, CAddressBookData > m_address_book wallet::CWallet::GUARDED_BY | ( | cs_wallet | ) |
Set of Coins owned by this wallet that we won't try to spend from.
A Coin may be locked if it has already been used to fund a transaction that hasn't confirmed yet. We wouldn't consider the Coin spent already, but also shouldn't try to use it again. bool to track whether this locked coin is persisted to disk.
|
inline |
|
pure virtual |
|
overridevirtual |
Implements wallet::WalletStorage.
Definition at line 3392 of file wallet.cpp.
|
inline |
| bool wallet::CWallet::HaveCryptedKeys | ( | ) | const |
Definition at line 3397 of file wallet.cpp.
| bool wallet::CWallet::IsActiveScriptPubKeyMan | ( | const ScriptPubKeyMan & | spkm | ) | const |
| bool wallet::CWallet::IsAddressPreviouslySpent | ( | const CTxDestination & | dest | ) | const |
Definition at line 2696 of file wallet.cpp.
| std::optional< bool > wallet::CWallet::IsInternalScriptPubKeyMan | ( | ScriptPubKeyMan * | spk_man | ) | const |
Returns whether the provided ScriptPubKeyMan is internal.
| [in] | spk_man | The ScriptPubKeyMan to test |
Definition at line 3595 of file wallet.cpp.
|
overridevirtual |
Implements wallet::WalletStorage.
Definition at line 3204 of file wallet.cpp.
| bool wallet::CWallet::IsLockedCoin | ( | const COutPoint & | output | ) | const |
| bool wallet::CWallet::IsTxImmatureCoinBase | ( | const CWalletTx & | wtx | ) | const |
| size_t wallet::CWallet::KeypoolCountExternalKeys | ( | ) | const |
| std::vector< CTxDestination > wallet::CWallet::ListAddrBookAddresses | ( | const std::optional< AddrBookFilter > & | filter | ) | const |
Filter and retrieve destinations stored in the addressbook.
Definition at line 2460 of file wallet.cpp.
| std::set< std::string > wallet::CWallet::ListAddrBookLabels | ( | std::optional< AddressPurpose > | purpose | ) | const |
Retrieve all the known labels in the address book.
Definition at line 2476 of file wallet.cpp.
| void wallet::CWallet::ListLockedCoins | ( | std::vector< COutPoint > & | vOutpts | ) | const |
| void wallet::CWallet::LoadActiveScriptPubKeyMan | ( | uint256 | id, |
| OutputType | type, | ||
| bool | internal | ||
| ) |
Loads an active ScriptPubKeyMan for the specified type and internal.
(used by LoadWallet)
| [in] | id | The unique id for the ScriptPubKeyMan |
| [in] | type | The OutputType this ScriptPubKeyMan provides addresses for |
| [in] | internal | Whether this ScriptPubKeyMan provides change addresses |
Definition at line 3544 of file wallet.cpp.
| void wallet::CWallet::LoadAddressPreviouslySpent | ( | const CTxDestination & | dest | ) |
Marks destination as previously spent.
Definition at line 2686 of file wallet.cpp.
| void wallet::CWallet::LoadAddressReceiveRequest | ( | const CTxDestination & | dest, |
| const std::string & | id, | ||
| const std::string & | request | ||
| ) |
Appends payment request to destination.
Definition at line 2691 of file wallet.cpp.
| void wallet::CWallet::LoadDescriptorScriptPubKeyMan | ( | uint256 | id, |
| WalletDescriptor & | desc, | ||
| const KeyMap & | keys, | ||
| const CryptedKeyMap & | ckeys | ||
| ) |
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition at line 3417 of file wallet.cpp.
|
static |
Definition at line 2980 of file wallet.cpp.
| void wallet::CWallet::LoadLockedCoin | ( | const COutPoint & | coin, |
| bool | persistent | ||
| ) |
Definition at line 2540 of file wallet.cpp.
|
static |
Definition at line 2777 of file wallet.cpp.
| bool wallet::CWallet::Lock | ( | ) |
Definition at line 3213 of file wallet.cpp.
| bool wallet::CWallet::LockCoin | ( | const COutPoint & | output, |
| bool | persist | ||
| ) |
|
inlineoverridevirtual |
Return wallet name for use in logs, will return "default wallet" if the wallet has no name.
Implements wallet::WalletStorage.
Definition at line 908 of file wallet.h.
|
inline |
| void wallet::CWallet::MarkDestinationsDirty | ( | const std::set< CTxDestination > & | destinations | ) |
Marks all outputs in each one of the destinations dirty, so their cache is reset and does not return outdated information.
Definition at line 2437 of file wallet.cpp.
| bool wallet::CWallet::MigrateToSQLite | ( | bilingual_str & | error | ) |
Move all records from the BDB database to a new SQLite database for storage.
The original BDB file will be deleted and replaced with a new SQLite file. A backup is not created. May crash if something unexpected happens in the filesystem.
Definition at line 3739 of file wallet.cpp.
| DBErrors wallet::CWallet::PopulateWalletFromDB | ( | bilingual_str & | error, |
| std::vector< bilingual_str > & | warnings | ||
| ) |
| void wallet::CWallet::postInitProcess | ( | ) |
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init tasks.
Definition at line 3154 of file wallet.cpp.
| void wallet::CWallet::RefreshAllTXOs | ( | ) |
Cache outputs that belong to the wallet for all transactions in the wallet.
Definition at line 4503 of file wallet.cpp.
| void wallet::CWallet::RefreshTXOsFromTx | ( | const CWalletTx & | wtx | ) |
Cache outputs that belong to the wallet from a single transaction.
Definition at line 4489 of file wallet.cpp.
| util::Result< void > wallet::CWallet::RemoveTxs | ( | std::vector< Txid > & | txs_to_remove | ) |
Erases the provided transactions from the wallet.
Definition at line 2228 of file wallet.cpp.
| util::Result< void > wallet::CWallet::RemoveTxs | ( | WalletBatch & | batch, |
| std::vector< Txid > & | txs_to_remove | ||
| ) |
| ChainScanner & wallet::CWallet::Scanner | ( | ) |
| const ChainScanner & wallet::CWallet::Scanner | ( | ) | const |
Definition at line 500 of file wallet.cpp.
| bool wallet::CWallet::SetAddressBook | ( | const CTxDestination & | address, |
| const std::string & | strName, | ||
| const std::optional< AddressPurpose > & | purpose | ||
| ) |
Definition at line 2325 of file wallet.cpp.
|
private |
Definition at line 2289 of file wallet.cpp.
| bool wallet::CWallet::SetAddressPreviouslySpent | ( | WalletBatch & | batch, |
| const CTxDestination & | dest, | ||
| bool | used | ||
| ) |
Definition at line 2672 of file wallet.cpp.
| bool wallet::CWallet::SetAddressReceiveRequest | ( | WalletBatch & | batch, |
| const CTxDestination & | dest, | ||
| const std::string & | id, | ||
| const std::string & | value | ||
| ) |
|
inline |
|
inline |
| DescriptorScriptPubKeyMan & wallet::CWallet::SetupDescriptorScriptPubKeyMan | ( | WalletBatch & | batch, |
| const CExtKey & | master_key, | ||
| const OutputType & | output_type, | ||
| bool | internal | ||
| ) |
Create new DescriptorScriptPubKeyMan and add it to the wallet.
Definition at line 3428 of file wallet.cpp.
| void wallet::CWallet::SetupDescriptorScriptPubKeyMans | ( | ) |
Definition at line 3468 of file wallet.cpp.
| void wallet::CWallet::SetupDescriptorScriptPubKeyMans | ( | WalletBatch & | batch, |
| const CExtKey & | master_key | ||
| ) |
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition at line 3442 of file wallet.cpp.
| void wallet::CWallet::SetupLegacyDataSPKM | ( | ) |
Create a LegacyDataSPKM and set it for all legacy output types and both internal and external chains.
Definition at line 3369 of file wallet.cpp.
| void wallet::CWallet::SetupOwnDescriptorScriptPubKeyMans | ( | WalletBatch & | batch | ) |
Create new seed and default DescriptorScriptPubKeyMans for this wallet.
Definition at line 3452 of file wallet.cpp.
| void wallet::CWallet::SetupWalletGeneration | ( | ) |
Setup new descriptors or seed for new address generation.
Definition at line 3518 of file wallet.cpp.
| SigningResult wallet::CWallet::SignMessage | ( | const std::string & | message, |
| const PKHash & | pkhash, | ||
| std::string & | str_sig | ||
| ) | const |
| bool wallet::CWallet::SignTransaction | ( | CMutableTransaction & | tx | ) | const |
Fetch the inputs and sign with SIGHASH_ALL.
Definition at line 1964 of file wallet.cpp.
| bool wallet::CWallet::SignTransaction | ( | CMutableTransaction & | tx, |
| const std::map< COutPoint, Coin > & | coins, | ||
| int | sighash, | ||
| std::map< int, bilingual_str > & | input_errors | ||
| ) | const |
Sign the tx given the input coins and sighash.
Definition at line 1983 of file wallet.cpp.
|
overridevirtual |
Callback function for after TopUp completes containing any scripts that were added by a SPKMan.
Implements wallet::WalletStorage.
Definition at line 4422 of file wallet.cpp.
| bool wallet::CWallet::TopUpKeyPool | ( | unsigned int | kpSize = 0 | ) |
Definition at line 2400 of file wallet.cpp.
| OutputType wallet::CWallet::TransactionChangeType | ( | const std::optional< OutputType > & | change_type, |
| const std::vector< CRecipient > & | vecSend | ||
| ) | const |
|
private |
| bool wallet::CWallet::UnlockAllCoins | ( | ) |
| bool wallet::CWallet::UnlockCoin | ( | const COutPoint & | output | ) |
Definition at line 2557 of file wallet.cpp.
|
inline |
|
overridevirtual |
Pass the encryption key to cb().
Implements wallet::WalletStorage.
Definition at line 3386 of file wallet.cpp.
| void wallet::CWallet::WriteBestBlock | ( | ) | const |
Write the current best block to database.
Definition at line 4474 of file wallet.cpp.
|
friend |
|
mutable |
|
private |
| bool wallet::CWallet::m_allow_fallback_fee {true} |
|
private |
|
private |
|
private |
|
private |
| std::unique_ptr<interfaces::Handler> wallet::CWallet::m_chain_notifications_handler |
Registered interfaces::Chain::Notifications handler.
| unsigned int wallet::CWallet::m_confirm_target {DEFAULT_TX_CONFIRM_TARGET} |
| CFeeRate wallet::CWallet::m_consolidate_feerate {DEFAULT_CONSOLIDATE_FEERATE} |
|
private |
| OutputType wallet::CWallet::m_default_address_type {DEFAULT_ADDRESS_TYPE} |
| std::optional<OutputType> wallet::CWallet::m_default_change_type {} |
Default output type for change outputs.
When unset, automatically choose type based on address type setting and the types other of non-change outputs (see -changetype option documentation and implementation in CWallet::TransactionChangeType for details).
| CFeeRate wallet::CWallet::m_discard_rate {DEFAULT_DISCARD_FEE} |
|
private |
| CFeeRate wallet::CWallet::m_fallback_fee {DEFAULT_FALLBACK_FEE} |
|
private |
| int64_t wallet::CWallet::m_keypool_size {DEFAULT_KEYPOOL_SIZE} |
| CAmount wallet::CWallet::m_max_aps_fee {DEFAULT_MAX_AVOIDPARTIALSPEND_FEE} |
| CAmount wallet::CWallet::m_max_tx_fee {DEFAULT_TRANSACTION_MAXFEE} |
| CFeeRate wallet::CWallet::m_max_tx_fee_rate {DEFAULT_MAX_TRANSACTION_FEERATE} |
| CFeeRate wallet::CWallet::m_min_fee {DEFAULT_TRANSACTION_MINFEE} |
|
private |
|
private |
| std::string wallet::CWallet::m_notify_tx_changed_script |
| RecursiveMutex wallet::CWallet::m_relock_mutex |
|
private |
| bool wallet::CWallet::m_signal_rbf {DEFAULT_WALLET_RBF} |
| bool wallet::CWallet::m_spend_zero_conf_change {DEFAULT_SPEND_ZEROCONF_CHANGE} |
|
private |
|
private |
| MasterKeyMap wallet::CWallet::mapMasterKeys |
| btcsignals::signal<void(const CTxDestination& address, const std::string& label, bool isMine, AddressPurpose purpose, ChangeType status)> wallet::CWallet::NotifyAddressBookChanged |
| btcsignals::signal<void ()> wallet::CWallet::NotifyCanGetAddressesChanged |
| btcsignals::signal<void (CWallet* wallet)> wallet::CWallet::NotifyStatusChanged |
| btcsignals::signal<void(const Txid& hashTx, ChangeType status)> wallet::CWallet::NotifyTransactionChanged |
| btcsignals::signal<void ()> wallet::CWallet::NotifyUnload |
| btcsignals::signal<void (const std::string &title, int nProgress)> wallet::CWallet::ShowProgress |