6 #ifndef BITCOIN_WALLET_WALLET_H 7 #define BITCOIN_WALLET_WALLET_H 43 #include <boost/signals2/signal.hpp> 57 bool RemoveWallet(
const std::shared_ptr<CWallet>&
wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
58 bool RemoveWallet(
const std::shared_ptr<CWallet>&
wallet, std::optional<bool> load_on_start);
59 std::vector<std::shared_ptr<CWallet>>
GetWallets();
255 typedef std::multimap<COutPoint, uint256>
TxSpends;
360 bool SelectCoins(
const std::vector<COutput>& vAvailableCoins,
const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet,
CAmount& nValueRet,
396 typedef std::multimap<int64_t, CWalletTx*>
TxItems;
553 Balance
GetBalance(
int min_depth = 0,
bool avoid_reuse =
true)
const;
584 int sighash_type = 1 ,
586 bool bip32derivs =
true,
587 size_t* n_signed =
nullptr)
const;
608 std::vector<CTxOut> v_txouts(txouts.size());
609 std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
617 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);
735 const std::string& label,
bool isMine,
736 const std::string& purpose,
ChangeType status)>
746 boost::signals2::signal<void (const std::string &title, int nProgress)>
ShowProgress;
800 void SetWalletFlag(uint64_t
flags);
819 std::string wallet_name =
GetName().length() == 0 ?
"default wallet" :
GetName();
824 template<
typename...
Params>
867 assert(m_last_block_processed_height >= 0);
868 return m_last_block_processed_height;
873 assert(m_last_block_processed_height >= 0);
874 return m_last_block_processed;
880 m_last_block_processed_height = block_height;
881 m_last_block_processed = block_hash;
936 if (
m_wallet.fScanningWallet.exchange(
true)) {
976 #endif // BITCOIN_WALLET_WALLET_H std::shared_ptr< const CTransaction > CTransactionRef
constexpr CAmount HIGH_APS_FEE
discourage APS fee higher than this amount
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
std::atomic< bool > fScanningWallet
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)
void Close()
Close wallet database.
void AvailableCoins(std::vector< COutput > &vCoins, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
populate vCoins with vector of available COutputs.
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
int64_t nNextResend
The next scheduled rebroadcast of wallet transactions.
void SetSpentKeyState(WalletBatch &batch, const uint256 &hash, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void blockConnected(const CBlock &block, int height) override
bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Add wallet name to persistent configuration so it will be loaded on startup.
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLegacy() const
Determine if we are a legacy wallet.
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
bool IsFeatureSupported(int wallet_version, int feature_version)
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
constexpr CAmount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
uint64_t nAccountingEntryNumber
CTxDestination address
The destination.
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
std::atomic< int64_t > m_best_block_time
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
bool IsTrusted(const CWalletTx &wtx, std::set< uint256 > &trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
int64_t GetTimeMillis()
Returns the system time (not mockable)
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
const std::string & GetLabel() const
const CTxOut & FindNonChangeParentOutput(const CTransaction &tx, int output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Find non-change parent output.
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
std::optional< int > last_scanned_height
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
static const CAmount COIN
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::set< std::set< CTxDestination > > GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const
Returns whether all of the inputs match the filter.
int64_t GetOldestKeyPoolTime() const
std::shared_ptr< CWallet > m_wallet
std::multimap< COutPoint, uint256 > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
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...
bool RemoveWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Remove wallet name from persistent configuration so it will not be loaded on startup.
void blockDisconnected(const CBlock &block, int height) override
const CKeyingMaterial & GetEncryptionKey() const override
bool FundTransaction(CMutableTransaction &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl)
Insert additional inputs into the transaction by calling CreateTransaction();.
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
bool CanGetAddresses(bool internal=false) const
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
int nWalletVersion GUARDED_BY(cs_wallet)
the current wallet version: clients below this version are not able to load the wallet ...
static const bool DEFAULT_DISABLE_WALLET
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
bool fSubtractFeeFromAmount
bool IsLocked() const override
A version of CTransaction with the PSBT format.
std::map< unsigned int, CMasterKey > MasterKeyMap
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig=false) EXCLUSIVE_LOCKS_REQUIRED(wallet -> cs_wallet)
Calculate the size of the transaction assuming all signatures are max size Use DummySignatureCreator...
Indicates that the wallet needs an external signer.
CAmount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
void LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Adds a destination data tuple to the store, without saving it to disk.
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
int64_t ScanningDuration() const
void chainStateFlushed(const CBlockLocator &loc) override
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
std::atomic< bool > fAbortRescan
bool MarkReplaced(const uint256 &originalHash, const uint256 &newHash)
Mark a transaction as replaced by another transaction (e.g., BIP 125).
DBErrors
Error statuses for the wallet database.
bool EncryptWallet(const SecureString &strWalletPassphrase)
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Balance GetBalance(int min_depth=0, bool avoid_reuse=true) const
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CAmount m_max_aps_fee
The maximum fee amount we're willing to pay to prioritize partial spend avoidance.
static const bool DEFAULT_WALLET_RBF
-walletrbf default
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
WalletFeature
(client) version numbers for particular wallet features
bool BackupWallet(const std::string &strDest) const
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
CFeeRate m_min_fee
Override with -mintxfee.
double ScanningProgress() const
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Access to the wallet database.
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::unique_ptr< interfaces::Handler > HandleLoadWallet(LoadWalletFn load_wallet)
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
interfaces::Chain & chain() const
Interface for accessing chain state.
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
bool CreateTransactionInternal(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
int64_t CAmount
Amount in satoshis (Can be negative)
CFeeRate m_fallback_fee
If fee estimation does not have enough data to provide estimates, use this fee instead.
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
bool HasEncryptionKeys() const override
DBErrors ReorderTransactions()
Parameters for filtering which OutputGroups we may use in coin selection.
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
bool DelAddressBook(const CTxDestination &address)
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
unsigned int nMasterKeyMaxID
CFeeRate m_discard_rate
If the cost to spend a change output at this feerate is greater than the value of the output itself...
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
A group of UTXOs paid to the same output script.
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 AbandonTransaction(const uint256 &hashTx)
CWallet(interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > database)
Construct wallet with specified name and database implementation.
ScriptPubKeyMan * 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.
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...
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet...
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
An input of a transaction.
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
OutputType m_default_address_type
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
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 SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
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...
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
int64_t nIndex
The index of the address's key in the keypool.
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.
interfaces::Chain * m_chain
Interface for accessing chain state.
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::unique_ptr< WalletDatabase > const m_database
Internal database handle.
static const bool DEFAULT_WALLETBROADCAST
std::map< std::string, std::string > StringMap
bool AttemptSelection(const CAmount &nTargetValue, const CoinEligibilityFilter &eligibility_filter, std::vector< COutput > coins, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CoinSelectionParams &coin_selection_params) const
Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is st...
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses, and other watch only things, and is therefore "blank.".
ReserveDestination(CWallet *pwallet, OutputType type)
Construct a ReserveDestination object. This does NOT reserve an address yet.
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
std::vector< OutputGroup > GroupOutputs(const std::vector< COutput > &outputs, const CoinSelectionParams &coin_sel_params, const CoinEligibilityFilter &filter, bool positive_only) const
bool HaveChain() const
Interface to assert chain access.
CAmount GetChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, 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)
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
ReserveDestination & operator=(const ReserveDestination &)=delete
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
void SetLastBlockProcessed(int block_height, uint256 block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
An output of a transaction.
std::shared_ptr< CWallet > GetWallet(const std::string &name)
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)
std::map< CTxDestination, CAmount > GetAddressBalances() const
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
Descriptor with some wallet metadata.
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
An outpoint - a combination of a transaction hash and an index n into its vout.
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
std::map< std::string, std::string > mapValue_t
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool...
void updatedBlockTip() override
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::map< CTxDestination, std::vector< COutput > > ListCoins() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Return list of available coins and locked coins grouped by non-change output address.
RAII object to check and reserve a wallet rescan.
A transaction with a bunch of additional info that only the owner cares about.
size_t KeypoolCountExternalKeys() const 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...
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
std::vector< std::string > GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
bool SelectCoins(const std::vector< COutput > &vAvailableCoins, const CAmount &nTargetValue, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CCoinControl &coin_control, CoinSelectionParams &coin_selection_params) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Select a set of coins such that nValueRet >= nTargetValue and at least all coins from coin_control ar...
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
bool fBroadcastTransactions
Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadca...
static constexpr uint64_t MUTABLE_WALLET_FLAGS
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 ...
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade DescriptorCaches.
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
unsigned int m_confirm_target
WalletDatabase & GetDatabase() const override
CoinSelectionParams coin_selection_params(0, 0, CFeeRate(0), CFeeRate(0), CFeeRate(0), 0, false)
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
#define LOCKS_EXCLUDED(...)
CAmount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
std::atomic< uint64_t > m_wallet_flags
WalletFlags set on this wallet.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
MasterKeyMap mapMasterKeys
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
void ResendWalletTransactions()
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
const CChainParams & Params()
Return the currently selected parameters.
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const
Serialized script, used inside transaction inputs and outputs.
bool GetReservedDestination(CTxDestination &pubkey, bool internal, std::string &error)
Reserve an address.
bool TopUpKeyPool(unsigned int kpSize=0)
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
bool SetAddressReceiveRequest(WalletBatch &batch, const CTxDestination &dest, const std::string &id, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
A reference to a CKey: the Hash160 of its serialized public key.
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, int sighash_type=1, bool sign=true, bool bip32derivs=true, size_t *n_signed=nullptr) const
Fills out a PSBT with information from the wallet.
void SetLabel(const std::string &label)
std::set< uint256 > GetConflicts(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get wallet transactions that conflict with given transaction (spend same outputs) ...
boost::signals2::signal< void(const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Parameters for one iteration of Coin Selection.
Fee rate in satoshis per kilobyte: CAmount / kB.
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed.
const std::string GetDisplayName() const override
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet ha...
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
A wrapper to reserve an address from a wallet.
bool LoadToWallet(const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
RecursiveMutex cs_wallet
Main wallet lock.
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
bool fInternal
Whether this is from the internal (change output) keypool.
A mutable version of CTransaction.
uint256 last_failed_block
Height of the most recent block that could not be scanned due to read errors or pruning.
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
static std::vector< COutput > vCoins
bool IsSpent(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction spends it:
void Flush()
Flush wallet (bitdb flush)
std::atomic< int64_t > m_scanning_start
std::string m_name
Wallet name: relative directory name or "" for default wallet.
The basic transaction that is broadcasted on the network and contained in blocks. ...
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
Confirmation includes tx status and a triplet of {block height/block hash/tx index in block} at which...
bool IsAddressUsed(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::atomic< double > m_scanning_progress
ChangeType
General change type (added, updated, removed).
bool m_allow_fallback_fee
will be false if -fallbackfee=0
Indicate that this wallet supports DescriptorScriptPubKeyMan.
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
std::multimap< int64_t, CWalletTx * > TxItems
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
bool error(const char *fmt, const Args &... args)
const CWallet *const pwallet
The wallet to reserve from.
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Fetch the inputs and sign with SIGHASH_ALL.
CAmount GetAvailableBalance(const CCoinControl *coinControl=nullptr) const
WalletRescanReserver(CWallet &w)
static const CAmount DEFAULT_DISCARD_FEE
-discardfee default
bool AddWalletFlags(uint64_t flags)
overwrite all flags by the given uint64_t returns false if unknown, non-tolerable flags are present ...
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
std::vector< std::shared_ptr< CWallet > > GetWallets()
boost::signals2::signal< void(const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
bool SetAddressUsed(WalletBatch &batch, const CTxDestination &dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
static constexpr uint64_t KNOWN_WALLET_FLAGS
void KeepDestination()
Keep the address. Do not return it's key to the keypool when this object goes out of scope...
constexpr CAmount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
void ReturnDestination()
Return reserved address.
bool IsAbortingRescan() const
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called...
An instance of this class represents one database.
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE
Pre-calculated constants for input size estimation in virtual size