 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
6 #ifndef BITCOIN_WALLET_WALLET_H
7 #define BITCOIN_WALLET_WALLET_H
42 #include <boost/signals2/signal.hpp>
63 bool RemoveWallet(WalletContext&
context,
const std::shared_ptr<CWallet>&
wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
261 typedef std::multimap<COutPoint, uint256>
TxSpends;
394 typedef std::multimap<int64_t, CWalletTx*>
TxItems;
570 bool bip32derivs = true,
571 size_t* n_signed =
nullptr,
572 bool finalize = true) const;
590 std::vector<CTxOut> v_txouts(txouts.size());
591 std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
598 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);
710 const std::string& label,
bool isMine,
711 const std::string& purpose,
ChangeType status)>
721 boost::signals2::signal<void (
const std::string &title,
int nProgress)>
ShowProgress;
775 void SetWalletFlag(uint64_t
flags);
794 std::string wallet_name =
GetName().length() == 0 ?
"default wallet" :
GetName();
799 template<
typename...
Params>
839 assert(m_last_block_processed_height >= 0);
840 return m_last_block_processed_height;
845 assert(m_last_block_processed_height >= 0);
846 return m_last_block_processed;
852 m_last_block_processed_height = block_height;
853 m_last_block_processed = block_hash;
913 if (
m_wallet.fScanningWallet.exchange(
true)) {
918 m_could_reserve =
true;
924 return (m_could_reserve &&
m_wallet.fScanningWallet);
929 if (m_could_reserve) {
946 #endif // BITCOIN_WALLET_WALLET_H
std::set< ScriptPubKeyMan * > GetScriptPubKeyMans(const CScript &script) const
Get all the ScriptPubKeyMans for a script.
static const bool DEFAULT_WALLETBROADCAST
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 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)
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
An input of a transaction.
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
An instance of this class represents one database.
void updatedBlockTip() override
const CWallet *const pwallet
The wallet to reserve from.
static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CTxDestination address
The destination.
ReserveDestination(CWallet *pwallet, OutputType type)
Construct a ReserveDestination object. This does NOT reserve an address yet.
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
bool SetAddressUsed(WalletBatch &batch, const CTxDestination &dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
bool LoadToWallet(const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
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.
bool fInternal
Whether this is from the internal (change output) keypool.
bool FillInputToWeight(CTxIn &txin, int64_t target_weight)
std::underlying_type< isminetype >::type isminefilter
used for bitflags of isminetype
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
std::atomic< int64_t > m_scanning_start
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
interfaces::Chain & chain() const
Interface for accessing chain state.
std::atomic< bool > fAbortRescan
void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
RAII object to check and reserve a wallet rescan.
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
CWalletTx * AddToWallet(CTransactionRef tx, const TxState &state, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true, bool rescanning_old_block=false)
std::optional< bool > IsInternalScriptPubKeyMan(ScriptPubKeyMan *spk_man) const
Returns whether the provided ScriptPubKeyMan is internal.
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
std::unique_ptr< interfaces::Handler > HandleLoadWallet(WalletContext &context, LoadWalletFn load_wallet)
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
std::optional< int64_t > GetOldestKeyPoolTime() const
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
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.
CFeeRate m_discard_rate
If the cost to spend a change output at this feerate is greater than the value of the output itself,...
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
bool DelAddressBook(const CTxDestination &address)
bool MarkReplaced(const uint256 &originalHash, const uint256 &newHash)
Mark a transaction as replaced by another transaction (e.g., BIP 125).
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
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.
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Fetch the inputs and sign with SIGHASH_ALL.
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
An interface to be implemented by keystores that support signing.
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)
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
bool CanGetAddresses(bool internal=false) const
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
static const CAmount DEFAULT_CONSOLIDATE_FEERATE
-consolidatefeerate default
DBErrors
Error statuses for the wallet database.
bool m_spend_zero_conf_change
Allow Coin Selection to pick unconfirmed UTXOs that were sent from our own wallet if it cannot fund t...
uint64_t nAccountingEntryNumber
A reference to a CKey: the Hash160 of its serialized public key.
bool fSubtractFeeFromAmount
static const CAmount DEFAULT_DISCARD_FEE
-discardfee default
void SetLastBlockProcessed(int block_height, uint256 block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
bool IsTxInMainChain(const CWalletTx &wtx) const
int64_t nNextResend
The next scheduled rebroadcast of wallet transactions.
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
unsigned int m_confirm_target
std::shared_ptr< const CTransaction > CTransactionRef
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
A transaction with a bunch of additional info that only the owner cares about.
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, bilingual_str &error)
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool LockCoin(const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Fee rate in satoshis per kilobyte: CAmount / kB.
unsigned int nMasterKeyMaxID
static constexpr uint64_t KNOWN_WALLET_FLAGS
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
The basic transaction that is broadcasted on the network and contained in blocks.
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool.
uint256 last_failed_block
Height of the most recent block that could not be scanned due to read errors or pruning.
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE
Pre-calculated constants for input size estimation in virtual size
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, bilingual_str &error)
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed.
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
bool IsLocked() const override
WalletFeature
(client) version numbers for particular wallet features
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
bool AbandonTransaction(const uint256 &hashTx)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
CAmount m_max_aps_fee
The maximum fee amount we're willing to pay to prioritize partial spend avoidance.
ChangeType
General change type (added, updated, removed).
#define NO_THREAD_SAFETY_ANALYSIS
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_blo...
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool RemoveWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Remove wallet name from persistent configuration so it will not be loaded on startup.
std::variant< TxStateConfirmed, TxStateInMempool, TxStateInactive > SyncTxState
Subset of states transaction sync logic is implemented to handle.
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
void SetLabel(const std::string &label)
An output of a transaction.
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
MasterKeyMap mapMasterKeys
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.
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
bool IsLegacy() const
Determine if we are a legacy wallet.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
WalletDatabase & GetDatabase() const override
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 blockch...
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
bool HaveChain() const
Interface to assert chain access.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called.
std::set< uint256 > GetTxConflicts(const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS
DBErrors ReorderTransactions()
constexpr CAmount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
unsigned int ComputeTimeSmart(const CWalletTx &wtx, bool rescanning_old_block) const
Compute smart timestamp for a transaction being added to the wallet.
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
bool BackupWallet(const std::string &strDest) const
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CWallet(interfaces::Chain *chain, const std::string &name, const ArgsManager &args, std::unique_ptr< WalletDatabase > database)
Construct wallet with specified name and database implementation.
Access to the wallet database.
int64_t CAmount
Amount in satoshis (Can be negative)
std::atomic< double > m_scanning_progress
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
constexpr CAmount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
@ WALLET_FLAG_AVOID_REUSE
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
std::shared_ptr< CWallet > CreateWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
CFeeRate m_min_fee
Override with -mintxfee.
std::string m_name
Wallet name: relative directory name or "" for default wallet.
void ResendWalletTransactions()
bool IsAddressUsed(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void blockConnected(const CBlock &block, int height) override
@ WALLET_FLAG_LAST_HARDENED_XPUB_CACHED
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
std::atomic< bool > fScanningWallet
Serialized script, used inside transaction inputs and outputs.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade DescriptorCaches.
std::variant< TxStateConfirmed, TxStateInMempool, TxStateConflicted, TxStateInactive, TxStateUnrecognized > TxState
All possible CWalletTx states.
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.
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
constexpr CAmount HIGH_APS_FEE
discourage APS fee higher than this amount
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
int64_t ScanningDuration() const
boost::signals2::signal< void(const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
@ WALLET_FLAG_KEY_ORIGIN_METADATA
bool UnlockCoin(const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
RecursiveMutex cs_wallet
Main wallet lock.
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
bool IsAbortingRescan() const
void Flush()
Flush wallet (bitdb flush)
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
CFeeRate m_fallback_fee
If fee estimation does not have enough data to provide estimates, use this fee instead.
OutputType m_default_address_type
bool GetReservedDestination(CTxDestination &pubkey, bool internal, bilingual_str &error)
Reserve an address.
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
std::vector< std::string > GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
A wrapper to reserve an address from a wallet.
void SyncTransaction(const CTransactionRef &tx, const SyncTxState &state, bool update_tx=true, bool rescanning_old_block=false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const std::unique_ptr< WalletDatabase > m_database
Internal database handle.
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
void KeepDestination()
Keep the address. Do not return it's key to the keypool when this object goes out of scope.
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
#define LOCKS_EXCLUDED(...)
bool fBroadcastTransactions
Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadca...
ReserveDestination & operator=(const ReserveDestination &)=delete
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
static constexpr uint64_t MUTABLE_WALLET_FLAGS
void Close()
Close wallet database.
const std::string GetDisplayName() const override
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet ha...
const ArgsManager & m_args
Provider of aplication-wide arguments.
void blockDisconnected(const CBlock &block, int height) override
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
std::map< std::string, std::string > StringMap
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
static const bool DEFAULT_WALLET_RBF
-walletrbf default
std::shared_ptr< CWallet > LoadWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
A version of CTransaction with the PSBT format.
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
std::optional< int > last_scanned_height
WalletRescanReserver(CWallet &w)
std::shared_ptr< CWallet > RestoreWallet(WalletContext &context, const fs::path &backup_file, const std::string &wallet_name, std::optional< bool > load_on_start, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
bool EncryptWallet(const SecureString &strWalletPassphrase)
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)
std::shared_ptr< CWallet > m_wallet
CAmount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
bool TopUpKeyPool(unsigned int kpSize=0)
boost::signals2::signal< void(const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Add wallet name to persistent configuration so it will be loaded on startup.
const CKeyingMaterial & GetEncryptionKey() const override
bool UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
bool m_allow_fallback_fee
will be false if -fallbackfee=0
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
const CChainParams & Params()
Return the currently selected parameters.
CFeeRate m_consolidate_feerate
When the actual feerate is less than the consolidate feerate, we will tend to make transactions which...
static const bool DEFAULT_DISABLE_WALLET
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
interfaces::Chain * m_chain
Interface for accessing chain state.
void chainStateFlushed(const CBlockLocator &loc) override
int GetTxBlocksToMaturity(const CWalletTx &wtx) const
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
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.
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
void SetSpentKeyState(WalletBatch &batch, const uint256 &hash, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Descriptor with some wallet metadata.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::multimap< int64_t, CWalletTx * > TxItems
bool HasEncryptionKeys() const override
std::atomic< uint64_t > m_wallet_flags
WalletFlags set on this wallet.
int64_t nIndex
The index of the address's key in the keypool.
bool IsSpent(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction spends it:
WalletContext struct containing references to state shared between CWallet instances,...
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
bool error(const char *fmt, const Args &... args)
std::set< uint256 > GetConflicts(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get wallet transactions that conflict with given transaction (spend same outputs)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
A mutable version of CTransaction.
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
std::map< std::string, std::string > mapValue_t
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
std::map< unsigned int, CMasterKey > MasterKeyMap
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
int nWalletVersion GUARDED_BY(cs_wallet)
the current wallet version: clients below this version are not able to load the wallet
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
std::atomic< int64_t > m_best_block_time
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.
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) 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 ...
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, const CCoinControl *coin_control=nullptr) const
void ReturnDestination()
Return reserved address.
CAmount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
bool SetAddressReceiveRequest(WalletBatch &batch, const CTxDestination &dest, const std::string &id, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
const std::string & GetLabel() const
bool AddWalletFlags(uint64_t flags)
overwrite all flags by the given uint64_t returns false if unknown, non-tolerable flags are present
int64_t GetTimeMillis()
Returns the system time (not mockable)
bool IsTxImmatureCoinBase(const CWalletTx &wtx) const
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
bool IsFeatureSupported(int wallet_version, int feature_version)
double ScanningProgress() const
std::multimap< COutPoint, uint256 > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
bool DummySignInput(const SigningProvider &provider, CTxIn &tx_in, const CTxOut &txout, bool use_max_sig)
@ SIGHASH_DEFAULT
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
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.