Bitcoin Core  22.99.0
P2P Digital Currency
wallet.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_WALLET_WALLET_H
7 #define BITCOIN_WALLET_WALLET_H
8 
9 #include <consensus/amount.h>
10 #include <fs.h>
11 #include <interfaces/chain.h>
12 #include <interfaces/handler.h>
13 #include <outputtype.h>
14 #include <policy/feerate.h>
15 #include <psbt.h>
16 #include <tinyformat.h>
17 #include <util/message.h>
18 #include <util/strencodings.h>
19 #include <util/string.h>
20 #include <util/system.h>
21 #include <util/ui_change_type.h>
22 #include <validationinterface.h>
23 #include <wallet/coinselection.h>
24 #include <wallet/crypter.h>
25 #include <wallet/scriptpubkeyman.h>
26 #include <wallet/transaction.h>
27 #include <wallet/walletdb.h>
28 #include <wallet/walletutil.h>
29 
30 #include <algorithm>
31 #include <atomic>
32 #include <map>
33 #include <memory>
34 #include <optional>
35 #include <set>
36 #include <stdexcept>
37 #include <stdint.h>
38 #include <string>
39 #include <utility>
40 #include <vector>
41 
42 #include <boost/signals2/signal.hpp>
43 
44 
45 using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
46 
47 class CScript;
48 enum class FeeEstimateMode;
49 struct FeeCalculation;
50 struct bilingual_str;
51 
52 namespace wallet {
53 struct WalletContext;
54 
60 void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
61 
62 bool AddWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
63 bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
64 bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start);
65 std::vector<std::shared_ptr<CWallet>> GetWallets(WalletContext& context);
66 std::shared_ptr<CWallet> GetWallet(WalletContext& context, const std::string& name);
67 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);
68 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);
69 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);
70 std::unique_ptr<interfaces::Handler> HandleLoadWallet(WalletContext& context, LoadWalletFn load_wallet);
71 std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
72 
76 static const CAmount DEFAULT_FALLBACK_FEE = 0;
78 static const CAmount DEFAULT_DISCARD_FEE = 10000;
80 static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
82 static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte
92 constexpr CAmount HIGH_APS_FEE{COIN / 10000};
96 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
98 static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
100 static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
102 static const bool DEFAULT_WALLET_RBF = false;
103 static const bool DEFAULT_WALLETBROADCAST = true;
104 static const bool DEFAULT_DISABLE_WALLET = false;
108 constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
112 static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
113 
114 class CCoinControl;
115 class COutput;
116 class CWalletTx;
117 class ReserveDestination;
118 
121 
122 static constexpr uint64_t KNOWN_WALLET_FLAGS =
130 
131 static constexpr uint64_t MUTABLE_WALLET_FLAGS =
133 
134 static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
135  {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
136  {"blank", WALLET_FLAG_BLANK_WALLET},
137  {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
138  {"last_hardened_xpub_cached", WALLET_FLAG_LAST_HARDENED_XPUB_CACHED},
139  {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
140  {"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
141  {"external_signer", WALLET_FLAG_EXTERNAL_SIGNER}
142 };
143 
144 extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;
145 
162 {
163 protected:
165  const CWallet* const pwallet;
170  int64_t nIndex{-1};
174  bool fInternal{false};
175 
176 public:
179  : pwallet(pwallet)
180  , type(type) { }
181 
182  ReserveDestination(const ReserveDestination&) = delete;
184 
187  {
189  }
190 
192  bool GetReservedDestination(CTxDestination& pubkey, bool internal, bilingual_str& error);
194  void ReturnDestination();
196  void KeepDestination();
197 };
198 
201 {
202 private:
203  bool m_change{true};
204  std::string m_label;
205 public:
206  std::string purpose;
207 
208  CAddressBookData() : purpose("unknown") {}
209 
210  typedef std::map<std::string, std::string> StringMap;
212 
213  bool IsChange() const { return m_change; }
214  const std::string& GetLabel() const { return m_label; }
215  void SetLabel(const std::string& label) {
216  m_change = false;
217  m_label = label;
218  }
219 };
220 
222 {
226 };
227 
228 class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime
233 {
234 private:
236 
237  bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys = false);
238 
239  std::atomic<bool> fAbortRescan{false};
240  std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
241  std::atomic<int64_t> m_scanning_start{0};
242  std::atomic<double> m_scanning_progress{0};
243  friend class WalletRescanReserver;
244 
246  int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
247 
249  int64_t nNextResend = 0;
253  // Local time that the tip block was received. Used to schedule wallet rebroadcasts.
254  std::atomic<int64_t> m_best_block_time {0};
255 
261  typedef std::multimap<COutPoint, uint256> TxSpends;
262  TxSpends mapTxSpends GUARDED_BY(cs_wallet);
263  void AddToSpends(const COutPoint& outpoint, const uint256& wtxid, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
264  void AddToSpends(const uint256& wtxid, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
265 
282  bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const SyncTxState& state, bool fUpdate, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
283 
285  void MarkConflicted(const uint256& hashBlock, int conflicting_height, const uint256& hashTx);
286 
289 
290  void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
291 
292  void SyncTransaction(const CTransactionRef& tx, const SyncTxState& state, bool update_tx = true, bool rescanning_old_block = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
293 
295  std::atomic<uint64_t> m_wallet_flags{0};
296 
297  bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
298 
300  void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
301 
303  void UnsetBlankWalletFlag(WalletBatch& batch) override;
304 
307 
310 
312  std::string m_name;
313 
315  std::unique_ptr<WalletDatabase> const m_database;
316 
324  uint256 m_last_block_processed GUARDED_BY(cs_wallet);
325 
331  int m_last_block_processed_height GUARDED_BY(cs_wallet) = -1;
332 
333  std::map<OutputType, ScriptPubKeyMan*> m_external_spk_managers;
334  std::map<OutputType, ScriptPubKeyMan*> m_internal_spk_managers;
335 
336  // Indexed by a unique identifier produced by each ScriptPubKeyMan using
337  // ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal structure
338  std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
339 
345  static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings);
346 
347 public:
353 
354  WalletDatabase& GetDatabase() const override
355  {
356  assert(static_cast<bool>(m_database));
357  return *m_database;
358  }
359 
362  const std::string& GetName() const { return m_name; }
363 
364  typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
366  unsigned int nMasterKeyMaxID = 0;
367 
369  CWallet(interfaces::Chain* chain, const std::string& name, const ArgsManager& args, std::unique_ptr<WalletDatabase> database)
370  : m_args(args),
371  m_chain(chain),
372  m_name(name),
373  m_database(std::move(database))
374  {
375  }
376 
378  {
379  // Should not have slots connected at this point.
380  assert(NotifyUnload.empty());
381  }
382 
383  bool IsCrypted() const;
384  bool IsLocked() const override;
385  bool Lock();
386 
388  bool HaveChain() const { return m_chain ? true : false; }
389 
392  std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
393 
394  typedef std::multimap<int64_t, CWalletTx*> TxItems;
396 
397  int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
399 
400  std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
401  const CAddressBookData* FindAddressBookEntry(const CTxDestination&, bool allow_change = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
402 
407  std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
408 
411 
413  interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
414 
416 
417  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
418  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
419  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
420  // resolve the issue of member access into incomplete type CWallet. Note
421  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
422  // in place.
423  std::set<uint256> GetTxConflicts(const CWalletTx& wtx) const NO_THREAD_SAFETY_ANALYSIS;
424 
431  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
432  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
433  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
434  // resolve the issue of member access into incomplete type CWallet. Note
435  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
436  // in place.
438  bool IsTxInMainChain(const CWalletTx& wtx) const { return GetTxDepthInMainChain(wtx) > 0; }
439 
445  int GetTxBlocksToMaturity(const CWalletTx& wtx) const;
446  bool IsTxImmatureCoinBase(const CWalletTx& wtx) const;
447 
449  bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return IsFeatureSupported(nWalletVersion, wf); }
450 
451  bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
452 
453  // Whether this or any known UTXO with the same single key has been spent.
454  bool IsSpentKey(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
455  void SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
456 
459 
460  bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
461  bool LockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
462  bool UnlockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
464  void ListLockedCoins(std::vector<COutPoint>& vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
465 
466  /*
467  * Rescan abort properties
468  */
469  void AbortRescan() { fAbortRescan = true; }
470  bool IsAbortingRescan() const { return fAbortRescan; }
471  bool IsScanning() const { return fScanningWallet; }
472  int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
473  double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
474 
477 
480 
481  bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; return true; }
482 
484  void LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
485 
487  int64_t nRelockTime GUARDED_BY(cs_wallet){0};
488 
489  // Used to prevent concurrent calls to walletpassphrase RPC.
491  bool Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys = false);
492  bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
493  bool EncryptWallet(const SecureString& strWalletPassphrase);
494 
495  void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
496  unsigned int ComputeTimeSmart(const CWalletTx& wtx, bool rescanning_old_block) const;
497 
504 
505  void MarkDirty();
506 
513  using UpdateWalletTxFn = std::function<bool(CWalletTx& wtx, bool new_tx)>;
514 
515  CWalletTx* AddToWallet(CTransactionRef tx, const TxState& state, const UpdateWalletTxFn& update_wtx=nullptr, bool fFlushOnClose=true, bool rescanning_old_block = false);
516  bool LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
517  void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override;
518  void blockConnected(const CBlock& block, int height) override;
519  void blockDisconnected(const CBlock& block, int height) override;
520  void updatedBlockTip() override;
521  int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
522 
523  struct ScanResult {
524  enum { SUCCESS, FAILURE, USER_ABORT } status = SUCCESS;
525 
530  std::optional<int> last_scanned_height;
531 
537  };
538  ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate);
539  void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override;
542 
543  OutputType TransactionChangeType(const std::optional<OutputType>& change_type, const std::vector<CRecipient>& vecSend) const;
544 
548  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const;
549  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const;
550 
567  bool& complete,
568  int sighash_type = SIGHASH_DEFAULT,
569  bool sign = true,
570  bool bip32derivs = true,
571  size_t* n_signed = nullptr,
572  bool finalize = true) const;
573 
583  void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm);
584 
586  bool SubmitTxMemoryPoolAndRelay(CWalletTx& wtx, std::string& err_string, bool relay) const;
587 
588  bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, const CCoinControl* coin_control = nullptr) const
589  {
590  std::vector<CTxOut> v_txouts(txouts.size());
591  std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
592  return DummySignTx(txNew, v_txouts, coin_control);
593  }
594  bool DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut> &txouts, const CCoinControl* coin_control = nullptr) const;
595 
596  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
597  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
598  bool ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
599  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);
600 
607  bool m_allow_fallback_fee{true};
609 
615 
619 
625 
635  std::optional<OutputType> m_default_change_type{};
638 
640  bool TopUpKeyPool(unsigned int kpSize = 0);
641 
642  std::optional<int64_t> GetOldestKeyPoolTime() const;
643 
644  std::set<CTxDestination> GetLabelAddresses(const std::string& label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
645 
651 
652  bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, bilingual_str& error);
654 
661  CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
663  bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
665  bool IsFromMe(const CTransaction& tx) const;
666  CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
667  void chainStateFlushed(const CBlockLocator& loc) override;
668 
670  DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
671 
672  bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
673 
674  bool DelAddressBook(const CTxDestination& address);
675 
677  bool SetAddressUsed(WalletBatch& batch, const CTxDestination& dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
678 
680  bool SetAddressReceiveRequest(WalletBatch& batch, const CTxDestination& dest, const std::string& id, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
681 
682  unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
683 
685  void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr) override;
686 
688  int GetVersion() const { LOCK(cs_wallet); return nWalletVersion; }
689 
691  std::set<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
692 
694  bool HasWalletSpend(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
695 
697  void Flush();
698 
700  void Close();
701 
703  boost::signals2::signal<void ()> NotifyUnload;
704 
709  boost::signals2::signal<void(const CTxDestination& address,
710  const std::string& label, bool isMine,
711  const std::string& purpose, ChangeType status)>
713 
718  boost::signals2::signal<void(const uint256& hashTx, ChangeType status)> NotifyTransactionChanged;
719 
721  boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
722 
724  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
725 
727  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
728 
733  boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
734 
738  void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
739 
741  bool TransactionCanBeAbandoned(const uint256& hashTx) const;
742 
743  /* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
744  bool AbandonTransaction(const uint256& hashTx);
745 
747  bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
748 
749  /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
750  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);
751 
756  void postInitProcess();
757 
758  bool BackupWallet(const std::string& strDest) const;
759 
760  /* Returns true if HD is enabled */
761  bool IsHDEnabled() const;
762 
763  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
764  bool CanGetAddresses(bool internal = false) const;
765 
772  void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(::cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_wallet);
773 
775  void SetWalletFlag(uint64_t flags);
776 
778  void UnsetWalletFlag(uint64_t flag);
779 
781  bool IsWalletFlagSet(uint64_t flag) const override;
782 
785  bool AddWalletFlags(uint64_t flags);
787  bool LoadWalletFlags(uint64_t flags);
788 
790  bool IsLegacy() const;
791 
793  const std::string GetDisplayName() const override {
794  std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
795  return strprintf("[%s]", wallet_name);
796  };
797 
799  template<typename... Params>
800  void WalletLogPrintf(std::string fmt, Params... parameters) const {
801  LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
802  };
803 
805  bool UpgradeWallet(int version, bilingual_str& error);
806 
808  std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
809 
811  std::set<ScriptPubKeyMan*> GetAllScriptPubKeyMans() const;
812 
814  ScriptPubKeyMan* GetScriptPubKeyMan(const OutputType& type, bool internal) const;
815 
817  std::set<ScriptPubKeyMan*> GetScriptPubKeyMans(const CScript& script) const;
819  ScriptPubKeyMan* GetScriptPubKeyMan(const uint256& id) const;
820 
822  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const;
823  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script, SignatureData& sigdata) const;
824 
828 
831 
832  const CKeyingMaterial& GetEncryptionKey() const override;
833  bool HasEncryptionKeys() const override;
834 
837  {
839  assert(m_last_block_processed_height >= 0);
840  return m_last_block_processed_height;
841  };
843  {
845  assert(m_last_block_processed_height >= 0);
846  return m_last_block_processed;
847  }
850  {
852  m_last_block_processed_height = block_height;
853  m_last_block_processed = block_hash;
854  };
855 
858 
861 
866  void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
867 
872  void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
873 
878  void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal);
879 
882 
885 
889  std::optional<bool> IsInternalScriptPubKeyMan(ScriptPubKeyMan* spk_man) const;
890 
892  ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
893 };
894 
900 
903 {
904 private:
907 public:
908  explicit WalletRescanReserver(CWallet& w) : m_wallet(w), m_could_reserve(false) {}
909 
910  bool reserve()
911  {
912  assert(!m_could_reserve);
913  if (m_wallet.fScanningWallet.exchange(true)) {
914  return false;
915  }
916  m_wallet.m_scanning_start = GetTimeMillis();
917  m_wallet.m_scanning_progress = 0;
918  m_could_reserve = true;
919  return true;
920  }
921 
922  bool isReserved() const
923  {
924  return (m_could_reserve && m_wallet.fScanningWallet);
925  }
926 
928  {
929  if (m_could_reserve) {
930  m_wallet.fScanningWallet = false;
931  }
932  }
933 };
934 
936 bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
937 
939 bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
940 
941 bool DummySignInput(const SigningProvider& provider, CTxIn &tx_in, const CTxOut &txout, bool use_max_sig);
942 
943 bool FillInputToWeight(CTxIn& txin, int64_t target_weight);
944 } // namespace wallet
945 
946 #endif // BITCOIN_WALLET_WALLET_H
wallet::CWallet::GetScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetScriptPubKeyMans(const CScript &script) const
Get all the ScriptPubKeyMans for a script.
Definition: wallet.cpp:3179
wallet::DEFAULT_WALLETBROADCAST
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:103
wallet::CWallet::LoadDestData
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:2596
wallet::CWallet::ImportScriptPubKeys
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:1612
wallet::CWallet::IsFromMe
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
Definition: wallet.cpp:1396
CTxIn
An input of a transaction.
Definition: transaction.h:65
wallet::CWallet::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: wallet.h:727
interfaces
Definition: dummywallet.cpp:10
wallet::WalletDatabase
An instance of this class represents one database.
Definition: db.h:104
wallet::CWallet::updatedBlockTip
void updatedBlockTip() override
Definition: wallet.cpp:1332
wallet::CWallet::IsHDEnabled
bool IsHDEnabled() const
Definition: wallet.cpp:1413
wallet::ReserveDestination::pwallet
const CWallet *const pwallet
The wallet to reserve from.
Definition: wallet.h:165
wallet::DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
Definition: wallet.h:90
wallet::CWallet::ListLockedCoins
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2434
wallet::ReserveDestination::address
CTxDestination address
The destination.
Definition: wallet.h:172
crypter.h
feerate.h
wallet::FEATURE_BASE
@ FEATURE_BASE
Definition: walletutil.h:17
wallet::ReserveDestination::ReserveDestination
ReserveDestination(CWallet *pwallet, OutputType type)
Construct a ReserveDestination object. This does NOT reserve an address yet.
Definition: wallet.h:178
wallet::CWallet::UpdateWalletTxFn
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
Definition: wallet.h:513
OutputType
OutputType
Definition: outputtype.h:18
wallet::CWallet::SetAddressUsed
bool SetAddressUsed(WalletBatch &batch, const CTxDestination &dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2580
wallet::isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:41
ui_change_type.h
wallet::CWallet::LoadToWallet
bool LoadToWallet(const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1023
wallet::CWallet::MarkConflicted
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.
Definition: wallet.cpp:1197
assert
assert(!tx.IsCoinBase())
wallet::ReserveDestination::fInternal
bool fInternal
Whether this is from the internal (change output) keypool.
Definition: wallet.h:174
wallet::FillInputToWeight
bool FillInputToWeight(CTxIn &txin, int64_t target_weight)
Definition: wallet.cpp:1508
wallet::isminefilter
std::underlying_type< isminetype >::type isminefilter
used for bitflags of isminetype
Definition: wallet.h:40
wallet::CWallet::UnsetWalletFlagWithDB
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
Definition: wallet.cpp:1451
wallet::CWallet::m_scanning_start
std::atomic< int64_t > m_scanning_start
Definition: wallet.h:241
wallet::CWallet::GetVersion
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition: wallet.h:688
wallet::CWallet::chain
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:413
wallet::CWallet::fAbortRescan
std::atomic< bool > fAbortRescan
Definition: wallet.h:239
wallet::CWallet::DeactivateScriptPubKeyMan
void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
Definition: wallet.cpp:3370
wallet::AddWallet
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:110
wallet::DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:526
wallet::CWallet::m_unlock_mutex
Mutex m_unlock_mutex
Definition: wallet.h:487
wallet::WalletRescanReserver
RAII object to check and reserve a wallet rescan.
Definition: wallet.h:902
fs.h
wallet::CAddressBookData
Address book data.
Definition: wallet.h:200
wallet::CWallet::WalletLogPrintf
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:800
wallet::CWallet::SetAddressBookWithDB
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
Definition: wallet.cpp:2170
wallet::CWallet::AddToWallet
CWalletTx * AddToWallet(CTransactionRef tx, const TxState &state, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true, bool rescanning_old_block=false)
Definition: wallet.cpp:925
wallet::CWallet::Lock
bool Lock()
Definition: wallet.cpp:3117
flags
int flags
Definition: bitcoin-tx.cpp:529
wallet::WalletStorage
Definition: scriptpubkeyman.h:34
wallet::CWallet::IsInternalScriptPubKeyMan
std::optional< bool > IsInternalScriptPubKeyMan(ScriptPubKeyMan *spk_man) const
Returns whether the provided ScriptPubKeyMan is internal.
Definition: wallet.cpp:3409
wallet::DatabaseStatus
DatabaseStatus
Definition: db.h:213
wallet::CWallet::ZapSelectTx
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2139
wallet::CWallet::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1582
wallet::CWallet::ScanResult::last_scanned_block
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition: wallet.h:529
wallet::HandleLoadWallet
std::unique_ptr< interfaces::Handler > HandleLoadWallet(WalletContext &context, LoadWalletFn load_wallet)
Definition: wallet.cpp:163
wallet::CWallet::UpgradeWallet
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
Definition: wallet.cpp:3011
wallet::CAddressBookData::destdata
StringMap destdata
Definition: wallet.h:211
wallet::CWallet::GetOldestKeyPoolTime
std::optional< int64_t > GetOldestKeyPoolTime() const
Definition: wallet.cpp:2296
string.h
wallet::DEFAULT_FALLBACK_FEE
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:76
wallet::CWallet::MarkDirty
void MarkDirty()
Definition: wallet.cpp:830
wallet::CWallet::HasWalletSpend
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.
Definition: wallet.cpp:551
bilingual_str
Bilingual messages:
Definition: translation.h:16
wallet::CWallet::m_discard_rate
CFeeRate m_discard_rate
If the cost to spend a change output at this feerate is greater than the value of the output itself,...
Definition: wallet.h:618
outputtype.h
wallet::CWallet::m_internal_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
Definition: wallet.h:334
wallet::CWallet::IsCrypted
bool IsCrypted() const
Definition: wallet.cpp:3103
wallet::CWallet::SignMessage
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Definition: wallet.cpp:2001
wallet::CWallet::DelAddressBook
bool DelAddressBook(const CTxDestination &address)
Definition: wallet.cpp:2196
wallet::CAddressBookData::CAddressBookData
CAddressBookData()
Definition: wallet.h:208
wallet::CWallet::MarkReplaced
bool MarkReplaced(const uint256 &originalHash, const uint256 &newHash)
Mark a transaction as replaced by another transaction (e.g., BIP 125).
Definition: wallet.cpp:839
wallet::CWallet::CanSupportFeature
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
Definition: wallet.h:449
wallet::CWallet::AddWalletDescriptor
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:3433
validationinterface.h
handler.h
wallet::MaybeResendWalletTxs
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
Definition: wallet.cpp:1903
wallet::CWallet::SignTransaction
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Fetch the inputs and sign with SIGHASH_ALL.
Definition: wallet.cpp:1916
wallet::CWallet::SyncMetaData
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:568
wallet::CWallet::m_chain_notifications_handler
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition: wallet.h:410
wallet::WALLET_FLAG_DESCRIPTORS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition: walletutil.h:66
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:17
wallet::CWallet::ImportPubKeys
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:1602
wallet::CRecipient
Definition: wallet.h:221
wallet::DEFAULT_TX_CONFIRM_TARGET
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
Definition: wallet.h:100
wallet::CWallet::GetActiveScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition: wallet.cpp:3146
wallet::CWallet::CanGetAddresses
bool CanGetAddresses(bool internal=false) const
Definition: wallet.cpp:1424
AnnotatedMixin< std::recursive_mutex >
wallet::CWallet::IsMine
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1371
wallet::DEFAULT_CONSOLIDATE_FEERATE
static const CAmount DEFAULT_CONSOLIDATE_FEERATE
-consolidatefeerate default
Definition: wallet.h:82
wallet::DBErrors
DBErrors
Error statuses for the wallet database.
Definition: walletdb.h:45
wallet
Definition: node.h:38
wallet::CWallet::m_spend_zero_conf_change
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...
Definition: wallet.h:605
wallet::CWallet::nAccountingEntryNumber
uint64_t nAccountingEntryNumber
Definition: wallet.h:398
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:23
wallet::CRecipient::fSubtractFeeFromAmount
bool fSubtractFeeFromAmount
Definition: wallet.h:225
wallet::DEFAULT_DISCARD_FEE
static const CAmount DEFAULT_DISCARD_FEE
-discardfee default
Definition: wallet.h:78
wallet::ReserveDestination::type
const OutputType type
Definition: wallet.h:168
wallet::CWallet::SetLastBlockProcessed
void SetLastBlockProcessed(int block_height, uint256 block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
Definition: wallet.h:849
wallet::CWallet::IsTxInMainChain
bool IsTxInMainChain(const CWalletTx &wtx) const
Definition: wallet.h:438
wallet::CWallet::nNextResend
int64_t nNextResend
The next scheduled rebroadcast of wallet transactions.
Definition: wallet.h:249
wallet::CWallet::Unlock
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
Definition: wallet.cpp:3131
wallet::CWallet::m_confirm_target
unsigned int m_confirm_target
Definition: wallet.h:602
chain.h
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:406
wallet::CWallet::GetAllScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
Definition: wallet.cpp:3160
wallet::CWallet::LoadWalletFlags
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
Definition: wallet.cpp:1469
wallet::CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:137
wallet::CWallet::GetNewChangeDestination
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, bilingual_str &error)
Definition: wallet.cpp:2282
wallet::CWallet::GetWalletTx
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:398
wallet::CWallet::LockCoin
bool LockCoin(const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2394
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
wallet::CWallet::nMasterKeyMaxID
unsigned int nMasterKeyMaxID
Definition: wallet.h:366
wallet::KNOWN_WALLET_FLAGS
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition: wallet.h:122
wallet::DEFAULT_TRANSACTION_MINFEE
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
Definition: wallet.h:80
SigningResult
SigningResult
Definition: message.h:42
wallet::CWallet::GUARDED_BY
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
wallet::CKeyingMaterial
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:62
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:279
wallet::CWallet::transactionRemovedFromMempool
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Definition: wallet.cpp:1267
AssertLockHeld
AssertLockHeld(pool.cs)
wallet::CWallet::DisplayAddress
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
Definition: wallet.cpp:2380
wallet::ReserveDestination::~ReserveDestination
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool.
Definition: wallet.h:186
scriptpubkeyman.h
wallet::CWallet::ScanResult::last_failed_block
uint256 last_failed_block
Height of the most recent block that could not be scanned due to read errors or pruning.
Definition: wallet.h:536
wallet::DUMMY_NESTED_P2WPKH_INPUT_SIZE
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE
Pre-calculated constants for input size estimation in virtual size
Definition: wallet.h:112
tinyformat.h
wallet::WALLET_FLAG_MAP
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:134
wallet::CWallet::FindAddressBookEntry
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3001
wallet::WalletRescanReserver::m_wallet
CWallet & m_wallet
Definition: wallet.h:905
wallet::CWallet::GetNewDestination
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, bilingual_str &error)
Definition: wallet.cpp:2263
wallet::CWallet::IsSpentKey
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:890
wallet::GetWallets
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
Definition: wallet.cpp:148
wallet::CWallet::ConnectScriptPubKeyManNotifiers
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition: wallet.cpp:3257
wallet::CWallet::transactionAddedToMempool
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Definition: wallet.cpp:1257
LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: wallet.h:45
wallet::CWallet::MarkInputsDirty
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:1133
wallet::WALLET_FLAG_EXTERNAL_SIGNER
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
Definition: walletutil.h:69
wallet::CAddressBookData::m_change
bool m_change
Definition: wallet.h:203
wallet::CWallet::IsLocked
bool IsLocked() const override
Definition: wallet.cpp:3108
strencodings.h
wallet::WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:15
TransactionError
TransactionError
Definition: error.h:22
interfaces::Chain
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:94
wallet::CWallet::AbandonTransaction
bool AbandonTransaction(const uint256 &hashTx)
Definition: wallet.cpp:1143
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:59
wallet::DEFAULT_ADDRESS_TYPE
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
Definition: wallet.h:120
FeeCalculation
Definition: fees.h:75
wallet::CWallet::m_max_aps_fee
CAmount m_max_aps_fee
The maximum fee amount we're willing to pay to prioritize partial spend avoidance.
Definition: wallet.h:627
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
walletutil.h
NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:51
wallet::CWallet::AttachChain
static bool AttachChain(const std::shared_ptr< CWallet > &wallet, interfaces::Chain &chain, const bool rescan_required, bilingual_str &error, std::vector< bilingual_str > &warnings)
Catch wallet up to current chain, scanning new blocks, updating the best block locator and m_last_blo...
Definition: wallet.cpp:2914
wallet::CWallet::RescanFromTime
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
Definition: wallet.cpp:1643
wallet::DatabaseStatus::SUCCESS
@ SUCCESS
wallet::CWallet::ReacceptWalletTransactions
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1789
coinselection.h
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
wallet::CWallet::ScanResult
Definition: wallet.h:523
wallet::RemoveWalletSetting
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:71
SignatureData
Definition: sign.h:63
wallet::SyncTxState
std::variant< TxStateConfirmed, TxStateInMempool, TxStateInactive > SyncTxState
Subset of states transaction sync logic is implemented to handle.
Definition: transaction.h:69
wallet::CWallet::SetBroadcastTransactions
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition: wallet.h:738
wallet::CAddressBookData::m_label
std::string m_label
Definition: wallet.h:204
wallet::CAddressBookData::SetLabel
void SetLabel(const std::string &label)
Definition: wallet.h:215
CTxOut
An output of a transaction.
Definition: transaction.h:148
wallet::MakeWalletDatabase
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
Definition: wallet.cpp:2644
wallet::CWallet::IsLockedCoin
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2426
Coin
A UTXO entry.
Definition: coins.h:30
wallet::CWallet::mapMasterKeys
MasterKeyMap mapMasterKeys
Definition: wallet.h:365
wallet::CWallet::AddToWalletIfInvolvingMe
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, const SyncTxState &state, bool fUpdate, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
Definition: wallet.cpp:1066
wallet::DEFAULT_TRANSACTION_MAXFEE
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition: wallet.h:106
wallet::LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:264
wallet::CWallet::IsLegacy
bool IsLegacy() const
Determine if we are a legacy wallet.
Definition: wallet.cpp:3387
wallet::CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:232
fs::path
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:29
wallet::CWallet::LoadDescriptorScriptPubKeyMan
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition: wallet.cpp:3265
wallet::CWallet::m_signal_rbf
bool m_signal_rbf
Definition: wallet.h:606
wallet::CWallet::GetDatabase
WalletDatabase & GetDatabase() const override
Definition: wallet.h:354
message.h
wallet::CWallet::GetTxDepthInMainChain
int GetTxDepthInMainChain(const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
Definition: wallet.cpp:3076
wallet::WALLET_FLAG_BLANK_WALLET
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
Definition: walletutil.h:63
FeeEstimateMode
FeeEstimateMode
Definition: feerate.h:18
wallet::CWallet::m_external_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Definition: wallet.h:333
wallet::CWallet::HaveChain
bool HaveChain() const
Interface to assert chain access.
Definition: wallet.h:388
wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition: walletutil.h:51
wallet::ReserveDestination::m_spk_man
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called.
Definition: wallet.h:167
wallet::CWallet::GetTxConflicts
std::set< uint256 > GetTxConflicts(const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS
Definition: wallet.cpp:1845
wallet::CWallet::ReorderTransactions
DBErrors ReorderTransactions()
Definition: wallet.cpp:761
wallet::HIGH_MAX_TX_FEE
constexpr CAmount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
Definition: wallet.h:110
wallet::CWallet::ComputeTimeSmart
unsigned int ComputeTimeSmart(const CWalletTx &wtx, bool rescanning_old_block) const
Compute smart timestamp for a transaction being added to the wallet.
Definition: wallet.cpp:2529
wallet::GetWallet
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
Definition: wallet.cpp:154
wallet::CWallet::BackupWallet
bool BackupWallet(const std::string &strDest) const
Definition: wallet.cpp:3056
wallet::CWallet::GetLabelAddresses
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2324
wallet::CWallet::GetKeyPoolSize
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2242
wallet::CWallet::CWallet
CWallet(interfaces::Chain *chain, const std::string &name, const ArgsManager &args, std::unique_ptr< WalletDatabase > database)
Construct wallet with specified name and database implementation.
Definition: wallet.h:369
wallet::WalletBatch
Access to the wallet database.
Definition: walletdb.h:180
LogPrintf
#define LogPrintf(...)
Definition: logging.h:188
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
wallet::CWallet::m_scanning_progress
std::atomic< double > m_scanning_progress
Definition: wallet.h:242
wallet::CWallet::postInitProcess
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
Definition: wallet.cpp:3044
wallet::HIGH_TX_FEE_PER_KB
constexpr CAmount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
Definition: wallet.h:108
context
WalletContext context
Definition: notifications.cpp:37
wallet::CWallet::LoadActiveScriptPubKeyMan
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:3350
wallet::CWallet::SetAddressBook
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:2190
wallet::WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:42
wallet::DEFAULT_WALLET_REJECT_LONG_CHAINS
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
Definition: wallet.h:98
wallet::CreateWallet
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)
Definition: wallet.cpp:263
wallet::CWallet::m_min_fee
CFeeRate m_min_fee
Override with -mintxfee.
Definition: wallet.h:608
wallet::CWallet::m_name
std::string m_name
Wallet name: relative directory name or "" for default wallet.
Definition: wallet.h:312
wallet::CWallet::ResendWalletTransactions
void ResendWalletTransactions()
Definition: wallet.cpp:1865
wallet::CWallet::IsAddressUsed
bool IsAddressUsed(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2601
wallet::CWallet::blockConnected
void blockConnected(const CBlock &block, int height) override
Definition: wallet.cpp:1304
wallet::WALLET_FLAG_LAST_HARDENED_XPUB_CACHED
@ WALLET_FLAG_LAST_HARDENED_XPUB_CACHED
Definition: walletutil.h:48
uint256
256-bit opaque blob.
Definition: uint256.h:126
wallet::CWallet::GetOrCreateLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
Definition: wallet.cpp:3227
wallet::CWallet::~CWallet
~CWallet()
Definition: wallet.h:377
wallet::CWallet::fScanningWallet
std::atomic< bool > fScanningWallet
Definition: wallet.h:240
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
wallet::CWallet::GetName
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:362
wallet::CWallet::UpgradeDescriptorCache
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade DescriptorCaches.
Definition: wallet.cpp:422
wallet::TxState
std::variant< TxStateConfirmed, TxStateInMempool, TxStateConflicted, TxStateInactive, TxStateUnrecognized > TxState
All possible CWalletTx states.
Definition: transaction.h:66
wallet::CWallet::ScanForWalletTransactions
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.
Definition: wallet.cpp:1686
wallet::CWallet::AddToSpends
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:630
wallet::WalletRescanReserver::isReserved
bool isReserved() const
Definition: wallet.h:922
wallet::HIGH_APS_FEE
constexpr CAmount HIGH_APS_FEE
discourage APS fee higher than this amount
Definition: wallet.h:92
wallet::CWallet::m_spk_managers
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
Definition: wallet.h:338
wallet::CWallet::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:724
wallet::CWallet::LoadWallet
DBErrors LoadWallet()
Definition: wallet.cpp:2116
wallet::CWallet::ScanningDuration
int64_t ScanningDuration() const
Definition: wallet.h:472
wallet::CWallet::NotifyAddressBookChanged
boost::signals2::signal< void(const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
Definition: wallet.h:712
wallet::WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_KEY_ORIGIN_METADATA
Definition: walletutil.h:45
wallet::CWallet::UnlockCoin
bool UnlockCoin(const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2404
wallet::CWallet::IsScanning
bool IsScanning() const
Definition: wallet.h:471
wallet::CWallet::cs_wallet
RecursiveMutex cs_wallet
Main wallet lock.
Definition: wallet.h:352
wallet::CWallet::IncOrderPosNext
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
Definition: wallet.cpp:818
wallet::CWallet::IsAbortingRescan
bool IsAbortingRescan() const
Definition: wallet.h:470
wallet::CWallet::Flush
void Flush()
Flush wallet (bitdb flush)
Definition: wallet.cpp:558
name
const char * name
Definition: rest.cpp:52
wallet::DEFAULT_PAY_TX_FEE
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:74
wallet::CWallet::m_fallback_fee
CFeeRate m_fallback_fee
If fee estimation does not have enough data to provide estimates, use this fee instead.
Definition: wallet.h:614
wallet::CWallet::m_default_address_type
OutputType m_default_address_type
Definition: wallet.h:628
transaction.h
OutputType::BECH32
@ BECH32
system.h
CBlock
Definition: block.h:62
PKHash
Definition: standard.h:79
wallet::ReserveDestination::GetReservedDestination
bool GetReservedDestination(CTxDestination &pubkey, bool internal, bilingual_str &error)
Reserve an address.
Definition: wallet.cpp:2339
wallet::CWallet::UnsetBlankWalletFlag
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
Definition: wallet.cpp:1459
wallet::CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:721
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
wallet::CWallet::GetAddressReceiveRequests
std::vector< std::string > GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2616
wallet::ReserveDestination
A wrapper to reserve an address from a wallet.
Definition: wallet.h:161
wallet::CAddressBookData::purpose
std::string purpose
Definition: wallet.h:206
wallet::CWallet::SyncTransaction
void SyncTransaction(const CTransactionRef &tx, const SyncTxState &state, bool update_tx=true, bool rescanning_old_block=false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1246
wallet::CWallet::m_database
const std::unique_ptr< WalletDatabase > m_database
Internal database handle.
Definition: wallet.h:315
wallet::CWallet::UpgradeKeyMetadata
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: wallet.cpp:407
wallet::ReserveDestination::KeepDestination
void KeepDestination()
Keep the address. Do not return it's key to the keypool when this object goes out of scope.
Definition: wallet.cpp:2362
wallet::CWallet::GetScriptPubKeyMan
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition: wallet.cpp:3169
LOCKS_EXCLUDED
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
wallet::CWallet::fBroadcastTransactions
bool fBroadcastTransactions
Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadca...
Definition: wallet.h:252
wallet::ReserveDestination::operator=
ReserveDestination & operator=(const ReserveDestination &)=delete
wallet::CWallet::GetBroadcastTransactions
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
Definition: wallet.h:736
wallet::MUTABLE_WALLET_FLAGS
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:131
wallet::CWallet::Close
void Close()
Close wallet database.
Definition: wallet.cpp:563
wallet::CWallet::GetDisplayName
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:793
wallet::CWallet::m_args
const ArgsManager & m_args
Provider of aplication-wide arguments.
Definition: wallet.h:306
ArgsManager
Definition: system.h:164
wallet::CWallet::blockDisconnected
void blockDisconnected(const CBlock &block, int height) override
Definition: wallet.cpp:1317
wallet::CWallet::GetLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition: wallet.cpp:3215
wallet::CRecipient::nAmount
CAmount nAmount
Definition: wallet.h:224
wallet::CAddressBookData::StringMap
std::map< std::string, std::string > StringMap
Definition: wallet.h:210
wallet::CWallet::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2225
wallet::CWallet::NotifyStatusChanged
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: wallet.h:733
wallet::CWallet::AbortRescan
void AbortRescan()
Definition: wallet.h:469
wallet::DEFAULT_WALLET_RBF
static const bool DEFAULT_WALLET_RBF
-walletrbf default
Definition: wallet.h:102
wallet::LoadWallet
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)
Definition: wallet.cpp:250
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
wallet::CWallet::wtxOrdered
TxItems wtxOrdered
Definition: wallet.h:395
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:668
LOCK
#define LOCK(cs)
Definition: sync.h:226
wallet::CWallet::m_default_change_type
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
Definition: wallet.h:635
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:347
interfaces::Chain::Notifications
Chain notifications.
Definition: chain.h:232
wallet::CWallet::ScanResult::last_scanned_height
std::optional< int > last_scanned_height
Definition: wallet.h:530
wallet::WalletRescanReserver::WalletRescanReserver
WalletRescanReserver(CWallet &w)
Definition: wallet.h:908
wallet::RestoreWallet
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)
Definition: wallet.cpp:361
std
Definition: setup_common.h:33
wallet::CAddressBookData::IsChange
bool IsChange() const
Definition: wallet.h:213
wallet::CWallet::EncryptWallet
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:659
wallet::COutput
Definition: spend.h:17
wallet::CWallet::Create
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)
Definition: wallet.cpp:2668
m_wallet
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:509
wallet::CWallet::GetDebit
CAmount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
Definition: wallet.cpp:1349
wallet::CWallet::SetupDescriptorScriptPubKeyMans
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition: wallet.cpp:3276
wallet::CWallet::TopUpKeyPool
bool TopUpKeyPool(unsigned int kpSize=0)
Definition: wallet.cpp:2253
wallet::CWallet::NotifyTransactionChanged
boost::signals2::signal< void(const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:718
wallet::CWallet::SetMinVersion
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
Definition: wallet.cpp:512
wallet::AddWalletSetting
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:60
wallet::CWallet::GetEncryptionKey
const CKeyingMaterial & GetEncryptionKey() const override
Definition: wallet.cpp:3247
wallet::CWallet::UnlockAllCoins
bool UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2414
wallet::CWallet::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
Definition: wallet.cpp:3199
wallet::CWallet::m_allow_fallback_fee
bool m_allow_fallback_fee
will be false if -fallbackfee=0
Definition: wallet.h:607
wallet::CWallet::ChangeWalletPassphrase
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:460
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
wallet::CWallet::m_consolidate_feerate
CFeeRate m_consolidate_feerate
When the actual feerate is less than the consolidate feerate, we will tend to make transactions which...
Definition: wallet.h:624
wallet::WalletRescanReserver::reserve
bool reserve()
Definition: wallet.h:910
wallet::DEFAULT_DISABLE_WALLET
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:104
wallet::CWallet::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1592
wallet::CWallet::m_chain
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition: wallet.h:309
wallet::CWallet::chainStateFlushed
void chainStateFlushed(const CBlockLocator &loc) override
Definition: wallet.cpp:506
wallet::CWallet::GetTxBlocksToMaturity
int GetTxBlocksToMaturity(const CWalletTx &wtx) const
Definition: wallet.cpp:3088
wallet::CWallet::SetupLegacyScriptPubKeyMan
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition: wallet.cpp:3233
wallet::CWallet::SubmitTxMemoryPoolAndRelay
bool SubmitTxMemoryPoolAndRelay(CWalletTx &wtx, std::string &err_string, bool relay) const
Pass this transaction to node for mempool insertion and relay to peers if flag set to true.
Definition: wallet.cpp:1817
wallet::WalletRescanReserver::~WalletRescanReserver
~WalletRescanReserver()
Definition: wallet.h:927
wallet::CWallet::AddActiveScriptPubKeyMan
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:3341
wallet::DEFAULT_SPEND_ZEROCONF_CHANGE
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:96
wallet::CWallet::SetSpentKeyState
void SetSpentKeyState(WalletBatch &batch, const uint256 &hash, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:871
wallet::WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:76
walletdb.h
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
wallet::CWallet::TxItems
std::multimap< int64_t, CWalletTx * > TxItems
Definition: wallet.h:394
wallet::CWallet::HasEncryptionKeys
bool HasEncryptionKeys() const override
Definition: wallet.cpp:3252
wallet::CWallet::m_wallet_flags
std::atomic< uint64_t > m_wallet_flags
WalletFlags set on this wallet.
Definition: wallet.h:295
wallet::ReserveDestination::nIndex
int64_t nIndex
The index of the address's key in the keypool.
Definition: wallet.h:170
wallet::CWallet::IsSpent
bool IsSpent(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction spends it:
Definition: wallet.cpp:611
wallet::WalletContext
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:35
wallet::WALLET_FLAG_CAVEATS
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:52
wallet::UnloadWallet
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:194
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
wallet::CWallet::GetConflicts
std::set< uint256 > GetConflicts(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get wallet transactions that conflict with given transaction (spend same outputs)
Definition: wallet.cpp:528
COIN
static constexpr CAmount COIN
The amount of satoshis in one BTC.
Definition: amount.h:15
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:364
wallet::CWallet::GetLastBlockHash
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:842
CBlockLocator
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:114
wallet::mapValue_t
std::map< std::string, std::string > mapValue_t
Definition: transaction.h:111
wallet::ScriptPubKeyMan
Definition: scriptpubkeyman.h:166
wallet::CWallet::GetLastBlockHeight
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
Definition: wallet.h:836
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:138
wallet::CWallet::UnsetWalletFlag
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
Definition: wallet.cpp:1445
wallet::CWallet::GetDescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition: wallet.cpp:3396
wallet::CRecipient::scriptPubKey
CScript scriptPubKey
Definition: wallet.h:223
wallet::CWallet::MasterKeyMap
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition: wallet.h:364
wallet::RemoveWallet
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:122
wallet::CWallet::GUARDED_BY
int nWalletVersion GUARDED_BY(cs_wallet)
the current wallet version: clients below this version are not able to load the wallet
Definition: wallet.h:246
wallet::WALLET_INCREMENTAL_RELAY_FEE
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
Definition: wallet.h:94
wallet::CWallet::m_best_block_time
std::atomic< int64_t > m_best_block_time
Definition: wallet.h:254
wallet::CWallet::m_pay_tx_fee
CFeeRate m_pay_tx_fee
Definition: wallet.h:601
wallet::CWallet::CommitTransaction
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.
Definition: wallet.cpp:2076
amount.h
wallet::CWallet::LoadMinVersion
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:481
wallet::CWallet::GetKeyBirthTimes
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2446
wallet::WalletRescanReserver::m_could_reserve
bool m_could_reserve
Definition: wallet.h:906
wallet::CWallet::MarkDestinationsDirty
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:2310
wallet::CCoinControl
Coin Control Features.
Definition: coincontrol.h:29
wallet::CWallet::DummySignTx
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, const CCoinControl *coin_control=nullptr) const
Definition: wallet.h:588
wallet::ReserveDestination::ReturnDestination
void ReturnDestination()
Return reserved address.
Definition: wallet.cpp:2371
wallet::CWallet::m_default_max_tx_fee
CAmount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
Definition: wallet.h:637
wallet::CWallet::SetAddressReceiveRequest
bool SetAddressReceiveRequest(WalletBatch &batch, const CTxDestination &dest, const std::string &id, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2630
wallet::CWallet::IsWalletFlagSet
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
Definition: wallet.cpp:1464
wallet::CWallet::TransactionChangeType
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
Definition: wallet.cpp:2013
wallet::CAddressBookData::GetLabel
const std::string & GetLabel() const
Definition: wallet.h:214
wallet::CWallet::AddWalletFlags
bool AddWalletFlags(uint64_t flags)
overwrite all flags by the given uint64_t returns false if unknown, non-tolerable flags are present
Definition: wallet.cpp:1481
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:117
wallet::CWallet::IsTxImmatureCoinBase
bool IsTxImmatureCoinBase(const CWalletTx &wtx) const
Definition: wallet.cpp:3097
wallet::CWallet::TransactionCanBeAbandoned
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
Definition: wallet.cpp:1126
wallet::CWallet::NotifyUnload
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:703
FlatSigningProvider
Definition: signingprovider.h:72
wallet::IsFeatureSupported
bool IsFeatureSupported(int wallet_version, int feature_version)
Definition: walletutil.cpp:33
wallet::CWallet::ScanningProgress
double ScanningProgress() const
Definition: wallet.h:473
wallet::CWallet::TxSpends
std::multimap< COutPoint, uint256 > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
Definition: wallet.h:261
args
ArgsManager args
Definition: notifications.cpp:36
wallet::DummySignInput
bool DummySignInput(const SigningProvider &provider, CTxIn &tx_in, const CTxOut &txout, bool use_max_sig)
Definition: wallet.cpp:1495
SIGHASH_DEFAULT
@ SIGHASH_DEFAULT
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
Definition: interpreter.h:33
wallet::CWallet::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, int sighash_type=SIGHASH_DEFAULT, bool sign=true, bool bip32derivs=true, size_t *n_signed=nullptr, bool finalize=true) const
Fills out a PSBT with information from the wallet.
Definition: wallet.cpp:1950