7#ifndef BITCOIN_WALLET_WALLET_H
8#define BITCOIN_WALLET_WALLET_H
46#include <boost/signals2/signal.hpp>
51 std::function<void(std::unique_ptr<interfaces::Wallet>
wallet)>;
64 const std::shared_ptr<CWallet> &
wallet,
65 std::optional<bool> load_on_start,
66 std::vector<bilingual_str> &warnings);
68 const std::shared_ptr<CWallet> &
wallet,
69 std::optional<bool> load_on_start);
73 const std::string &
name);
74std::shared_ptr<CWallet>
78 std::vector<bilingual_str> &warnings);
79std::shared_ptr<CWallet>
83 std::vector<bilingual_str> &warnings);
84std::shared_ptr<CWallet>
86 const std::string &wallet_name, std::optional<bool> load_on_start,
88 std::vector<bilingual_str> &warnings);
92 const std::shared_ptr<CWallet> &
wallet);
93std::unique_ptr<WalletDatabase>
252 size_t change_spend_size_,
CFeeRate effective_fee_,
253 size_t tx_noinputs_size_,
bool avoid_partial)
274 bool accept_no_keys =
false);
281 SteadyClock::time_point{}};
342 void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>)
358 const std::string &strName,
359 const std::string &strPurpose);
408 std::vector<bilingual_str> &warnings);
435 std::unique_ptr<WalletDatabase> _database)
455 typedef std::multimap<int64_t, CWalletTx *>
TxItems;
461 std::map<CTxDestination, CAddressBookData>
465 bool allow_change =
false) const
515 return nWalletMaxVersion >= wf;
518 bool IsSpent(
const COutPoint &outpoint)
const
525 bool used, std::set<CTxDestination> &tx_destinations)
545 : SteadyClock::duration{};
557 nWalletVersion = nVersion;
558 nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion);
568 const std::string &key,
const std::string &value)
572 const std::string &key)
576 const std::string &value)
581 std::string *value)
const
595 bool accept_no_keys =
false);
627 bool fFlushOnClose = true);
631 uint64_t mempool_sequence) override;
633 int height) override;
656 std::optional<int> max_height,
661 uint64_t mempool_sequence)
override;
674 const
std::map<COutPoint,
Coin> &coins,
676 std::map<
int,
std::
string> &input_errors) const;
678 std::
string &str_sig) const;
698 bool sign = true,
bool bip32derivs = true) const;
713 std::vector<
std::pair<
std::
string,
std::
string>> orderForm,
714 bool broadcast = true);
721 std::
string &err_string,
bool relay) const
725 bool use_max_sig = false)
const {
726 std::vector<CTxOut> v_txouts(txouts.size());
727 std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
731 const std::vector<CTxOut> &txouts,
732 bool use_max_sig =
false)
const;
734 bool use_max_sig =
false)
const;
736 bool ImportScripts(
const std::set<CScript> scripts, int64_t timestamp)
739 const int64_t timestamp)
742 const std::vector<CKeyID> &ordered_pubkeys,
743 const std::map<CKeyID, CPubKey> &pubkey_map,
744 const std::map<
CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
745 const bool add_keypool,
const bool internal,
const int64_t timestamp)
748 const std::set<CScript> &script_pub_keys,
749 const bool have_solving_data,
750 const bool apply_label,
const int64_t timestamp)
797 const
std::
string &label);
812 bool IsMine(const CTransaction &tx) const
815 bool IsFromMe(const CTransaction &tx) const;
826 const
std::
string &strName, const
std::
string &purpose);
835 bool fExplicit = false) override;
845 return nWalletVersion;
872 const std::string &label,
bool isMine,
873 const std::string &purpose,
ChangeType status)>
885 boost::signals2::signal<void(
const std::string &title,
int nProgress)>
920 static std::shared_ptr<CWallet>
922 std::unique_ptr<WalletDatabase>
database,
924 std::vector<bilingual_str> &warnings);
984 std::string wallet_name =
993 template <
typename...
Params>
998 template <
typename...
Params>
1000 Params... parameters)
const {
1018 bool internal)
const;
1027 std::set<ScriptPubKeyMan *>
1031 std::unique_ptr<SigningProvider>
1033 std::unique_ptr<SigningProvider>
1046 const std::function<
bool(
const CKeyingMaterial &)> &cb)
const override;
1053 assert(m_last_block_processed_height >= 0);
1054 return m_last_block_processed_height;
1058 assert(m_last_block_processed_height >= 0);
1059 return m_last_block_processed;
1065 m_last_block_processed_height = block_height;
1066 m_last_block_processed = block_hash;
1117 const
std::
string &label,
bool internal)
1140 if (
m_wallet.fScanningWallet.exchange(
true)) {
1143 m_wallet.m_scanning_start = SteadyClock::now();
1166 const std::string &wallet_name);
static constexpr Amount SATOSHI
static constexpr Amount COIN
const CChainParams & Params()
Return the currently selected parameters.
std::map< std::string, std::string > StringMap
const std::string & GetLabel() const
void SetLabel(const std::string &label)
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Fee rate in satoshis per kilobyte: Amount / kB.
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
std::atomic< int64_t > m_best_block_time
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::map< CTxDestination, CAddressBookData > m_address_book GUARDED_BY(cs_wallet)
int64_t nRelockTime GUARDED_BY(cs_wallet)
Holds a timestamp at which point the wallet is scheduled (externally) to be relocked.
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....
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
std::map< unsigned int, CMasterKey > MasterKeyMap
bool HaveChain() const
Interface to assert chain access.
int GetTxBlocksToMaturity(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
int nWalletVersion GUARDED_BY(cs_wallet)
the current wallet version: clients below this version are not able to load the wallet
double ScanningProgress() const
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
uint64_t nAccountingEntryNumber
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
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,...
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
MasterKeyMap mapMasterKeys
std::string m_name
Wallet name: relative directory name or "" for default 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 blockch...
bool IsTxImmatureCoinBase(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
SteadyClock::duration ScanningDuration() const
std::multimap< COutPoint, TxId > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
bool IsAbortingRescan() const
interfaces::Chain & chain() const
Interface for accessing chain state.
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
WalletDatabase & GetDatabase() override
interfaces::Chain * m_chain
Interface for accessing chain state.
std::atomic< bool > m_attaching_chain
bool WithEncryptionKey(const std::function< bool(const CKeyingMaterial &)> &cb) const override
Pass the encryption key to cb().
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
void DeactivateScriptPubKeyMan(const uint256 &id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
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.
CFeeRate m_fallback_fee
If fee estimation does not have enough data to provide estimates, use this fee instead.
bool IsLegacy() const
Determine if we are a legacy wallet.
std::atomic< bool > fAbortRescan
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
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.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
OutputType m_default_address_type
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
static bool AttachChain(const std::shared_ptr< CWallet > &wallet, interfaces::Chain &chain, 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...
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
std::atomic< uint64_t > m_wallet_flags
Amount m_max_aps_fee
note: this is absolute fee, not fee rate
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
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 BackupWallet(const std::string &strDest) const
int64_t nOrderPosNext GUARDED_BY(cs_wallet)=0
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,...
bool IsTxInMainChain(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
TxSpends mapTxSpends GUARDED_BY(cs_wallet)
std::map< TxId, CWalletTx > mapWallet GUARDED_BY(cs_wallet)
void WalletLogPrintfToBeContinued(std::string fmt, Params... parameters) const
std::unique_ptr< WalletDatabase > database
Internal database handle.
std::atomic< SteadyClock::time_point > m_scanning_start
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.
int m_last_block_processed_height GUARDED_BY(cs_wallet)
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::vector< std::string > GetDestValues(const std::string &prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get all destination values matching a prefix.
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
bool IsLocked() const override
bool m_allow_fallback_fee
will be false if -fallbackfee=0
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
std::atomic< double > m_scanning_progress
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
WalletDatabase & GetDBHandle()
Get database handle used by this wallet.
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
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.
boost::signals2::signal< void(CWallet *wallet, const TxId &txid, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
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)
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error.
bool HasEncryptionKeys() const override
bool m_spend_zero_conf_change
CWallet(interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > _database)
Construct wallet with specified name and database implementation.
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
bool fBroadcastTransactions
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
std::atomic< bool > fScanningWallet
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
std::multimap< int64_t, CWalletTx * > TxItems
int nWalletMaxVersion GUARDED_BY(cs_wallet)
the maximum wallet format version: memory-only variable that specifies to what version this wallet ma...
std::string GetDisplayName() const override
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet ha...
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
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.
unsigned int nMasterKeyMaxID
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
void SetLastBlockProcessed(int block_height, BlockHash block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
A transaction with a bunch of additional info that only the owner cares about.
A wrapper to reserve an address from a wallet.
bool fInternal
Whether this is from the internal (change output) keypool.
ReserveDestination & operator=(const ReserveDestination &)=delete
~ReserveDestination()
Destructor.
ReserveDestination(CWallet *_pwallet, OutputType _type)
Construct a ReserveDestination object.
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from.
int64_t nIndex
The index of the address's key in the keypool.
CTxDestination address
The destination.
ReserveDestination(const ReserveDestination &)=delete
const CWallet *const pwallet
The wallet to reserve from.
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
Signature hash type wrapper class.
Access to the wallet database.
An instance of this class represents one database.
Descriptor with some wallet metadata.
RAII object to check and reserve a wallet rescan.
WalletRescanReserver(CWallet &w)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
void LockCoin(const COutPoint &output) 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 ...
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
util::Result< CTxDestination > GetNewDestination(const OutputType type, const std::string &label)
util::Result< CTxDestination > GetNewChangeDestination(const OutputType type)
void KeepDestination()
Keep the address.
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void ReturnDestination()
Return reserved address.
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TopUpKeyPool(unsigned int kpSize=0)
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
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.
bool GetReservedDestination(CTxDestination &pubkey, bool internal)
Reserve an address.
int64_t GetOldestKeyPoolTime() const
bool DelAddressBook(const CTxDestination &address)
DBErrors ZapSelectTx(std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut) EXCLUSIVE_LOCKS_REQUIRED(cs_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 AddWalletFlags(uint64_t flags)
Overwrite all flags by the given uint64_t.
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 LoadToWallet(const TxId &txid, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
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 Flush()
Flush wallet (bitdb flush)
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
bool SetMaxVersion(int nVersion)
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading...
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 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.
void AddToSpends(const COutPoint &outpoint, const TxId &wtxid) 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 ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
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.
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
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...
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void blockConnected(ChainstateRole role, const CBlock &block, int height) override
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the 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)
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
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.
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TransactionCanBeAbandoned(const TxId &txid) const
Return whether transaction can be abandoned.
const CChainParams & GetChainParams() const override
Amount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed.
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool EncryptWallet(const SecureString &strWalletPassphrase)
void chainStateFlushed(ChainstateRole role, const CBlockLocator &loc) override
void updatedBlockTip() override
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
void SetSpentKeyState(WalletBatch &batch, const TxId &txid, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
DBErrors ReorderTransactions()
void blockDisconnected(const CBlock &block, int height) override
void Close()
Close wallet database.
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
const CWalletTx * GetWalletTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void ResendWalletTransactions()
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr, bool fExplicit=false) override
signify that a particular wallet feature is now used.
std::set< TxId > GetTxConflicts(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
isminetype
IsMine() return codes.
ChainstateRole
This enum describes the various roles a specific Chainstate instance can take.
#define LogPrintfToBeContinued
These are aliases used to explicitly state that the message should not end with a newline character.
Implement std::hash so RCUPtr can be used as a key for maps or sets.
std::shared_ptr< const CTransaction > CTransactionRef
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
bool fSubtractFeeFromAmount
std::optional< int > last_scanned_height
BlockHash last_scanned_block
Hash and height of most recent block that was successfully scanned.
BlockHash last_failed_block
Hash of the most recent block that could not be scanned due to read errors or pruning.
Confirmation includes tx status and a triplet of {block height/block hash/tx index in block} at which...
bool m_subtract_fee_outputs
Indicate that we are subtracting the fee from outputs.
CoinSelectionParams(bool use_bnb_, size_t change_output_size_, size_t change_spend_size_, CFeeRate effective_fee_, size_t tx_noinputs_size_, bool avoid_partial)
bool m_avoid_partial_spends
size_t change_output_size
A version of CTransaction with the PSBT format.
A TxId is the identifier of a transaction.
WalletContext struct containing references to state shared between CWallet instances,...
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define LOCKS_EXCLUDED(...)
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
ChangeType
General change type (added, updated, removed).
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
std::shared_ptr< CWallet > m_wallet
std::map< std::string, std::string > mapValue_t
constexpr Amount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
constexpr Amount DEFAULT_PAY_TX_FEE
-paytxfee default
static const bool DEFAULT_DISABLE_WALLET
std::unique_ptr< interfaces::Handler > HandleLoadWallet(WalletContext &context, LoadWalletFn load_wallet)
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
static constexpr uint64_t MUTABLE_WALLET_FLAGS
constexpr Amount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
static constexpr size_t DUMMY_P2PKH_INPUT_SIZE
Pre-calculated constants for input size estimation.
static const Amount DEFAULT_FALLBACK_FEE
-fallbackfee default
static const Amount DEFAULT_TRANSACTION_MINFEE_PER_KB
-mintxfee default
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
static constexpr uint64_t KNOWN_WALLET_FLAGS
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
constexpr Amount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
static const Amount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Add wallet name to persistent configuration so it will be loaded on startup.
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 RemoveWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Remove wallet name from persistent configuration so it will not be loaded on startup.
static const bool DEFAULT_WALLETBROADCAST
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
constexpr Amount HIGH_APS_FEE
discourage APS fee higher than this amount
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)
static const Amount WALLET_INCREMENTAL_RELAY_FEE(5000 *SATOSHI)
minimum recommended increment for BIP 125 replacement txs
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)
void NotifyWalletLoaded(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
DBErrors
Error statuses for the wallet database.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
WalletFeature
(client) version numbers for particular wallet features