![]() |
Bitcoin Core
22.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 | ScanResult |
Public Types | |
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... | |
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, const ArgsManager &args, std::unique_ptr< WalletDatabase > database) | |
Construct wallet with specified name and database implementation. More... | |
~CWallet () | |
bool | IsCrypted () const |
bool | IsLocked () const override |
bool | Lock () |
bool | HaveChain () const |
Interface to assert chain access. More... | |
std::map< uint256, CWalletTx > 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::set< COutPoint > setLockedCoins | 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 uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
std::set< uint256 > | GetTxConflicts (const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS |
int | GetTxDepthInMainChain (const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS |
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... | |
bool | IsTxInMainChain (const CWalletTx &wtx) const |
int | GetTxBlocksToMaturity (const CWalletTx &wtx) const |
bool | IsTxImmatureCoinBase (const CWalletTx &wtx) const |
bool | CanSupportFeature (enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
check whether we support the named feature More... | |
bool | IsSpent (const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Outpoint is spent if any non-conflicted transaction spends it: More... | |
bool | IsSpentKey (const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SetSpentKeyState (WalletBatch &batch, const uint256 &hash, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | DisplayAddress (const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Display address on an external signer. More... | |
bool | IsLockedCoin (uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | LockCoin (const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | UnlockCoin (const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | UnlockAllCoins () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | ListLockedCoins (std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | AbortRescan () |
bool | IsAbortingRescan () const |
bool | IsScanning () const |
int64_t | ScanningDuration () const |
double | ScanningProgress () const |
void | UpgradeKeyMetadata () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo. More... | |
void | UpgradeDescriptorCache () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Upgrade DescriptorCaches. More... | |
bool | LoadMinVersion (int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | LoadDestData (const CTxDestination &dest, const std::string &key, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Adds a destination data tuple to the store, without saving it to disk. 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... | |
bool | Unlock (const SecureString &strWalletPassphrase, bool accept_no_keys=false) |
bool | ChangeWalletPassphrase (const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase) |
bool | EncryptWallet (const SecureString &strWalletPassphrase) |
void | GetKeyBirthTimes (std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
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 fFlushOnClose=true, bool rescanning_old_block=false) |
bool | LoadToWallet (const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | transactionAddedToMempool (const CTransactionRef &tx, uint64_t mempool_sequence) override |
void | blockConnected (const CBlock &block, int height) override |
void | blockDisconnected (const CBlock &block, int height) override |
void | updatedBlockTip () override |
int64_t | RescanFromTime (int64_t startTime, const WalletRescanReserver &reserver, bool update) |
Scan active chain for relevant transactions after importing keys. More... | |
ScanResult | ScanForWalletTransactions (const uint256 &start_block, int start_height, std::optional< int > max_height, const WalletRescanReserver &reserver, bool fUpdate) |
Scan the block chain (starting in start_block) for transactions from or to us. More... | |
void | transactionRemovedFromMempool (const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override |
void | ReacceptWalletTransactions () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | ResendWalletTransactions () |
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 |
TransactionError | FillPSBT (PartiallySignedTransaction &psbtx, bool &complete, int sighash_type=SIGHASH_DEFAULT, bool sign=true, bool bip32derivs=true, size_t *n_signed=nullptr, bool finalize=true) const |
Fills out a PSBT with information from the wallet. More... | |
void | CommitTransaction (CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm) |
Submit the transaction to the node's mempool and then relay to peers. More... | |
bool | SubmitTxMemoryPoolAndRelay (CWalletTx &wtx, std::string &err_string, bool relay) const |
Pass this transaction to node for mempool insertion and relay to peers if flag set to true. More... | |
bool | DummySignTx (CMutableTransaction &txNew, const std::set< CTxOut > &txouts, const CCoinControl *coin_control=nullptr) const |
bool | DummySignTx (CMutableTransaction &txNew, const std::vector< CTxOut > &txouts, const CCoinControl *coin_control=nullptr) const |
bool | ImportScripts (const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | ImportPrivKeys (const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | ImportPubKeys (const std::vector< CKeyID > &ordered_pubkeys, const std::map< CKeyID, CPubKey > &pubkey_map, const std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo >> &key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | ImportScriptPubKeys (const std::string &label, const std::set< CScript > &script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
size_t | KeypoolCountExternalKeys () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | TopUpKeyPool (unsigned int kpSize=0) |
std::optional< int64_t > | GetOldestKeyPoolTime () const |
std::set< CTxDestination > | GetLabelAddresses (const std::string &label) 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... | |
bool | GetNewDestination (const OutputType type, const std::string label, CTxDestination &dest, bilingual_str &error) |
bool | GetNewChangeDestination (const OutputType type, CTxDestination &dest, bilingual_str &error) |
isminetype | IsMine (const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
isminetype | IsMine (const CScript &script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
CAmount | GetDebit (const CTxIn &txin, const isminefilter &filter) const |
Returns amount of debit if the input matches the filter, otherwise returns 0. More... | |
isminetype | IsMine (const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | IsMine (const CTransaction &tx) 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 isminefilter &filter) const |
void | chainStateFlushed (const CBlockLocator &loc) override |
DBErrors | LoadWallet () |
DBErrors | ZapSelectTx (std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | SetAddressBook (const CTxDestination &address, const std::string &strName, const std::string &purpose) |
bool | DelAddressBook (const CTxDestination &address) |
bool | IsAddressUsed (const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | SetAddressUsed (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) |
unsigned int | GetKeyPoolSize () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SetMinVersion (enum WalletFeature, WalletBatch *batch_in=nullptr) override |
signify that a particular wallet feature is now used. More... | |
int | GetVersion () const |
get the current wallet format (the oldest client version guaranteed to understand this wallet) More... | |
std::set< uint256 > | GetConflicts (const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Get wallet transactions that conflict with given transaction (spend same outputs) More... | |
bool | HasWalletSpend (const uint256 &txid) 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 | Flush () |
Flush wallet (bitdb flush) 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 uint256 &hashTx) const |
Return whether transaction can be abandoned. More... | |
bool | AbandonTransaction (const uint256 &hashTx) |
bool | MarkReplaced (const uint256 &originalHash, const uint256 &newHash) |
Mark a transaction as replaced by another transaction (e.g., BIP 125). 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 |
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... | |
bool | AddWalletFlags (uint64_t flags) |
overwrite all flags by the given uint64_t returns false if unknown, non-tolerable flags are present More... | |
bool | LoadWalletFlags (uint64_t flags) |
Loads the flags into the wallet. More... | |
bool | IsLegacy () const |
Determine if we are a legacy wallet. More... | |
const std::string | GetDisplayName () const override |
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name. More... | |
template<typename... Params> | |
void | WalletLogPrintf (std::string fmt, Params... parameters) const |
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases. More... | |
bool | UpgradeWallet (int version, bilingual_str &error) |
Upgrade the wallet. More... | |
std::set< ScriptPubKeyMan * > | GetActiveScriptPubKeyMans () const |
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers. More... | |
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 |
LegacyScriptPubKeyMan * | GetLegacyScriptPubKeyMan () const |
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external. More... | |
LegacyScriptPubKeyMan * | GetOrCreateLegacyScriptPubKeyMan () |
void | SetupLegacyScriptPubKeyMan () |
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external. More... | |
const CKeyingMaterial & | GetEncryptionKey () const override |
bool | HasEncryptionKeys () const override |
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, currently only use in unit test. More... | |
void | ConnectScriptPubKeyManNotifiers () |
Connect the signals from ScriptPubKeyMans to the signals in CWallet. More... | |
void | LoadDescriptorScriptPubKeyMan (uint256 id, WalletDescriptor &desc) |
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... | |
void | SetupDescriptorScriptPubKeyMans () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Create new DescriptorScriptPubKeyMans and add them to the wallet. 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... | |
ScriptPubKeyMan * | 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... | |
![]() | |
virtual | ~WalletStorage ()=default |
![]() | |
virtual | ~Notifications () |
Static Public Member Functions | |
static std::shared_ptr< CWallet > | Create (WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, 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 |
uint64_t | nAccountingEntryNumber = 0 |
std::unique_ptr< interfaces::Handler > | m_chain_notifications_handler |
Registered interfaces::Chain::Notifications handler. More... | |
Mutex | m_unlock_mutex |
CFeeRate | m_pay_tx_fee {DEFAULT_PAY_TX_FEE} |
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} |
Override with -mintxfee. More... | |
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_default_max_tx_fee {DEFAULT_TRANSACTION_MAXFEE} |
Absolute maximum transaction fee (in satoshis) used by default for the wallet. More... | |
boost::signals2::signal< void()> | NotifyUnload |
Wallet is about to be unloaded. More... | |
boost::signals2::signal< void(const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> | NotifyAddressBookChanged |
Address book entry changed. More... | |
boost::signals2::signal< void(const uint256 &hashTx, ChangeType status)> | NotifyTransactionChanged |
Wallet transaction added, removed or updated. More... | |
boost::signals2::signal< void(const std::string &title, int nProgress)> | ShowProgress |
Show progress e.g. More... | |
boost::signals2::signal< void(bool fHaveWatchOnly)> | NotifyWatchonlyChanged |
Watch-only address added. More... | |
boost::signals2::signal< void()> | NotifyCanGetAddressesChanged |
Keypool has new keys. More... | |
boost::signals2::signal< void(CWallet *wallet)> | NotifyStatusChanged |
Wallet status (encrypted, locked) changed. More... | |
Private Types | |
typedef std::multimap< COutPoint, uint256 > | TxSpends |
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated transactions where the mutant gets mined). More... | |
Private Member Functions | |
CKeyingMaterial vMasterKey | GUARDED_BY (cs_wallet) |
bool | Unlock (const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false) |
int nWalletVersion | GUARDED_BY (cs_wallet) |
the current wallet version: clients below this version are not able to load the wallet More... | |
TxSpends mapTxSpends | GUARDED_BY (cs_wallet) |
void | AddToSpends (const COutPoint &outpoint, const uint256 &wtxid, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | AddToSpends (const uint256 &wtxid, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | AddToWalletIfInvolvingMe (const CTransactionRef &tx, const SyncTxState &state, bool fUpdate, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Add a transaction to the wallet, or update it. More... | |
void | MarkConflicted (const uint256 &hashBlock, int conflicting_height, const uint256 &hashTx) |
Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. More... | |
void | MarkInputsDirty (const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed. More... | |
void | SyncMetaData (std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SyncTransaction (const CTransactionRef &tx, const SyncTxState &state, bool update_tx=true, bool rescanning_old_block=false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | SetAddressBookWithDB (WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &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... | |
Static Private Member Functions | |
static bool | AttachChain (const std::shared_ptr< CWallet > &wallet, interfaces::Chain &chain, const 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... | |
Private Attributes | |
std::atomic< bool > | fAbortRescan {false} |
std::atomic< bool > | fScanningWallet {false} |
std::atomic< int64_t > | m_scanning_start {0} |
std::atomic< double > | m_scanning_progress {0} |
int64_t | nNextResend = 0 |
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< uint64_t > | m_wallet_flags {0} |
WalletFlags set on this wallet. More... | |
const ArgsManager & | m_args |
Provider of aplication-wide arguments. 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... | |
const std::unique_ptr< WalletDatabase > | m_database |
Internal database handle. More... | |
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 |
Friends | |
class | WalletRescanReserver |
A CWallet maintains a set of transactions and balances, and provides the ability to create new transactions.
typedef std::map<unsigned int, CMasterKey> wallet::CWallet::MasterKeyMap |
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 |
|
inline |
|
inline |
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 3341 of file wallet.cpp.
ScriptPubKeyMan * 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 3433 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 2914 of file wallet.cpp.
bool wallet::CWallet::BackupWallet | ( | const std::string & | strDest | ) | const |
|
inlineoverridevirtual |
check whether we support the named feature
Implements wallet::WalletStorage.
Definition at line 449 of file wallet.h.
|
inline |
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 2529 of file wallet.cpp.
void wallet::CWallet::ConnectScriptPubKeyManNotifiers | ( | ) |
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition at line 3257 of file wallet.cpp.
|
static |
Definition at line 2668 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 3370 of file wallet.cpp.
|
inline |
const CAddressBookData * wallet::CWallet::FindAddressBookEntry | ( | const CTxDestination & | dest, |
bool | allow_change = false |
||
) | const |
std::set< ScriptPubKeyMan * > wallet::CWallet::GetActiveScriptPubKeyMans | ( | ) | const |
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition at line 3146 of file wallet.cpp.
std::vector< std::string > wallet::CWallet::GetAddressReceiveRequests | ( | ) | const |
Definition at line 2616 of file wallet.cpp.
std::set< ScriptPubKeyMan * > wallet::CWallet::GetAllScriptPubKeyMans | ( | ) | const |
Returns all unique ScriptPubKeyMans.
Definition at line 3160 of file wallet.cpp.
|
inline |
|
inlineoverridevirtual |
Implements wallet::WalletStorage.
Definition at line 354 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 3396 of file wallet.cpp.
|
inlineoverridevirtual |
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name.
Implements wallet::WalletStorage.
Definition at line 793 of file wallet.h.
|
overridevirtual |
Implements wallet::WalletStorage.
Definition at line 3247 of file wallet.cpp.
void wallet::CWallet::GetKeyBirthTimes | ( | std::map< CKeyID, int64_t > & | mapKeyBirth | ) | const |
|
inline |
|
inline |
LegacyScriptPubKeyMan * wallet::CWallet::GetLegacyScriptPubKeyMan | ( | ) | const |
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition at line 3215 of file wallet.cpp.
|
inline |
LegacyScriptPubKeyMan * wallet::CWallet::GetOrCreateLegacyScriptPubKeyMan | ( | ) |
Definition at line 3227 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 3169 of file wallet.cpp.
ScriptPubKeyMan * wallet::CWallet::GetScriptPubKeyMan | ( | const uint256 & | id | ) | const |
Get the ScriptPubKeyMan by id.
Definition at line 3191 of file wallet.cpp.
std::set< ScriptPubKeyMan * > wallet::CWallet::GetScriptPubKeyMans | ( | const CScript & | script | ) | const |
Get all the ScriptPubKeyMans for a script.
Definition at line 3179 of file wallet.cpp.
std::unique_ptr< SigningProvider > wallet::CWallet::GetSolvingProvider | ( | const CScript & | script | ) | const |
Get the SigningProvider for a script.
Definition at line 3199 of file wallet.cpp.
std::unique_ptr< SigningProvider > wallet::CWallet::GetSolvingProvider | ( | const CScript & | script, |
SignatureData & | sigdata | ||
) | const |
Definition at line 3205 of file wallet.cpp.
int wallet::CWallet::GetTxBlocksToMaturity | ( | const CWalletTx & | wtx | ) | const |
Definition at line 3088 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.
Definition at line 3076 of file wallet.cpp.
|
inline |
|
private |
|
inlineprivate |
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.
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 | ) |
|
inline |
|
pure virtual |
|
overridevirtual |
Implements wallet::WalletStorage.
Definition at line 3252 of file wallet.cpp.
|
inline |
bool wallet::CWallet::IsAddressUsed | ( | const CTxDestination & | dest | ) | const |
bool wallet::CWallet::IsCrypted | ( | ) | const |
Definition at line 3103 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 3409 of file wallet.cpp.
bool wallet::CWallet::IsLegacy | ( | ) | const |
Determine if we are a legacy wallet.
Definition at line 3387 of file wallet.cpp.
|
overridevirtual |
Implements wallet::WalletStorage.
Definition at line 3108 of file wallet.cpp.
bool wallet::CWallet::IsTxImmatureCoinBase | ( | const CWalletTx & | wtx | ) | const |
|
inline |
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 3350 of file wallet.cpp.
void wallet::CWallet::LoadDescriptorScriptPubKeyMan | ( | uint256 | id, |
WalletDescriptor & | desc | ||
) |
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition at line 3265 of file wallet.cpp.
void wallet::CWallet::LoadDestData | ( | const CTxDestination & | dest, |
const std::string & | key, | ||
const std::string & | value | ||
) |
Adds a destination data tuple to the store, without saving it to disk.
Definition at line 2596 of file wallet.cpp.
|
inline |
bool wallet::CWallet::Lock | ( | ) |
Definition at line 3117 of file wallet.cpp.
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 3044 of file wallet.cpp.
|
inline |
bool wallet::CWallet::SetAddressReceiveRequest | ( | WalletBatch & | batch, |
const CTxDestination & | dest, | ||
const std::string & | id, | ||
const std::string & | value | ||
) |
bool wallet::CWallet::SetAddressUsed | ( | WalletBatch & | batch, |
const CTxDestination & | dest, | ||
bool | used | ||
) |
Definition at line 2580 of file wallet.cpp.
|
inline |
|
inline |
void wallet::CWallet::SetupDescriptorScriptPubKeyMans | ( | ) |
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition at line 3276 of file wallet.cpp.
void wallet::CWallet::SetupLegacyScriptPubKeyMan | ( | ) |
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition at line 3233 of file wallet.cpp.
|
private |
bool wallet::CWallet::UpgradeWallet | ( | int | version, |
bilingual_str & | error | ||
) |
Upgrade the wallet.
Definition at line 3011 of file wallet.cpp.
|
inline |
|
friend |
|
mutable |
|
private |
|
private |
Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadcasts (see ResendWalletTransactions()).
|
private |
bool wallet::CWallet::m_allow_fallback_fee {true} |
|
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).
CAmount wallet::CWallet::m_default_max_tx_fee {DEFAULT_TRANSACTION_MAXFEE} |
CFeeRate wallet::CWallet::m_discard_rate {DEFAULT_DISCARD_FEE} |
|
private |
CFeeRate wallet::CWallet::m_fallback_fee {DEFAULT_FALLBACK_FEE} |
|
private |
CAmount wallet::CWallet::m_max_aps_fee {DEFAULT_MAX_AVOIDPARTIALSPEND_FEE} |
CFeeRate wallet::CWallet::m_min_fee {DEFAULT_TRANSACTION_MINFEE} |
|
private |
CFeeRate wallet::CWallet::m_pay_tx_fee {DEFAULT_PAY_TX_FEE} |
|
private |
|
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 |
|
private |
boost::signals2::signal<void(const CTxDestination& address, const std::string& label, bool isMine, const std::string& purpose, ChangeType status)> wallet::CWallet::NotifyAddressBookChanged |
boost::signals2::signal<void ()> wallet::CWallet::NotifyCanGetAddressesChanged |
boost::signals2::signal<void(const uint256& hashTx, ChangeType status)> wallet::CWallet::NotifyTransactionChanged |
boost::signals2::signal<void ()> wallet::CWallet::NotifyUnload |
boost::signals2::signal<void (bool fHaveWatchOnly)> wallet::CWallet::NotifyWatchonlyChanged |
boost::signals2::signal<void (const std::string &title, int nProgress)> wallet::CWallet::ShowProgress |