Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
wallet.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Copyright (c) 2018-2020 The Bitcoin developers
4// Distributed under the MIT software license, see the accompanying
5// file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7#ifndef BITCOIN_WALLET_WALLET_H
8#define BITCOIN_WALLET_WALLET_H
9
10#include <common/system.h>
11#include <consensus/amount.h>
12#include <interfaces/chain.h>
13#include <interfaces/handler.h>
14#include <logging.h>
15#include <outputtype.h>
17#include <psbt.h>
18#include <tinyformat.h>
19#include <util/message.h>
20#include <util/strencodings.h>
21#include <util/string.h>
22#include <util/translation.h>
23#include <util/ui_change_type.h>
24#include <validationinterface.h>
26#include <wallet/crypter.h>
27#include <wallet/rpcwallet.h>
29#include <wallet/transaction.h>
30#include <wallet/walletdb.h>
31#include <wallet/walletutil.h>
32
33#include <algorithm>
34#include <atomic>
35#include <cstdint>
36#include <map>
37#include <memory>
38#include <optional>
39#include <set>
40#include <stdexcept>
41#include <string>
42#include <utility>
43#include <vector>
44
45#include <boost/signals2/signal.hpp>
46
48 std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
49
50struct bilingual_str;
51
57void UnloadWallet(std::shared_ptr<CWallet> &&wallet);
58
59bool AddWallet(const std::shared_ptr<CWallet> &wallet);
60bool RemoveWallet(const std::shared_ptr<CWallet> &wallet,
61 std::optional<bool> load_on_start,
62 std::vector<bilingual_str> &warnings);
63bool RemoveWallet(const std::shared_ptr<CWallet> &wallet,
64 std::optional<bool> load_on_start);
65std::vector<std::shared_ptr<CWallet>> GetWallets();
66std::shared_ptr<CWallet> GetWallet(const std::string &name);
67std::shared_ptr<CWallet>
68LoadWallet(interfaces::Chain &chain, const std::string &name,
69 std::optional<bool> load_on_start, const DatabaseOptions &options,
71 std::vector<bilingual_str> &warnings);
72std::shared_ptr<CWallet>
73CreateWallet(interfaces::Chain &chain, const std::string &name,
74 std::optional<bool> load_on_start, const DatabaseOptions &options,
76 std::vector<bilingual_str> &warnings);
77std::unique_ptr<interfaces::Handler> HandleLoadWallet(LoadWalletFn load_wallet);
78std::unique_ptr<WalletDatabase>
79MakeWalletDatabase(const std::string &name, const DatabaseOptions &options,
81
100constexpr Amount HIGH_APS_FEE{COIN / 10000};
104static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
105static const bool DEFAULT_WALLETBROADCAST = true;
106static const bool DEFAULT_DISABLE_WALLET = false;
115static constexpr size_t DUMMY_P2PKH_INPUT_SIZE = 148;
116
117class CChainParams;
118class CCoinControl;
119class COutput;
120class CScript;
121class CTxMemPool;
122class CWalletTx;
124
127
128static constexpr uint64_t KNOWN_WALLET_FLAGS =
132
134
135static const std::map<std::string, WalletFlags> WALLET_FLAG_MAP{
136 {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
137 {"blank", WALLET_FLAG_BLANK_WALLET},
138 {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
139 {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
140 {"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
141};
142
143extern const std::map<uint64_t, std::string> WALLET_FLAG_CAVEATS;
144
197
200private:
201 bool m_change{true};
202 std::string m_label;
203
204public:
205 std::string purpose;
206
207 CAddressBookData() : purpose("unknown") {}
208
209 typedef std::map<std::string, std::string> StringMap;
211
212 bool IsChange() const { return m_change; }
213 const std::string &GetLabel() const { return m_label; }
214 void SetLabel(const std::string &label) {
215 m_change = false;
216 m_label = label;
217 }
218};
219
225
245
246// forward declarations for ScanForWalletTransactions/RescanFromTime
248
255private:
257
259 bool accept_no_keys = false);
260
261 std::atomic<bool> fAbortRescan{false};
262 // controlled by WalletRescanReserver
263 std::atomic<bool> fScanningWallet{false};
264 std::atomic<int64_t> m_scanning_start{0};
265 std::atomic<double> m_scanning_progress{0};
267
271
275
278 // Local time that the tip block was received. Used to schedule wallet
279 // rebroadcasts.
280 std::atomic<int64_t> m_best_block_time{0};
281
286 typedef std::multimap<COutPoint, TxId> TxSpends;
288 void AddToSpends(const COutPoint &outpoint, const TxId &wtxid)
291
310
315 void MarkConflicted(const BlockHash &hashBlock, int conflicting_height,
316 const TxId &txid);
317
322 void MarkInputsDirty(const CTransactionRef &tx)
324
325 void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>)
327
334 void SyncTransaction(const CTransactionRef &tx,
337
339
340 bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address,
341 const std::string &strName,
342 const std::string &strPurpose);
343
345 void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag);
346
348 void UnsetBlankWalletFlag(WalletBatch &batch) override;
349
352
354 std::string m_name;
355
357 std::unique_ptr<WalletDatabase> database;
358
367
368 /* Height of last block processed is used by wallet to know depth of
369 * transactions without relying on Chain interface beyond asynchronous
370 * updates. For safety, we initialize it to -1. Height is a pointer on
371 * node's tip and doesn't imply that the wallet has scanned sequentially all
372 * blocks up to this one.
373 */
375
376 std::map<OutputType, ScriptPubKeyMan *> m_external_spk_managers;
377 std::map<OutputType, ScriptPubKeyMan *> m_internal_spk_managers;
378
379 // Indexed by a unique identifier produced by each ScriptPubKeyMan using
380 // ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal
381 // structure
382 std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
383
384public:
385 /*
386 * Main wallet lock.
387 * This lock protects all the fields added by CWallet.
388 */
390
396 WalletDatabase &GetDatabase() override { return *database; }
397
401 const std::string &GetName() const { return m_name; }
402
403 typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
405 unsigned int nMasterKeyMaxID = 0;
406
408 CWallet(interfaces::Chain *chain, const std::string &name,
409 std::unique_ptr<WalletDatabase> _database)
411
413 // Should not have slots connected at this point.
414 assert(NotifyUnload.empty());
415 }
416
417 /* Returns the chain params used by this wallet. */
418 const CChainParams &GetChainParams() const override;
419
420 bool IsCrypted() const;
421 bool IsLocked() const override;
422 bool Lock();
423
425 bool HaveChain() const { return m_chain ? true : false; }
426
427 std::map<TxId, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
428
429 typedef std::multimap<int64_t, CWalletTx *> TxItems;
431
434
435 std::map<CTxDestination, CAddressBookData>
437 const CAddressBookData *
439 bool allow_change = false) const
441
443
446
448 interfaces::Chain &chain() const {
450 return *m_chain;
451 }
452
453 const CWalletTx *GetWalletTx(const TxId &txid) const
455
456 std::set<TxId> GetTxConflicts(const CWalletTx &wtx) const
458
465 int GetTxDepthInMainChain(const CWalletTx &wtx) const
467 bool IsTxInMainChain(const CWalletTx &wtx) const
470
471 return GetTxDepthInMainChain(wtx) > 0;
472 }
473
479 int GetTxBlocksToMaturity(const CWalletTx &wtx) const
481 bool IsTxImmatureCoinBase(const CWalletTx &wtx) const
483
491
492 bool IsSpent(const COutPoint &outpoint) const
494
495 // Whether this or any UTXO with the same CTxDestination has been spent.
496 bool IsSpentKey(const TxId &txid, unsigned int n) const
498 void SetSpentKeyState(WalletBatch &batch, const TxId &txid, unsigned int n,
499 bool used, std::set<CTxDestination> &tx_destinations)
501
502 bool IsLockedCoin(const COutPoint &outpoint) const
505 void UnlockCoin(const COutPoint &output)
510
511 /*
512 * Rescan abort properties
513 */
514 void AbortRescan() { fAbortRescan = true; }
515 bool IsAbortingRescan() const { return fAbortRescan; }
516 bool IsScanning() const { return fScanningWallet; }
520 double ScanningProgress() const {
522 }
523
527
530 nWalletVersion = nVersion;
531 nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion);
532 return true;
533 }
534
540 bool AddDestData(WalletBatch &batch, const CTxDestination &dest,
541 const std::string &key, const std::string &value)
544 bool EraseDestData(WalletBatch &batch, const CTxDestination &dest,
545 const std::string &key)
548 void LoadDestData(const CTxDestination &dest, const std::string &key,
549 const std::string &value)
553 bool GetDestData(const CTxDestination &dest, const std::string &key,
554 std::string *value) const
557 std::vector<std::string> GetDestValues(const std::string &prefix) const
559
564
565 // Used to prevent concurrent calls to walletpassphrase RPC.
568 bool accept_no_keys = false);
572
573 void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const
575 unsigned int ComputeTimeSmart(const CWalletTx &wtx) const;
576
581 int64_t IncOrderPosNext(WalletBatch *batch = nullptr)
584
585 void MarkDirty();
586
596
598 const CWalletTx::Confirmation &confirm,
599 const UpdateWalletTxFn &update_wtx = nullptr,
600 bool fFlushOnClose = true);
601 bool LoadToWallet(const TxId &txid, const UpdateWalletTxFn &fill_wtx)
605 void blockConnected(const CBlock &block, int height) override;
606 void blockDisconnected(const CBlock &block, int height) override;
610
627 int start_height,
628 std::optional<int> max_height,
630 bool fUpdate);
633 uint64_t mempool_sequence) override;
636
639 const std::vector<CRecipient> &vecSend) const;
640
641 // Fetch the inputs and sign with SIGHASH_ALL.
644 // Sign the tx given the input coins and sighash.
646 const std::map<COutPoint, Coin> &coins,
648 std::map<int, std::string> &input_errors) const;
649 SigningResult SignMessage(const std::string &message, const PKHash &pkhash,
650 std::string &str_sig) const;
651
669 SigHashType sighash_type = SigHashType().withForkId(),
670 bool sign = true, bool bip32derivs = true) const;
671
684 CTransactionRef tx, mapValue_t mapValue,
685 std::vector<std::pair<std::string, std::string>> orderForm,
686 bool broadcast = true);
687
693 std::string &err_string, bool relay) const
695
697 bool use_max_sig = false) const {
698 std::vector<CTxOut> v_txouts(txouts.size());
699 std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
700 return DummySignTx(txNew, v_txouts, use_max_sig);
701 }
703 const std::vector<CTxOut> &txouts,
704 bool use_max_sig = false) const;
705 bool DummySignInput(CTxIn &tx_in, const CTxOut &txout,
706 bool use_max_sig = false) const;
707
708 bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp)
710 bool ImportPrivKeys(const std::map<CKeyID, CKey> &privkey_map,
711 const int64_t timestamp)
713 bool ImportPubKeys(
714 const std::vector<CKeyID> &ordered_pubkeys,
715 const std::map<CKeyID, CPubKey> &pubkey_map,
716 const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
717 const bool add_keypool, const bool internal, const int64_t timestamp)
719 bool ImportScriptPubKeys(const std::string &label,
720 const std::set<CScript> &script_pub_keys,
721 const bool have_solving_data,
722 const bool apply_label, const int64_t timestamp)
724
729 // Override with -mintxfee
746 std::optional<OutputType> m_default_change_type{};
752
754 bool TopUpKeyPool(unsigned int kpSize = 0);
755
757
758 std::set<CTxDestination> GetLabelAddresses(const std::string &label) const
760
767
768 bool GetNewDestination(const OutputType type, const std::string label,
769 CTxDestination &dest, std::string &error);
771 std::string &error);
772
773 isminetype IsMine(const CTxDestination &dest) const
775 isminetype IsMine(const CScript &script) const
781 Amount GetDebit(const CTxIn &txin, const isminefilter &filter) const;
782 isminetype IsMine(const CTxOut &txout) const
784 ;
785 bool IsMine(const CTransaction &tx) const
788 bool IsFromMe(const CTransaction &tx) const;
789 Amount GetDebit(const CTransaction &tx, const isminefilter &filter) const;
791
796
797 bool SetAddressBook(const CTxDestination &address,
798 const std::string &strName, const std::string &purpose);
799
800 bool DelAddressBook(const CTxDestination &address);
801
803
807 bool fExplicit = false) override;
808
811 bool SetMaxVersion(int nVersion);
812
815 int GetVersion() const {
817 return nWalletVersion;
818 }
819
822 std::set<TxId> GetConflicts(const TxId &txid) const
824
827 bool HasWalletSpend(const TxId &txid) const
829
831 void Flush();
832
834 void Close();
835
837 boost::signals2::signal<void()> NotifyUnload;
838
843 boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address,
844 const std::string &label, bool isMine,
845 const std::string &purpose, ChangeType status)>
847
852 boost::signals2::signal<void(CWallet *wallet, const TxId &txid,
853 ChangeType status)>
855
857 boost::signals2::signal<void(const std::string &title, int nProgress)>
859
861 boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged;
862
864 boost::signals2::signal<void()> NotifyCanGetAddressesChanged;
865
870 boost::signals2::signal<void(CWallet *wallet)> NotifyStatusChanged;
871
878
880 bool TransactionCanBeAbandoned(const TxId &txid) const;
881
886 bool AbandonTransaction(const TxId &txid);
887
892 static std::shared_ptr<CWallet>
893 Create(interfaces::Chain &chain, const std::string &name,
894 std::unique_ptr<WalletDatabase> database,
896 std::vector<bilingual_str> &warnings);
897
903 void postInitProcess();
904
905 bool BackupWallet(const std::string &strDest) const;
906
907 /* Returns true if HD is enabled */
908 bool IsHDEnabled() const;
909
914 bool CanGetAddresses(bool internal = false) const;
915
924
929
933 void UnsetWalletFlag(uint64_t flag);
934
938 bool IsWalletFlagSet(uint64_t flag) const override;
939
947
949 bool IsLegacy() const;
950
955 const std::string GetDisplayName() const override {
956 std::string wallet_name =
957 GetName().length() == 0 ? "default wallet" : GetName();
958 return strprintf("[%s]", wallet_name);
959 };
960
965 template <typename... Params>
966 void WalletLogPrintf(std::string fmt, Params... parameters) const {
967 LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
968 };
969
970 template <typename... Params>
972 Params... parameters) const {
974 parameters...);
975 };
976
978 bool UpgradeWallet(int version, bilingual_str &error);
979
982 std::set<ScriptPubKeyMan *> GetActiveScriptPubKeyMans() const;
983
985 std::set<ScriptPubKeyMan *> GetAllScriptPubKeyMans() const;
986
990 bool internal) const;
991
993 ScriptPubKeyMan *GetScriptPubKeyMan(const CScript &script) const;
996
999 std::set<ScriptPubKeyMan *>
1000 GetScriptPubKeyMans(const CScript &script, SignatureData &sigdata) const;
1001
1003 std::unique_ptr<SigningProvider>
1004 GetSolvingProvider(const CScript &script) const;
1005 std::unique_ptr<SigningProvider>
1006 GetSolvingProvider(const CScript &script, SignatureData &sigdata) const;
1007
1012
1016
1017 bool WithEncryptionKey(
1018 const std::function<bool(const CKeyingMaterial &)> &cb) const override;
1019
1020 bool HasEncryptionKeys() const override;
1021
1034 void SetLastBlockProcessed(int block_height, BlockHash block_hash)
1037 m_last_block_processed_height = block_height;
1038 m_last_block_processed = block_hash;
1039 };
1040
1043
1047
1056
1065
1073 void DeactivateScriptPubKeyMan(const uint256 &id, OutputType type,
1074 bool internal);
1075
1078
1083
1089 const std::string &label, bool internal)
1091};
1092
1099
1102private:
1105
1106public:
1108 : m_wallet(w), m_could_reserve(false) {}
1109
1110 bool reserve() {
1111 assert(!m_could_reserve);
1112 if (m_wallet.fScanningWallet.exchange(true)) {
1113 return false;
1114 }
1115 m_wallet.m_scanning_start = GetTimeMillis();
1116 m_wallet.m_scanning_progress = 0;
1117 m_could_reserve = true;
1118 return true;
1119 }
1120
1121 bool isReserved() const {
1122 return (m_could_reserve && m_wallet.fScanningWallet);
1123 }
1124
1126 if (m_could_reserve) {
1127 m_wallet.fScanningWallet = false;
1128 }
1129 }
1130};
1131
1133bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name);
1134
1138 const std::string &wallet_name);
1139
1140#endif // BITCOIN_WALLET_WALLET_H
static constexpr Amount SATOSHI
Definition amount.h:143
static constexpr Amount COIN
Definition amount.h:144
int flags
const CChainParams & Params()
Return the currently selected parameters.
Address book data.
Definition wallet.h:199
StringMap destdata
Definition wallet.h:210
std::map< std::string, std::string > StringMap
Definition wallet.h:209
std::string m_label
Definition wallet.h:202
const std::string & GetLabel() const
Definition wallet.h:213
std::string purpose
Definition wallet.h:205
bool IsChange() const
Definition wallet.h:212
void SetLabel(const std::string &label)
Definition wallet.h:214
Definition block.h:60
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition chainparams.h:80
Coin Control Features.
Definition coincontrol.h:21
Fee rate in satoshis per kilobyte: Amount / kB.
Definition feerate.h:21
A reference to a CKey: the Hash160 of its serialized public key.
Definition pubkey.h:22
A mutable version of CTransaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition transaction.h:20
Serialized script, used inside transaction inputs and outputs.
Definition script.h:424
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
Definition transaction.h:59
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition txmempool.h:212
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition wallet.h:254
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
Definition wallet.cpp:3255
std::atomic< int64_t > m_best_block_time
Definition wallet.h:280
bool Lock()
Definition wallet.cpp:3155
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.h:1028
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.
Definition wallet.h:563
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....
Definition wallet.cpp:3226
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition wallet.h:837
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition wallet.h:403
bool HaveChain() const
Interface to assert chain access.
Definition wallet.h:425
int GetTxBlocksToMaturity(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:3124
int nWalletVersion GUARDED_BY(cs_wallet)
the current wallet version: clients below this version are not able to load the wallet
double ScanningProgress() const
Definition wallet.h:520
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
Definition wallet.h:696
uint64_t nAccountingEntryNumber
Definition wallet.h:433
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition wallet.cpp:3315
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
Definition wallet.cpp:3368
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition wallet.cpp:3290
Mutex m_unlock_mutex
Definition wallet.h:566
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,...
Definition wallet.cpp:2619
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition wallet.h:864
const std::string GetDisplayName() const override
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet ha...
Definition wallet.h:955
MasterKeyMap mapMasterKeys
Definition wallet.h:404
std::string m_name
Wallet name: relative directory name or "" for default wallet.
Definition wallet.h:354
TxItems wtxOrdered
Definition wallet.h:430
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...
Definition wallet.cpp:3114
bool IsTxImmatureCoinBase(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:3136
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition wallet.h:858
RecursiveMutex cs_wallet
Definition wallet.h:389
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
Definition wallet.cpp:3174
std::multimap< COutPoint, TxId > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
Definition wallet.h:286
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
Definition wallet.h:873
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
Definition wallet.h:966
bool IsAbortingRescan() const
Definition wallet.h:515
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition wallet.h:448
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition wallet.cpp:3330
std::atomic< int64_t > m_scanning_start
Definition wallet.h:264
WalletDatabase & GetDatabase() override
Definition wallet.h:396
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition wallet.h:351
bool WithEncryptionKey(const std::function< bool(const CKeyingMaterial &)> &cb) const override
Pass the encryption key to cb().
Definition wallet.cpp:3305
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
Definition wallet.cpp:3285
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Definition wallet.h:376
void DeactivateScriptPubKeyMan(const uint256 &id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
Definition wallet.cpp:3406
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.
Definition wallet.cpp:2643
CFeeRate m_fallback_fee
If fee estimation does not have enough data to provide estimates, use this fee instead.
Definition wallet.h:736
bool IsLegacy() const
Determine if we are a legacy wallet.
Definition wallet.cpp:3429
std::atomic< bool > fAbortRescan
Definition wallet.h:261
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
Definition wallet.h:382
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
Definition wallet.cpp:3379
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition wallet.h:445
static std::shared_ptr< CWallet > Create(interfaces::Chain &chain, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error.
Definition wallet.cpp:2707
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition wallet.h:875
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.
Definition wallet.h:846
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
Definition wallet.h:1023
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition wallet.h:870
OutputType m_default_address_type
Definition wallet.h:739
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition wallet.cpp:3439
int64_t ScanningDuration() const
Definition wallet.h:517
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition wallet.cpp:3323
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition wallet.cpp:3271
std::atomic< uint64_t > m_wallet_flags
Definition wallet.h:338
Amount m_max_aps_fee
note: this is absolute fee, not fee rate
Definition wallet.h:738
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition wallet.h:401
CFeeRate m_pay_tx_fee
Definition wallet.h:725
int64_t nNextResend
Definition wallet.h:276
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
Definition wallet.h:486
bool BackupWallet(const std::string &strDest) const
Definition wallet.cpp:3097
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)
Definition wallet.h:467
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
Definition wallet.cpp:2577
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
bool IsScanning() const
Definition wallet.h:516
TxSpends mapTxSpends GUARDED_BY(cs_wallet)
std::map< TxId, CWalletTx > mapWallet GUARDED_BY(cs_wallet)
void WalletLogPrintfToBeContinued(std::string fmt, Params... parameters) const
Definition wallet.h:971
std::unique_ptr< WalletDatabase > database
Internal database handle.
Definition wallet.h:357
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.
Definition wallet.cpp:3455
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.
Definition wallet.cpp:3189
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.h:528
CFeeRate m_min_fee
Definition wallet.h:730
std::vector< std::string > GetDestValues(const std::string &prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get all destination values matching a prefix.
Definition wallet.cpp:2662
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition wallet.h:861
bool IsLocked() const override
Definition wallet.cpp:3147
bool m_allow_fallback_fee
will be false if -fallbackfee=0
Definition wallet.h:728
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
Definition wallet.h:377
std::atomic< double > m_scanning_progress
Definition wallet.h:265
~CWallet()
Definition wallet.h:412
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition wallet.h:815
WalletDatabase & GetDBHandle()
Get database handle used by this wallet.
Definition wallet.h:395
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2485
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.
Definition wallet.cpp:2629
boost::signals2::signal< void(CWallet *wallet, const TxId &txid, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition wallet.h:854
bool HasEncryptionKeys() const override
Definition wallet.cpp:3311
bool m_spend_zero_conf_change
Definition wallet.h:726
CWallet(interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > _database)
Construct wallet with specified name and database implementation.
Definition wallet.h:408
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
Definition wallet.h:751
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
Definition wallet.cpp:3043
bool fBroadcastTransactions
Definition wallet.h:277
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition wallet.cpp:3210
bool IsCrypted() const
Definition wallet.cpp:3143
std::atomic< bool > fScanningWallet
Definition wallet.h:263
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
Definition wallet.cpp:3202
std::multimap< int64_t, CWalletTx * > TxItems
Definition wallet.h:429
int nWalletMaxVersion GUARDED_BY(cs_wallet)
the maximum wallet format version: memory-only variable that specifies to what version this wallet ma...
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
Definition wallet.h:746
void AbortRescan()
Definition wallet.h:514
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.
Definition wallet.cpp:2638
unsigned int nMasterKeyMaxID
Definition wallet.h:405
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
Definition wallet.h:595
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
Definition wallet.cpp:3086
void SetLastBlockProcessed(int block_height, BlockHash block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
Definition wallet.h:1034
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:3031
A transaction with a bunch of additional info that only the owner cares about.
Definition transaction.h:65
A UTXO entry.
Definition coins.h:28
A wrapper to reserve an address from a wallet.
Definition wallet.h:161
bool fInternal
Whether this is from the internal (change output) keypool.
Definition wallet.h:174
ReserveDestination & operator=(const ReserveDestination &)=delete
OutputType const type
Definition wallet.h:168
~ReserveDestination()
Destructor.
Definition wallet.h:187
ReserveDestination(CWallet *_pwallet, OutputType _type)
Construct a ReserveDestination object.
Definition wallet.h:179
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from.
Definition wallet.h:167
int64_t nIndex
The index of the address's key in the keypool.
Definition wallet.h:170
CTxDestination address
The destination.
Definition wallet.h:172
ReserveDestination(const ReserveDestination &)=delete
const CWallet *const pwallet
The wallet to reserve from.
Definition wallet.h:164
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
Signature hash type wrapper class.
Definition sighashtype.h:37
Access to the wallet database.
Definition walletdb.h:175
An instance of this class represents one database.
Definition db.h:100
Descriptor with some wallet metadata.
Definition walletutil.h:80
RAII object to check and reserve a wallet rescan.
Definition wallet.h:1101
bool isReserved() const
Definition wallet.h:1121
CWallet & m_wallet
Definition wallet.h:1103
WalletRescanReserver(CWallet &w)
Definition wallet.h:1107
Chain notifications.
Definition chain.h:241
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition chain.h:123
256-bit opaque blob.
Definition uint256.h:129
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
Definition crypter.h:57
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition cs_main.cpp:7
TransactionError
Definition error.h:22
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2455
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 ...
Definition wallet.cpp:2378
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2301
void KeepDestination()
Keep the address.
Definition wallet.cpp:2438
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2476
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2312
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2399
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2470
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Definition wallet.cpp:2094
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2460
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition wallet.cpp:2260
DBErrors LoadWallet(bool &fFirstRunRet)
Definition wallet.cpp:2171
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
Definition wallet.cpp:2108
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2003
void ReturnDestination()
Return reserved address.
Definition wallet.cpp:2447
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
Definition wallet.cpp:2351
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2465
bool TopUpKeyPool(unsigned int kpSize=0)
Definition wallet.cpp:2322
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
Definition wallet.cpp:2233
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.
Definition wallet.cpp:2050
bool GetReservedDestination(CTxDestination &pubkey, bool internal)
Reserve an address.
Definition wallet.cpp:2417
int64_t GetOldestKeyPoolTime() const
Definition wallet.cpp:2368
bool DelAddressBook(const CTxDestination &address)
Definition wallet.cpp:2267
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
Definition wallet.cpp:2331
DBErrors ZapSelectTx(std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:2201
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.
Definition wallet.cpp:2124
bool AddWalletFlags(uint64_t flags)
Overwrite all flags by the given uint64_t.
Definition wallet.cpp:1532
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)
Definition wallet.cpp:1607
void blockConnected(const CBlock &block, int height) override
Definition wallet.cpp:1354
bool LoadToWallet(const TxId &txid, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:1046
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.
Definition wallet.cpp:1229
void Flush()
Flush wallet (bitdb flush)
Definition wallet.cpp:604
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition wallet.cpp:402
bool SetMaxVersion(int nVersion)
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading...
Definition wallet.cpp:556
std::set< TxId > GetConflicts(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get wallet transactions that conflict with given transaction (spend same outputs)
Definition wallet.cpp:569
void MarkDirty()
Definition wallet.cpp:894
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.
Definition wallet.cpp:1881
void AddToSpends(const COutPoint &outpoint, const TxId &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:682
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
Definition wallet.cpp:1286
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:1587
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
Definition wallet.cpp:952
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.
Definition wallet.cpp:598
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition wallet.cpp:446
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...
Definition wallet.cpp:1490
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
Definition wallet.cpp:1449
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:1597
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:1424
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
Definition wallet.cpp:1521
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)
Definition wallet.cpp:1621
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
Definition wallet.cpp:1476
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.
Definition wallet.cpp:1707
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:925
bool TransactionCanBeAbandoned(const TxId &txid) const
Return whether transaction can be abandoned.
Definition wallet.cpp:1154
const CChainParams & GetChainParams() const override
Definition wallet.cpp:386
Amount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
Definition wallet.cpp:1403
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed.
Definition wallet.cpp:1161
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
Definition wallet.cpp:1097
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
Definition wallet.cpp:661
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:1848
bool IsHDEnabled() const
Definition wallet.cpp:1467
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
Definition wallet.cpp:1504
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:612
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition wallet.cpp:706
void updatedBlockTip() override
Definition wallet.cpp:1386
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
Definition wallet.cpp:1499
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Definition wallet.cpp:1312
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
Definition wallet.cpp:1517
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
Definition wallet.cpp:1656
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
Definition wallet.cpp:1170
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
Definition wallet.cpp:1513
void SetSpentKeyState(WalletBatch &batch, const TxId &txid, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:901
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Definition wallet.cpp:1299
DBErrors ReorderTransactions()
Definition wallet.cpp:826
void blockDisconnected(const CBlock &block, int height) override
Definition wallet.cpp:1369
void Close()
Close wallet database.
Definition wallet.cpp:608
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
Definition wallet.cpp:882
const CWalletTx * GetWalletTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:392
void ResendWalletTransactions()
Definition wallet.cpp:1942
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr, bool fExplicit=false) override
signify that a particular wallet feature is now used.
Definition wallet.cpp:528
std::set< TxId > GetTxConflicts(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition wallet.cpp:1922
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
Definition wallet.cpp:1546
void chainStateFlushed(const CBlockLocator &loc) override
Definition wallet.cpp:523
uint8_t isminefilter
Definition wallet.h:42
isminetype
IsMine() return codes.
Definition ismine.h:18
bool error(const char *fmt, const Args &...args)
Definition logging.h:263
#define LogPrintfToBeContinued
These are aliases used to explicitly state that the message should not end with a newline character.
Definition logging.h:259
#define LogPrintf(...)
Definition logging.h:227
SigningResult
Definition message.h:47
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition rcu.h:259
OutputType
Definition outputtype.h:16
std::shared_ptr< const CTransaction > CTransactionRef
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
const char * prefix
Definition rest.cpp:817
const char * name
Definition rest.cpp:47
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition secure.h:55
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition standard.h:85
static constexpr Amount zero() noexcept
Definition amount.h:32
A BlockHash is a unqiue identifier for a block.
Definition blockhash.h:13
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition block.h:105
CScript scriptPubKey
Definition wallet.h:221
Amount nAmount
Definition wallet.h:222
bool fSubtractFeeFromAmount
Definition wallet.h:223
std::optional< int > last_scanned_height
Definition wallet.h:618
BlockHash last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition wallet.h:617
BlockHash last_failed_block
Hash of the most recent block that could not be scanned due to read errors or pruning.
Definition wallet.h:624
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.
Definition wallet.h:233
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)
Definition wallet.h:236
size_t change_spend_size
Definition wallet.h:229
size_t tx_noinputs_size
Definition wallet.h:231
bool m_avoid_partial_spends
Definition wallet.h:234
CFeeRate effective_fee
Definition wallet.h:230
size_t change_output_size
Definition wallet.h:228
A version of CTransaction with the PSBT format.
Definition psbt.h:334
A TxId is the identifier of a transaction.
Definition txid.h:14
Bilingual messages:
Definition translation.h:17
#define LOCK(cs)
Definition sync.h:306
#define AssertLockHeld(cs)
Definition sync.h:146
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define GUARDED_BY(x)
#define LOCKS_EXCLUDED(...)
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition time.cpp:101
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition txmempool.h:151
ChangeType
General change type (added, updated, removed).
assert(!tx.IsCoinBase())
DatabaseStatus
Definition db.h:229
std::shared_ptr< CWallet > m_wallet
std::map< std::string, std::string > mapValue_t
Definition transaction.h:21
std::unique_ptr< interfaces::Handler > HandleLoadWallet(LoadWalletFn load_wallet)
Definition wallet.cpp:167
constexpr Amount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
Definition wallet.h:110
constexpr Amount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition wallet.h:83
static const bool DEFAULT_DISABLE_WALLET
Definition wallet.h:106
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition wallet.h:48
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
Definition wallet.cpp:121
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
Definition wallet.h:126
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition wallet.h:133
constexpr Amount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
Definition wallet.h:113
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition wallet.cpp:44
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition wallet.h:135
static constexpr size_t DUMMY_P2PKH_INPUT_SIZE
Pre-calculated constants for input size estimation.
Definition wallet.h:115
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
Definition wallet.cpp:1991
static const Amount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition wallet.h:85
static const Amount DEFAULT_TRANSACTION_MINFEE_PER_KB
-mintxfee default
Definition wallet.h:87
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Definition wallet.cpp:2675
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition wallet.cpp:202
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition wallet.h:104
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition wallet.h:128
constexpr Amount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition wallet.h:108
static const Amount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
Definition wallet.h:98
bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Add wallet name to persistent configuration so it will be loaded on startup.
Definition wallet.cpp:55
bool RemoveWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Remove wallet name from persistent configuration so it will not be loaded on startup.
Definition wallet.cpp:70
static const bool DEFAULT_WALLETBROADCAST
Definition wallet.h:105
constexpr Amount HIGH_APS_FEE
discourage APS fee higher than this amount
Definition wallet.h:100
static const Amount WALLET_INCREMENTAL_RELAY_FEE(5000 *SATOSHI)
minimum recommended increment for BIP 125 replacement txs
std::shared_ptr< CWallet > GetWallet(const std::string &name)
Definition wallet.cpp:156
std::vector< std::shared_ptr< CWallet > > GetWallets()
Definition wallet.cpp:151
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
Definition wallet.cpp:107
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)
Definition wallet.cpp:265
std::shared_ptr< CWallet > CreateWallet(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)
Definition wallet.cpp:283
DBErrors
Error statuses for the wallet database.
Definition walletdb.h:45
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition walletutil.h:55
@ WALLET_FLAG_AVOID_REUSE
Definition walletutil.h:47
@ WALLET_FLAG_KEY_ORIGIN_METADATA
Definition walletutil.h:51
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition walletutil.h:70
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
Definition walletutil.h:67
WalletFeature
(client) version numbers for particular wallet features
Definition walletutil.h:14
@ FEATURE_BASE
Definition walletutil.h:17