Bitcoin ABC 0.26.3
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. | |
Public Member Functions | |
WalletDatabase & | GetDBHandle () |
Get database handle used by this wallet. | |
WalletDatabase & | GetDatabase () override |
const std::string & | GetName () const |
Get a name for this wallet for logging/debugging purposes. | |
CWallet (interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > _database) | |
Construct wallet with specified name and database implementation. | |
~CWallet () | |
const CChainParams & | GetChainParams () const override |
bool | IsCrypted () const |
bool | IsLocked () const override |
bool | Lock () |
bool | HaveChain () const |
Interface to assert chain access. | |
std::map< TxId, CWalletTx > mapWallet | GUARDED_BY (cs_wallet) |
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) |
interfaces::Chain & | chain () const |
Interface for accessing chain state. | |
const CWalletTx * | GetWalletTx (const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
std::set< TxId > | GetTxConflicts (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
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. | |
bool | IsTxInMainChain (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
int | GetTxBlocksToMaturity (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | IsTxImmatureCoinBase (const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | CanSupportFeature (enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
check whether we are allowed to upgrade (or already support) to the named feature | |
bool | IsSpent (const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Outpoint is spent if any non-conflicted transaction, spends it: | |
bool | IsSpentKey (const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SetSpentKeyState (WalletBatch &batch, const TxId &txid, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | IsLockedCoin (const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | LockCoin (const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | UnlockCoin (const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | 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. | |
bool | LoadMinVersion (int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | AddDestData (WalletBatch &batch, const CTxDestination &dest, const std::string &key, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Adds a destination data tuple to the store, and saves it to disk When adding new fields, take care to consider how DelAddressBook should handle it! | |
bool | EraseDestData (WalletBatch &batch, const CTxDestination &dest, const std::string &key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Erases a destination data tuple in the store and on disk. | |
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. | |
bool | GetDestData (const CTxDestination &dest, const std::string &key, std::string *value) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Look up a destination data tuple in the store, return true if found false otherwise. | |
std::vector< std::string > | GetDestValues (const std::string &prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Get all destination values matching a prefix. | |
int64_t nRelockTime | GUARDED_BY (cs_wallet) |
Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. | |
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) const |
Compute smart timestamp for a transaction being added to the wallet. | |
int64_t | IncOrderPosNext (WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Increment the next transaction order id. | |
DBErrors | ReorderTransactions () |
void | MarkDirty () |
CWalletTx * | AddToWallet (CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true) |
bool | LoadToWallet (const TxId &txid, 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. | |
ScanResult | ScanForWalletTransactions (const BlockHash &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. | |
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) |
bool | SignTransaction (CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const |
SigningResult | SignMessage (const std::string &message, const PKHash &pkhash, std::string &str_sig) const |
TransactionError | FillPSBT (PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true) const |
Fills out a PSBT with information from the wallet. | |
void | CommitTransaction (CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string > > orderForm, bool broadcast=true) |
Add the transaction to the wallet and maybe attempt to broadcast it. | |
bool | SubmitTxMemoryPoolAndRelay (const CWalletTx &wtx, std::string &err_string, bool relay) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Pass this transaction to node for mempool insertion and relay to peers if flag set to true. | |
bool | DummySignTx (CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const |
bool | DummySignTx (CMutableTransaction &txNew, const std::vector< CTxOut > &txouts, bool use_max_sig=false) const |
bool | DummySignInput (CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) 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) |
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. | |
bool | GetNewDestination (const OutputType type, const std::string label, CTxDestination &dest, std::string &error) |
bool | GetNewChangeDestination (const OutputType type, CTxDestination &dest, std::string &error) |
isminetype | IsMine (const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
isminetype | IsMine (const CScript &script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Amount | GetDebit (const CTxIn &txin, const isminefilter &filter) const |
Returns amount of debit if the input matches the filter, otherwise returns 0. | |
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 | |
Amount | GetDebit (const CTransaction &tx, const isminefilter &filter) const |
void | chainStateFlushed (const CBlockLocator &loc) override |
DBErrors | LoadWallet (bool &fFirstRunRet) |
DBErrors | ZapSelectTx (std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | SetAddressBook (const CTxDestination &address, const std::string &strName, const std::string &purpose) |
bool | DelAddressBook (const CTxDestination &address) |
unsigned int | GetKeyPoolSize () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SetMinVersion (enum WalletFeature, WalletBatch *batch_in=nullptr, bool fExplicit=false) override |
signify that a particular wallet feature is now used. | |
bool | SetMaxVersion (int nVersion) |
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format) | |
int | GetVersion () const |
get the current wallet format (the oldest client version guaranteed to understand this 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) | |
bool | HasWalletSpend (const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Check if a given transaction has any of its outputs spent by another transaction in the wallet. | |
void | Flush () |
Flush wallet (bitdb flush) | |
void | Close () |
Close wallet database. | |
bool | GetBroadcastTransactions () const |
Inquire whether this wallet broadcasts transactions. | |
void | SetBroadcastTransactions (bool broadcast) |
Set whether this wallet broadcasts transactions. | |
bool | TransactionCanBeAbandoned (const TxId &txid) const |
Return whether transaction can be abandoned. | |
bool | AbandonTransaction (const TxId &txid) |
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. | |
void | postInitProcess () |
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init tasks. | |
bool | BackupWallet (const std::string &strDest) const |
bool | IsHDEnabled () const |
bool | CanGetAddresses (bool internal=false) const |
Returns true if the wallet can give out new addresses. | |
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. | |
void | UnsetWalletFlag (uint64_t flag) |
Unsets a single wallet flag. | |
bool | IsWalletFlagSet (uint64_t flag) const override |
Check if a certain wallet flag is set. | |
bool | AddWalletFlags (uint64_t flags) |
Overwrite all flags by the given uint64_t. | |
bool | LoadWalletFlags (uint64_t flags) |
Loads the flags into the wallet. | |
bool | IsLegacy () const |
Determine if we are a legacy wallet. | |
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. | |
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. | |
template<typename... Params> | |
void | WalletLogPrintfToBeContinued (std::string fmt, Params... parameters) const |
bool | UpgradeWallet (int version, bilingual_str &error) |
Upgrade the wallet. | |
std::set< ScriptPubKeyMan * > | GetActiveScriptPubKeyMans () const |
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers. | |
std::set< ScriptPubKeyMan * > | GetAllScriptPubKeyMans () const |
Returns all unique ScriptPubKeyMans. | |
ScriptPubKeyMan * | GetScriptPubKeyMan (const OutputType &type, bool internal) const |
Get the ScriptPubKeyMan for the given OutputType and internal/external chain. | |
ScriptPubKeyMan * | GetScriptPubKeyMan (const CScript &script) const |
Get the ScriptPubKeyMan for a script. | |
ScriptPubKeyMan * | GetScriptPubKeyMan (const uint256 &id) const |
Get the ScriptPubKeyMan by id. | |
std::set< ScriptPubKeyMan * > | GetScriptPubKeyMans (const CScript &script, SignatureData &sigdata) const |
Get all of the ScriptPubKeyMans for a script given additional information in sigdata (populated by e.g. | |
std::unique_ptr< SigningProvider > | GetSolvingProvider (const CScript &script) const |
Get the SigningProvider for a script. | |
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. | |
LegacyScriptPubKeyMan * | GetOrCreateLegacyScriptPubKeyMan () |
void | SetupLegacyScriptPubKeyMan () |
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external. | |
bool | WithEncryptionKey (const std::function< bool(const CKeyingMaterial &)> &cb) const override |
Pass the encryption key to cb(). | |
bool | HasEncryptionKeys () const override |
int | GetLastBlockHeight () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Get last block processed height. | |
BlockHash | GetLastBlockHash () const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SetLastBlockProcessed (int block_height, BlockHash block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Set last block processed height, currently only use in unit test. | |
void | ConnectScriptPubKeyManNotifiers () |
Connect the signals from ScriptPubKeyMans to the signals in CWallet. | |
void | LoadDescriptorScriptPubKeyMan (uint256 id, WalletDescriptor &desc) |
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it. | |
void | AddActiveScriptPubKeyMan (uint256 id, OutputType type, bool internal) |
Adds the active ScriptPubKeyMan for the specified type and internal. | |
void | LoadActiveScriptPubKeyMan (uint256 id, OutputType type, bool internal) |
Loads an active ScriptPubKeyMan for the specified type and internal. | |
void | DeactivateScriptPubKeyMan (const uint256 &id, OutputType type, bool internal) |
Remove specified ScriptPubKeyMan from set of active SPK managers. | |
void | SetupDescriptorScriptPubKeyMans () EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Create new DescriptorScriptPubKeyMans and add them to the wallet. | |
DescriptorScriptPubKeyMan * | GetDescriptorScriptPubKeyMan (const WalletDescriptor &desc) const |
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet. | |
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. | |
Public Member Functions inherited from WalletStorage | |
virtual | ~WalletStorage ()=default |
Public Member Functions inherited from interfaces::Chain::Notifications | |
virtual | ~Notifications () |
Static Public Member Functions | |
static std::shared_ptr< CWallet > | Create (interfaces::Chain &chain, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings) |
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error. | |
Public Attributes | |
RecursiveMutex | cs_wallet |
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. | |
Mutex | m_unlock_mutex |
CFeeRate | m_pay_tx_fee {DEFAULT_PAY_TX_FEE} |
bool | m_spend_zero_conf_change {DEFAULT_SPEND_ZEROCONF_CHANGE} |
bool | m_allow_fallback_fee {true} |
will be false if -fallbackfee=0 | |
CFeeRate | m_min_fee {DEFAULT_TRANSACTION_MINFEE_PER_KB} |
CFeeRate | m_fallback_fee {DEFAULT_FALLBACK_FEE} |
If fee estimation does not have enough data to provide estimates, use this fee instead. | |
Amount | m_max_aps_fee {DEFAULT_MAX_AVOIDPARTIALSPEND_FEE} |
note: this is absolute fee, not fee rate | |
OutputType | m_default_address_type {DEFAULT_ADDRESS_TYPE} |
std::optional< OutputType > | m_default_change_type {} |
Default output type for change outputs. | |
Amount | m_default_max_tx_fee {DEFAULT_TRANSACTION_MAXFEE} |
Absolute maximum transaction fee (in satoshis) used by default for the wallet. | |
boost::signals2::signal< void()> | NotifyUnload |
Wallet is about to be unloaded. | |
boost::signals2::signal< void(CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> | NotifyAddressBookChanged |
Address book entry changed. | |
boost::signals2::signal< void(CWallet *wallet, const TxId &txid, ChangeType status)> | NotifyTransactionChanged |
Wallet transaction added, removed or updated. | |
boost::signals2::signal< void(const std::string &title, int nProgress)> | ShowProgress |
Show progress e.g. | |
boost::signals2::signal< void(bool fHaveWatchOnly)> | NotifyWatchonlyChanged |
Watch-only address added. | |
boost::signals2::signal< void()> | NotifyCanGetAddressesChanged |
Keypool has new keys. | |
boost::signals2::signal< void(CWallet *wallet)> | NotifyStatusChanged |
Wallet status (encrypted, locked) changed. | |
Private Types | |
typedef std::multimap< COutPoint, TxId > | TxSpends |
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated transactions where the mutant gets mined). | |
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 | |
int nWalletMaxVersion | GUARDED_BY (cs_wallet) |
the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded | |
TxSpends mapTxSpends | GUARDED_BY (cs_wallet) |
void | AddToSpends (const COutPoint &outpoint, const TxId &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | AddToSpends (const TxId &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
bool | AddToWalletIfInvolvingMe (const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Add a transaction to the wallet, or update it. | |
void | MarkConflicted (const BlockHash &hashBlock, int conflicting_height, const TxId &txid) |
Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. | |
void | MarkInputsDirty (const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed. | |
void | SyncMetaData (std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
void | SyncTransaction (const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) |
Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions. | |
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. | |
void | UnsetBlankWalletFlag (WalletBatch &batch) override |
Unset the blank wallet flag and saves it to disk. | |
BlockHash 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. | |
int m_last_block_processed_height | GUARDED_BY (cs_wallet) |
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 |
bool | fBroadcastTransactions = false |
std::atomic< int64_t > | m_best_block_time {0} |
std::atomic< uint64_t > | m_wallet_flags {0} |
interfaces::Chain * | m_chain |
Interface for accessing chain state. | |
std::string | m_name |
Wallet name: relative directory name or "" for default wallet. | |
std::unique_ptr< WalletDatabase > | database |
Internal database handle. | |
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> CWallet::MasterKeyMap |
typedef std::multimap<int64_t, CWalletTx *> CWallet::TxItems |
|
private |
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 |
|
inline |
void 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 3368 of file wallet.cpp.
bool CWallet::AddDestData | ( | WalletBatch & | batch, |
const CTxDestination & | dest, | ||
const std::string & | key, | ||
const std::string & | value | ||
) |
Adds a destination data tuple to the store, and saves it to disk When adding new fields, take care to consider how DelAddressBook should handle it!
Definition at line 2619 of file wallet.cpp.
ScriptPubKeyMan * 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 3455 of file wallet.cpp.
bool CWallet::BackupWallet | ( | const std::string & | strDest | ) | const |
Definition at line 3097 of file wallet.cpp.
|
inlineoverridevirtual |
check whether we are allowed to upgrade (or already support) to the named feature
Implements WalletStorage.
Definition at line 486 of file wallet.h.
|
inline |
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 2577 of file wallet.cpp.
void CWallet::ConnectScriptPubKeyManNotifiers | ( | ) |
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition at line 3315 of file wallet.cpp.
|
static |
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error.
Definition at line 2707 of file wallet.cpp.
void CWallet::DeactivateScriptPubKeyMan | ( | const 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 3406 of file wallet.cpp.
|
inline |
bool CWallet::EraseDestData | ( | WalletBatch & | batch, |
const CTxDestination & | dest, | ||
const std::string & | key | ||
) |
Erases a destination data tuple in the store and on disk.
Definition at line 2629 of file wallet.cpp.
const CAddressBookData * CWallet::FindAddressBookEntry | ( | const CTxDestination & | dest, |
bool | allow_change = false |
||
) | const |
Definition at line 3031 of file wallet.cpp.
std::set< ScriptPubKeyMan * > CWallet::GetActiveScriptPubKeyMans | ( | ) | const |
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition at line 3189 of file wallet.cpp.
std::set< ScriptPubKeyMan * > CWallet::GetAllScriptPubKeyMans | ( | ) | const |
Returns all unique ScriptPubKeyMans.
Definition at line 3202 of file wallet.cpp.
|
inline |
|
inlineoverridevirtual |
Implements WalletStorage.
Definition at line 396 of file wallet.h.
|
inline |
DescriptorScriptPubKeyMan * CWallet::GetDescriptorScriptPubKeyMan | ( | const WalletDescriptor & | desc | ) | const |
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition at line 3439 of file wallet.cpp.
bool CWallet::GetDestData | ( | const CTxDestination & | dest, |
const std::string & | key, | ||
std::string * | value | ||
) | const |
Look up a destination data tuple in the store, return true if found false otherwise.
Definition at line 2643 of file wallet.cpp.
std::vector< std::string > CWallet::GetDestValues | ( | const std::string & | prefix | ) | const |
Get all destination values matching a prefix.
Definition at line 2662 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 WalletStorage.
Definition at line 955 of file wallet.h.
|
inline |
|
inline |
LegacyScriptPubKeyMan * CWallet::GetLegacyScriptPubKeyMan | ( | ) | const |
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition at line 3271 of file wallet.cpp.
|
inline |
LegacyScriptPubKeyMan * CWallet::GetOrCreateLegacyScriptPubKeyMan | ( | ) |
Definition at line 3285 of file wallet.cpp.
ScriptPubKeyMan * CWallet::GetScriptPubKeyMan | ( | const CScript & | script | ) | const |
Get the ScriptPubKeyMan for a script.
Definition at line 3237 of file wallet.cpp.
ScriptPubKeyMan * CWallet::GetScriptPubKeyMan | ( | const OutputType & | type, |
bool | internal | ||
) | const |
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition at line 3210 of file wallet.cpp.
ScriptPubKeyMan * CWallet::GetScriptPubKeyMan | ( | const uint256 & | id | ) | const |
Get the ScriptPubKeyMan by id.
Definition at line 3247 of file wallet.cpp.
std::set< ScriptPubKeyMan * > CWallet::GetScriptPubKeyMans | ( | const CScript & | script, |
SignatureData & | sigdata | ||
) | const |
Get all of the ScriptPubKeyMans for a script given additional information in sigdata (populated by e.g.
a psbt)
Definition at line 3226 of file wallet.cpp.
std::unique_ptr< SigningProvider > CWallet::GetSolvingProvider | ( | const CScript & | script | ) | const |
Get the SigningProvider for a script.
Definition at line 3255 of file wallet.cpp.
std::unique_ptr< SigningProvider > CWallet::GetSolvingProvider | ( | const CScript & | script, |
SignatureData & | sigdata | ||
) | const |
Definition at line 3124 of file wallet.cpp.
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 3114 of file wallet.cpp.
|
inline |
|
private |
|
private |
the current wallet version: clients below this version are not able to load the wallet
|
private |
the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
|
private |
|
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 |
std::map< CTxDestination, CAddressBookData > m_address_book CWallet::GUARDED_BY | ( | cs_wallet | ) |
std::set< COutPoint > setLockedCoins CWallet::GUARDED_BY | ( | cs_wallet | ) |
|
inline |
|
pure virtual |
|
overridevirtual |
Implements WalletStorage.
Definition at line 3311 of file wallet.cpp.
|
inline |
|
inline |
bool CWallet::IsCrypted | ( | ) | const |
Definition at line 3143 of file wallet.cpp.
bool CWallet::IsLegacy | ( | ) | const |
Determine if we are a legacy wallet.
Definition at line 3429 of file wallet.cpp.
|
overridevirtual |
Implements WalletStorage.
Definition at line 3147 of file wallet.cpp.
|
inline |
void 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 3379 of file wallet.cpp.
void CWallet::LoadDescriptorScriptPubKeyMan | ( | uint256 | id, |
WalletDescriptor & | desc | ||
) |
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition at line 3323 of file wallet.cpp.
void 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 2638 of file wallet.cpp.
bool CWallet::Lock | ( | ) |
Definition at line 3155 of file wallet.cpp.
void CWallet::postInitProcess | ( | ) |
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init tasks.
Definition at line 3086 of file wallet.cpp.
|
inline |
|
inline |
void CWallet::SetupDescriptorScriptPubKeyMans | ( | ) |
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition at line 3330 of file wallet.cpp.
void CWallet::SetupLegacyScriptPubKeyMan | ( | ) |
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition at line 3290 of file wallet.cpp.
|
private |
Definition at line 3174 of file wallet.cpp.
bool CWallet::UpgradeWallet | ( | int | version, |
bilingual_str & | error | ||
) |
Upgrade the wallet.
Definition at line 3043 of file wallet.cpp.
|
inline |
|
inline |
|
overridevirtual |
Pass the encryption key to cb().
Implements WalletStorage.
Definition at line 3305 of file wallet.cpp.
|
friend |
|
mutable |
|
private |
|
private |
|
private |
std::unique_ptr<interfaces::Handler> CWallet::m_chain_notifications_handler |
Registered interfaces::Chain::Notifications handler.
OutputType CWallet::m_default_address_type {DEFAULT_ADDRESS_TYPE} |
std::optional<OutputType> 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 implementation in CWallet::TransactionChangeType for details).
Amount CWallet::m_default_max_tx_fee {DEFAULT_TRANSACTION_MAXFEE} |
|
private |
CFeeRate CWallet::m_fallback_fee {DEFAULT_FALLBACK_FEE} |
|
private |
Amount CWallet::m_max_aps_fee {DEFAULT_MAX_AVOIDPARTIALSPEND_FEE} |
CFeeRate CWallet::m_min_fee {DEFAULT_TRANSACTION_MINFEE_PER_KB} |
|
private |
CFeeRate CWallet::m_pay_tx_fee {DEFAULT_PAY_TX_FEE} |
|
private |
bool CWallet::m_spend_zero_conf_change {DEFAULT_SPEND_ZEROCONF_CHANGE} |
|
private |
MasterKeyMap CWallet::mapMasterKeys |
boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> CWallet::NotifyAddressBookChanged |
boost::signals2::signal<void()> CWallet::NotifyCanGetAddressesChanged |
boost::signals2::signal<void(CWallet *wallet, const TxId &txid, ChangeType status)> CWallet::NotifyTransactionChanged |
boost::signals2::signal<void()> CWallet::NotifyUnload |