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-2020 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 <interfaces/chain.h>
11 #include <interfaces/handler.h>
12 #include <outputtype.h>
13 #include <policy/feerate.h>
14 #include <psbt.h>
15 #include <tinyformat.h>
16 #include <util/message.h>
17 #include <util/strencodings.h>
18 #include <util/string.h>
19 #include <util/system.h>
20 #include <util/ui_change_type.h>
21 #include <validationinterface.h>
22 #include <wallet/coinselection.h>
23 #include <wallet/crypter.h>
24 #include <wallet/scriptpubkeyman.h>
25 #include <wallet/transaction.h>
26 #include <wallet/walletdb.h>
27 #include <wallet/walletutil.h>
28 
29 #include <algorithm>
30 #include <atomic>
31 #include <map>
32 #include <memory>
33 #include <optional>
34 #include <set>
35 #include <stdexcept>
36 #include <stdint.h>
37 #include <string>
38 #include <utility>
39 #include <vector>
40 
41 #include <boost/signals2/signal.hpp>
42 
43 struct WalletContext;
44 
45 using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
46 
47 struct bilingual_str;
48 
54 void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
55 
56 bool AddWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
57 bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
58 bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start);
59 std::vector<std::shared_ptr<CWallet>> GetWallets(WalletContext& context);
60 std::shared_ptr<CWallet> GetWallet(WalletContext& context, const std::string& name);
61 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);
62 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);
63 std::unique_ptr<interfaces::Handler> HandleLoadWallet(WalletContext& context, LoadWalletFn load_wallet);
64 std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
65 
69 static const CAmount DEFAULT_FALLBACK_FEE = 0;
71 static const CAmount DEFAULT_DISCARD_FEE = 10000;
73 static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
75 static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte
85 constexpr CAmount HIGH_APS_FEE{COIN / 10000};
89 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
91 static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
93 static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
95 static const bool DEFAULT_WALLET_RBF = false;
96 static const bool DEFAULT_WALLETBROADCAST = true;
97 static const bool DEFAULT_DISABLE_WALLET = false;
101 constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
105 static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
106 
107 class CCoinControl;
108 class COutput;
109 class CScript;
110 class CWalletTx;
111 struct FeeCalculation;
112 enum class FeeEstimateMode;
113 class ReserveDestination;
114 
117 
118 static constexpr uint64_t KNOWN_WALLET_FLAGS =
126 
127 static constexpr uint64_t MUTABLE_WALLET_FLAGS =
129 
130 static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
131  {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
132  {"blank", WALLET_FLAG_BLANK_WALLET},
133  {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
134  {"last_hardened_xpub_cached", WALLET_FLAG_LAST_HARDENED_XPUB_CACHED},
135  {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
136  {"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
137  {"external_signer", WALLET_FLAG_EXTERNAL_SIGNER}
138 };
139 
140 extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;
141 
158 {
159 protected:
161  const CWallet* const pwallet;
166  int64_t nIndex{-1};
170  bool fInternal{false};
171 
172 public:
175  : pwallet(pwallet)
176  , type(type) { }
177 
178  ReserveDestination(const ReserveDestination&) = delete;
180 
183  {
185  }
186 
188  bool GetReservedDestination(CTxDestination& pubkey, bool internal, bilingual_str& error);
190  void ReturnDestination();
192  void KeepDestination();
193 };
194 
197 {
198 private:
199  bool m_change{true};
200  std::string m_label;
201 public:
202  std::string purpose;
203 
204  CAddressBookData() : purpose("unknown") {}
205 
206  typedef std::map<std::string, std::string> StringMap;
208 
209  bool IsChange() const { return m_change; }
210  const std::string& GetLabel() const { return m_label; }
211  void SetLabel(const std::string& label) {
212  m_change = false;
213  m_label = label;
214  }
215 };
216 
218 {
222 };
223 
224 class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime
229 {
230 private:
232 
233  bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys = false);
234 
235  std::atomic<bool> fAbortRescan{false};
236  std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
237  std::atomic<int64_t> m_scanning_start{0};
238  std::atomic<double> m_scanning_progress{0};
239  friend class WalletRescanReserver;
240 
242  int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
243 
245  int64_t nNextResend = 0;
249  // Local time that the tip block was received. Used to schedule wallet rebroadcasts.
250  std::atomic<int64_t> m_best_block_time {0};
251 
257  typedef std::multimap<COutPoint, uint256> TxSpends;
258  TxSpends mapTxSpends GUARDED_BY(cs_wallet);
259  void AddToSpends(const COutPoint& outpoint, const uint256& wtxid, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
260  void AddToSpends(const uint256& wtxid, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
261 
278  bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, CWalletTx::Confirmation confirm, bool fUpdate, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
279 
281  void MarkConflicted(const uint256& hashBlock, int conflicting_height, const uint256& hashTx);
282 
285 
286  void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
287 
288  /* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
289  * Should be called with non-zero block_hash and posInBlock if this is for a transaction that is included in a block. */
290  void SyncTransaction(const CTransactionRef& tx, CWalletTx::Confirmation confirm, bool update_tx = true, bool rescanning_old_block = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
291 
293  std::atomic<uint64_t> m_wallet_flags{0};
294 
295  bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
296 
298  void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
299 
301  void UnsetBlankWalletFlag(WalletBatch& batch) override;
302 
305 
307  std::string m_name;
308 
310  std::unique_ptr<WalletDatabase> const m_database;
311 
319  uint256 m_last_block_processed GUARDED_BY(cs_wallet);
320 
326  int m_last_block_processed_height GUARDED_BY(cs_wallet) = -1;
327 
328  std::map<OutputType, ScriptPubKeyMan*> m_external_spk_managers;
329  std::map<OutputType, ScriptPubKeyMan*> m_internal_spk_managers;
330 
331  // Indexed by a unique identifier produced by each ScriptPubKeyMan using
332  // ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal structure
333  std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
334 
340  static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings);
341 
342 public:
348 
349  WalletDatabase& GetDatabase() const override
350  {
351  assert(static_cast<bool>(m_database));
352  return *m_database;
353  }
354 
357  const std::string& GetName() const { return m_name; }
358 
359  typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
361  unsigned int nMasterKeyMaxID = 0;
362 
364  CWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database)
365  : m_chain(chain),
366  m_name(name),
367  m_database(std::move(database))
368  {
369  }
370 
372  {
373  // Should not have slots connected at this point.
374  assert(NotifyUnload.empty());
375  }
376 
377  bool IsCrypted() const;
378  bool IsLocked() const override;
379  bool Lock();
380 
382  bool HaveChain() const { return m_chain ? true : false; }
383 
386  std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
387 
388  typedef std::multimap<int64_t, CWalletTx*> TxItems;
390 
391  int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
393 
394  std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
395  const CAddressBookData* FindAddressBookEntry(const CTxDestination&, bool allow_change = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
396 
401  std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
402 
404  std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
405 
407  interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
408 
410 
411  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
412  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
413  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
414  // resolve the issue of member access into incomplete type CWallet. Note
415  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
416  // in place.
417  std::set<uint256> GetTxConflicts(const CWalletTx& wtx) const NO_THREAD_SAFETY_ANALYSIS;
418 
425  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
426  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
427  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
428  // resolve the issue of member access into incomplete type CWallet. Note
429  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
430  // in place.
432  bool IsTxInMainChain(const CWalletTx& wtx) const { return GetTxDepthInMainChain(wtx) > 0; }
433 
439  int GetTxBlocksToMaturity(const CWalletTx& wtx) const;
440  bool IsTxImmatureCoinBase(const CWalletTx& wtx) const;
441 
443  bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return IsFeatureSupported(nWalletVersion, wf); }
444 
445  bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
446 
447  // Whether this or any known UTXO with the same single key has been spent.
448  bool IsSpentKey(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
449  void SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
450 
453 
454  bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
455  bool LockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
456  bool UnlockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
458  void ListLockedCoins(std::vector<COutPoint>& vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
459 
460  /*
461  * Rescan abort properties
462  */
463  void AbortRescan() { fAbortRescan = true; }
464  bool IsAbortingRescan() const { return fAbortRescan; }
465  bool IsScanning() const { return fScanningWallet; }
466  int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
467  double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
468 
471 
474 
475  bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; return true; }
476 
478  void LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
479 
481  int64_t nRelockTime GUARDED_BY(cs_wallet){0};
482 
483  // Used to prevent concurrent calls to walletpassphrase RPC.
485  bool Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys = false);
486  bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
487  bool EncryptWallet(const SecureString& strWalletPassphrase);
488 
489  void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
490  unsigned int ComputeTimeSmart(const CWalletTx& wtx, bool rescanning_old_block) const;
491 
498 
499  void MarkDirty();
500 
507  using UpdateWalletTxFn = std::function<bool(CWalletTx& wtx, bool new_tx)>;
508 
509  CWalletTx* AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation& confirm, const UpdateWalletTxFn& update_wtx=nullptr, bool fFlushOnClose=true, bool rescanning_old_block = false);
510  bool LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
511  void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override;
512  void blockConnected(const CBlock& block, int height) override;
513  void blockDisconnected(const CBlock& block, int height) override;
514  void updatedBlockTip() override;
515  int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
516 
517  struct ScanResult {
518  enum { SUCCESS, FAILURE, USER_ABORT } status = SUCCESS;
519 
524  std::optional<int> last_scanned_height;
525 
531  };
532  ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate);
533  void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override;
536 
537  OutputType TransactionChangeType(const std::optional<OutputType>& change_type, const std::vector<CRecipient>& vecSend) const;
538 
542  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const;
543  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const;
544 
559  bool& complete,
560  int sighash_type = 1 /* SIGHASH_ALL */,
561  bool sign = true,
562  bool bip32derivs = true,
563  size_t* n_signed = nullptr) const;
564 
574  void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm);
575 
577  bool SubmitTxMemoryPoolAndRelay(const CWalletTx& wtx, std::string& err_string, bool relay) const;
578 
579  bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, const CCoinControl* coin_control = nullptr) const
580  {
581  std::vector<CTxOut> v_txouts(txouts.size());
582  std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
583  return DummySignTx(txNew, v_txouts, coin_control);
584  }
585  bool DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut> &txouts, const CCoinControl* coin_control = nullptr) const;
586 
587  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
588  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
589  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);
590  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);
591 
598  bool m_allow_fallback_fee{true};
600 
606 
610 
616 
626  std::optional<OutputType> m_default_change_type{};
629 
631  bool TopUpKeyPool(unsigned int kpSize = 0);
632 
633  int64_t GetOldestKeyPoolTime() const;
634 
635  std::set<CTxDestination> GetLabelAddresses(const std::string& label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
636 
641  void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
642 
643  bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, bilingual_str& error);
645 
652  CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
654  bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
656  bool IsFromMe(const CTransaction& tx) const;
657  CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
658  void chainStateFlushed(const CBlockLocator& loc) override;
659 
661  DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
662 
663  bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
664 
665  bool DelAddressBook(const CTxDestination& address);
666 
668  bool SetAddressUsed(WalletBatch& batch, const CTxDestination& dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
669 
670  std::vector<std::string> GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
671  bool SetAddressReceiveRequest(WalletBatch& batch, const CTxDestination& dest, const std::string& id, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
672 
673  unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
674 
676  void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr) override;
677 
679  int GetVersion() const { LOCK(cs_wallet); return nWalletVersion; }
680 
682  std::set<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
683 
685  bool HasWalletSpend(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
686 
688  void Flush();
689 
691  void Close();
692 
694  boost::signals2::signal<void ()> NotifyUnload;
695 
700  boost::signals2::signal<void(const CTxDestination& address,
701  const std::string& label, bool isMine,
702  const std::string& purpose, ChangeType status)>
704 
709  boost::signals2::signal<void(const uint256& hashTx, ChangeType status)> NotifyTransactionChanged;
710 
712  boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
713 
715  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
716 
718  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
719 
724  boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
725 
729  void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
730 
732  bool TransactionCanBeAbandoned(const uint256& hashTx) const;
733 
734  /* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
735  bool AbandonTransaction(const uint256& hashTx);
736 
738  bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
739 
740  /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
741  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);
742 
747  void postInitProcess();
748 
749  bool BackupWallet(const std::string& strDest) const;
750 
751  /* Returns true if HD is enabled */
752  bool IsHDEnabled() const;
753 
754  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
755  bool CanGetAddresses(bool internal = false) const;
756 
763  void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(::cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_wallet);
764 
766  void SetWalletFlag(uint64_t flags);
767 
769  void UnsetWalletFlag(uint64_t flag);
770 
772  bool IsWalletFlagSet(uint64_t flag) const override;
773 
776  bool AddWalletFlags(uint64_t flags);
778  bool LoadWalletFlags(uint64_t flags);
779 
781  bool IsLegacy() const;
782 
784  const std::string GetDisplayName() const override {
785  std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
786  return strprintf("[%s]", wallet_name);
787  };
788 
790  template<typename... Params>
791  void WalletLogPrintf(std::string fmt, Params... parameters) const {
792  LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
793  };
794 
796  bool UpgradeWallet(int version, bilingual_str& error);
797 
799  std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
800 
802  std::set<ScriptPubKeyMan*> GetAllScriptPubKeyMans() const;
803 
805  ScriptPubKeyMan* GetScriptPubKeyMan(const OutputType& type, bool internal) const;
806 
808  ScriptPubKeyMan* GetScriptPubKeyMan(const CScript& script) const;
810  ScriptPubKeyMan* GetScriptPubKeyMan(const uint256& id) const;
811 
813  std::set<ScriptPubKeyMan*> GetScriptPubKeyMans(const CScript& script, SignatureData& sigdata) const;
814 
816  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const;
817  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script, SignatureData& sigdata) const;
818 
822 
825 
826  const CKeyingMaterial& GetEncryptionKey() const override;
827  bool HasEncryptionKeys() const override;
828 
831  {
833  assert(m_last_block_processed_height >= 0);
834  return m_last_block_processed_height;
835  };
837  {
839  assert(m_last_block_processed_height >= 0);
840  return m_last_block_processed;
841  }
844  {
846  m_last_block_processed_height = block_height;
847  m_last_block_processed = block_hash;
848  };
849 
852 
855 
860  void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
861 
866  void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
867 
872  void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal);
873 
876 
879 
881  ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
882 };
883 
888 void MaybeResendWalletTxs(WalletContext& context);
889 
892 {
893 private:
896 public:
898 
899  bool reserve()
900  {
902  if (m_wallet.fScanningWallet.exchange(true)) {
903  return false;
904  }
905  m_wallet.m_scanning_start = GetTimeMillis();
906  m_wallet.m_scanning_progress = 0;
907  m_could_reserve = true;
908  return true;
909  }
910 
911  bool isReserved() const
912  {
913  return (m_could_reserve && m_wallet.fScanningWallet);
914  }
915 
917  {
918  if (m_could_reserve) {
919  m_wallet.fScanningWallet = false;
920  }
921  }
922 };
923 
925 bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
926 
928 bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
929 
930 bool DummySignInput(const SigningProvider& provider, CTxIn &tx_in, const CTxOut &txout, bool use_max_sig);
931 
932 #endif // BITCOIN_WALLET_WALLET_H
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:70
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:530
CWallet::GetKeyPoolSize
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2118
DatabaseOptions
Definition: db.h:203
CTxIn
An input of a transaction.
Definition: transaction.h:65
interfaces
Definition: dummywallet.cpp:11
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:791
ReserveDestination::GetReservedDestination
bool GetReservedDestination(CTxDestination &pubkey, bool internal, bilingual_str &error)
Reserve an address.
Definition: wallet.cpp:2211
CWallet::UpgradeDescriptorCache
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade DescriptorCaches.
Definition: wallet.cpp:385
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:609
CWallet::ConnectScriptPubKeyManNotifiers
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition: wallet.cpp:3131
crypter.h
ReserveDestination::fInternal
bool fInternal
Whether this is from the internal (change output) keypool.
Definition: wallet.h:170
CWallet::CWallet
CWallet(interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > database)
Construct wallet with specified name and database implementation.
Definition: wallet.h:364
CWallet::GetActiveScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition: wallet.cpp:3010
feerate.h
CRecipient::fSubtractFeeFromAmount
bool fSubtractFeeFromAmount
Definition: wallet.h:221
CWallet::nMasterKeyMaxID
unsigned int nMasterKeyMaxID
Definition: wallet.h:361
CWallet::m_signal_rbf
bool m_signal_rbf
Definition: wallet.h:597
CAddressBookData::IsChange
bool IsChange() const
Definition: wallet.h:209
CWallet::m_external_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Definition: wallet.h:328
OutputType
OutputType
Definition: outputtype.h:18
ui_change_type.h
assert
assert(!tx.IsCoinBase())
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:1150
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:242
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:605
DatabaseStatus
DatabaseStatus
Definition: db.h:212
CWallet::ResendWalletTransactions
void ResendWalletTransactions()
Definition: wallet.cpp:1771
ReserveDestination::~ReserveDestination
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool.
Definition: wallet.h:182
CWallet::IsTxInMainChain
bool IsTxInMainChain(const CWalletTx &wtx) const
Definition: wallet.h:432
CWallet::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
Definition: wallet.cpp:3073
CWallet::MasterKeyMap
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition: wallet.h:359
WalletRescanReserver::WalletRescanReserver
WalletRescanReserver(CWallet &w)
Definition: wallet.h:897
CWallet::blockDisconnected
void blockDisconnected(const CBlock &block, int height) override
Definition: wallet.cpp:1273
isminefilter
uint8_t isminefilter
Definition: wallet.h:36
CWallet::m_confirm_target
unsigned int m_confirm_target
Definition: wallet.h:593
CWallet::IsAbortingRescan
bool IsAbortingRescan() const
Definition: wallet.h:464
CWallet::GetTxConflicts
std::set< uint256 > GetTxConflicts(const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS
Definition: wallet.cpp:1751
CWallet::IsFromMe
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
Definition: wallet.cpp:1353
CWallet::ReacceptWalletTransactions
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1695
CWallet::m_scanning_start
std::atomic< int64_t > m_scanning_start
Definition: wallet.h:237
flags
int flags
Definition: bitcoin-tx.cpp:525
GetWallets
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
Definition: wallet.cpp:143
CWallet::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const
Definition: wallet.cpp:2172
WALLET_FLAG_CAVEATS
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:51
CWallet::m_wallet_flags
std::atomic< uint64_t > m_wallet_flags
WalletFlags set on this wallet.
Definition: wallet.h:293
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:615
CWallet::GetLastBlockHeight
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
Definition: wallet.h:830
CWallet::IsWalletFlagSet
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
Definition: wallet.cpp:1421
CWallet::CanSupportFeature
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
Definition: wallet.h:443
string.h
CWallet::LoadDescriptorScriptPubKeyMan
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition: wallet.cpp:3139
DummySignInput
bool DummySignInput(const SigningProvider &provider, CTxIn &tx_in, const CTxOut &txout, bool use_max_sig)
Definition: wallet.cpp:1452
bilingual_str
Bilingual messages:
Definition: translation.h:16
DEFAULT_WALLET_REJECT_LONG_CHAINS
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
Definition: wallet.h:91
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:2782
FEATURE_BASE
@ FEATURE_BASE
Definition: walletutil.h:16
CWallet::GetNewDestination
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, bilingual_str &error)
Definition: wallet.cpp:2139
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:83
outputtype.h
CWallet::ScanResult::last_scanned_height
std::optional< int > last_scanned_height
Definition: wallet.h:524
CWallet::ScanResult::last_scanned_block
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition: wallet.h:523
CKeyingMaterial
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:61
CCoinControl
Coin Control Features.
Definition: coincontrol.h:28
validationinterface.h
MakeWalletDatabase
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Definition: wallet.cpp:2510
handler.h
CWallet::GetEncryptionKey
const CKeyingMaterial & GetEncryptionKey() const override
Definition: wallet.cpp:3121
CWallet::chain
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:407
WALLET_FLAG_EXTERNAL_SIGNER
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
Definition: walletutil.h:68
ReserveDestination::address
CTxDestination address
The destination.
Definition: wallet.h:168
CWallet::m_scanning_progress
std::atomic< double > m_scanning_progress
Definition: wallet.h:238
CWallet::IsCrypted
bool IsCrypted() const
Definition: wallet.cpp:2967
CWallet::NotifyUnload
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:694
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:618
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:18
ReserveDestination::pwallet
const CWallet *const pwallet
The wallet to reserve from.
Definition: wallet.h:161
CWallet::IsSpentKey
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:853
CWallet::nAccountingEntryNumber
uint64_t nAccountingEntryNumber
Definition: wallet.h:392
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:1592
CWallet::AbortRescan
void AbortRescan()
Definition: wallet.h:463
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:802
AnnotatedMixin< std::recursive_mutex >
CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:712
ReserveDestination::nIndex
int64_t nIndex
The index of the address's key in the keypool.
Definition: wallet.h:166
wallet
Definition: interfaces.cpp:50
WalletDatabase
An instance of this class represents one database.
Definition: db.h:103
WalletRescanReserver::reserve
bool reserve()
Definition: wallet.h:899
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:22
CWallet::GetBroadcastTransactions
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
Definition: wallet.h:727
ReserveDestination
A wrapper to reserve an address from a wallet.
Definition: wallet.h:157
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:3285
CWallet::AddToWalletIfInvolvingMe
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate, bool rescanning_old_block) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
Definition: wallet.cpp:1035
LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:250
CWallet::blockConnected
void blockConnected(const CBlock &block, int height) override
Definition: wallet.cpp:1260
chain.h
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
CWallet::SetAddressUsed
bool SetAddressUsed(WalletBatch &batch, const CTxDestination &dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2446
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:117
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
CWallet::IsAddressUsed
bool IsAddressUsed(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2467
CWallet::UnsetBlankWalletFlag
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
Definition: wallet.cpp:1416
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:103
CWallet::NotifyStatusChanged
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: wallet.h:724
CWallet::DummySignTx
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, const CCoinControl *coin_control=nullptr) const
Definition: wallet.h:579
SigningResult
SigningResult
Definition: message.h:42
CWallet::SignMessage
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Definition: wallet.cpp:1906
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
AssertLockHeld
AssertLockHeld(pool.cs)
scriptpubkeyman.h
tinyformat.h
CWallet::ZapSelectTx
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2015
CWallet::AddToSpends
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:593
CWallet::GetVersion
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition: wallet.h:679
CWallet::SetAddressBook
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:2066
WalletRescanReserver::m_wallet
CWallet & m_wallet
Definition: wallet.h:894
DEFAULT_CONSOLIDATE_FEERATE
static const CAmount DEFAULT_CONSOLIDATE_FEERATE
-consolidatefeerate default
Definition: wallet.h:75
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:784
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:514
DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:508
CWallet::MarkDirty
void MarkDirty()
Definition: wallet.cpp:793
CWallet::IsLockedCoin
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2299
CWallet::DelAddressBook
bool DelAddressBook(const CTxDestination &address)
Definition: wallet.cpp:2072
strencodings.h
CWallet::TransactionCanBeAbandoned
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
Definition: wallet.cpp:1079
CWallet::LoadWallet
DBErrors LoadWallet()
Definition: wallet.cpp:1992
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:92
CWallet::IsLocked
bool IsLocked() const override
Definition: wallet.cpp:2972
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:59
CWallet::Flush
void Flush()
Flush wallet (bitdb flush)
Definition: wallet.cpp:521
FeeCalculation
Definition: fees.h:75
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
walletutil.h
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:628
NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:51
CWallet::UpgradeKeyMetadata
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: wallet.cpp:370
WalletStorage
Definition: scriptpubkeyman.h:32
isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:38
coinselection.h
CRecipient::nAmount
CAmount nAmount
Definition: wallet.h:220
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
CWallet::UnlockAllCoins
bool UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2287
CWallet::ScanningDuration
int64_t ScanningDuration() const
Definition: wallet.h:466
CWallet::LoadWalletFlags
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
Definition: wallet.cpp:1426
SignatureData
Definition: sign.h:65
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:1952
CAddressBookData::m_change
bool m_change
Definition: wallet.h:199
CTxOut
An output of a transaction.
Definition: transaction.h:128
CWallet::m_best_block_time
std::atomic< int64_t > m_best_block_time
Definition: wallet.h:250
Coin
A UTXO entry.
Definition: coins.h:30
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:1518
CWallet::fScanningWallet
std::atomic< bool > fScanningWallet
Definition: wallet.h:236
CWallet::GetTxBlocksToMaturity
int GetTxBlocksToMaturity(const CWalletTx &wtx) const
Definition: wallet.cpp:2952
CWallet::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1498
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:2402
CWallet::m_name
std::string m_name
Wallet name: relative directory name or "" for default wallet.
Definition: wallet.h:307
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:2462
AddWallet
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:105
message.h
CWallet::UnsetWalletFlag
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
Definition: wallet.cpp:1402
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:257
CWallet::m_default_address_type
OutputType m_default_address_type
Definition: wallet.h:619
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:596
WALLET_INCREMENTAL_RELAY_FEE
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
Definition: wallet.h:87
CWallet::updatedBlockTip
void updatedBlockTip() override
Definition: wallet.cpp:1288
CWallet::SetupDescriptorScriptPubKeyMans
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition: wallet.cpp:3150
CWallet::UnsetWalletFlagWithDB
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
Definition: wallet.cpp:1408
DEFAULT_TRANSACTION_MAXFEE
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition: wallet.h:99
FeeEstimateMode
FeeEstimateMode
Definition: feerate.h:18
HIGH_APS_FEE
constexpr CAmount HIGH_APS_FEE
discourage APS fee higher than this amount
Definition: wallet.h:85
WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:41
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:258
CAddressBookData
Address book data.
Definition: wallet.h:196
CWallet::nNextResend
int64_t nNextResend
The next scheduled rebroadcast of wallet transactions.
Definition: wallet.h:245
DEFAULT_WALLET_RBF
static const bool DEFAULT_WALLET_RBF
-walletrbf default
Definition: wallet.h:95
MUTABLE_WALLET_FLAGS
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:127
CWallet::wtxOrdered
TxItems wtxOrdered
Definition: wallet.h:389
CWallet::m_chain_notifications_handler
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition: wallet.h:404
CAddressBookData::SetLabel
void SetLabel(const std::string &label)
Definition: wallet.h:211
LogPrintf
#define LogPrintf(...)
Definition: logging.h:187
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
WalletRescanReserver
RAII object to check and reserve a wallet rescan.
Definition: wallet.h:891
CWallet::AddActiveScriptPubKeyMan
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:3217
CWallet::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:715
CWallet::SetMinVersion
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
Definition: wallet.cpp:475
CWallet::IsHDEnabled
bool IsHDEnabled() const
Definition: wallet.cpp:1370
CWallet::~CWallet
~CWallet()
Definition: wallet.h:371
WalletRescanReserver::m_could_reserve
bool m_could_reserve
Definition: wallet.h:895
HandleLoadWallet
std::unique_ptr< interfaces::Handler > HandleLoadWallet(WalletContext &context, LoadWalletFn load_wallet)
Definition: wallet.cpp:158
CWallet::fBroadcastTransactions
bool fBroadcastTransactions
Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadca...
Definition: wallet.h:248
CWallet::GetDatabase
WalletDatabase & GetDatabase() const override
Definition: wallet.h:349
CWallet::transactionAddedToMempool
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Definition: wallet.cpp:1213
CWallet::GetName
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:357
CWallet::mapMasterKeys
MasterKeyMap mapMasterKeys
Definition: wallet.h:360
CWallet::ReorderTransactions
DBErrors ReorderTransactions()
Definition: wallet.cpp:724
CWallet::fAbortRescan
std::atomic< bool > fAbortRescan
Definition: wallet.h:235
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:843
CWallet::LockCoin
bool LockCoin(const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2267
uint256
256-bit opaque blob.
Definition: uint256.h:124
CWallet::IsTxImmatureCoinBase
bool IsTxImmatureCoinBase(const CWalletTx &wtx) const
Definition: wallet.cpp:2961
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:2534
CWallet::ScanResult
Definition: wallet.h:517
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:2944
CWallet::AbandonTransaction
bool AbandonTransaction(const uint256 &hashTx)
Definition: wallet.cpp:1096
CWallet::UpgradeWallet
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
Definition: wallet.cpp:2879
CWallet::GetDescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition: wallet.cpp:3272
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
CWallet::GetLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition: wallet.cpp:3089
CWallet::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2101
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:2182
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:62
CWallet::ListLockedCoins
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2307
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:1306
CWallet::TxItems
std::multimap< int64_t, CWalletTx * > TxItems
Definition: wallet.h:388
IsFeatureSupported
bool IsFeatureSupported(int wallet_version, int feature_version)
Definition: walletutil.cpp:32
CAddressBookData::CAddressBookData
CAddressBookData()
Definition: wallet.h:204
CWallet::SetupLegacyScriptPubKeyMan
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition: wallet.cpp:3107
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:491
mapValue_t
std::map< std::string, std::string > mapValue_t
Definition: transaction.h:20
WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition: walletutil.h:50
name
const char * name
Definition: rest.cpp:43
CWallet::EncryptWallet
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:622
CRecipient::scriptPubKey
CScript scriptPubKey
Definition: wallet.h:219
WalletRescanReserver::~WalletRescanReserver
~WalletRescanReserver()
Definition: wallet.h:916
transaction.h
OutputType::BECH32
@ BECH32
system.h
CBlock
Definition: block.h:62
CWallet::m_internal_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
Definition: wallet.h:329
PKHash
Definition: standard.h:79
UnloadWallet
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:189
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:59
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
ReserveDestination::type
const OutputType type
Definition: wallet.h:164
DBErrors
DBErrors
Error statuses for the wallet database.
Definition: walletdb.h:43
CWallet::m_database
const std::unique_ptr< WalletDatabase > m_database
Internal database handle.
Definition: wallet.h:310
CAddressBookData::purpose
std::string purpose
Definition: wallet.h:202
CWallet::transactionRemovedFromMempool
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Definition: wallet.cpp:1223
DEFAULT_SPEND_ZEROCONF_CHANGE
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:89
LOCKS_EXCLUDED
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
ScriptPubKeyMan
Definition: scriptpubkeyman.h:158
CWallet::SetAddressBookWithDB
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
Definition: wallet.cpp:2046
WALLET_FLAG_LAST_HARDENED_XPUB_CACHED
@ WALLET_FLAG_LAST_HARDENED_XPUB_CACHED
Definition: walletutil.h:47
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:118
CWallet::TopUpKeyPool
bool TopUpKeyPool(unsigned int kpSize=0)
Definition: wallet.cpp:2129
CWallet::AddToWallet
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true, bool rescanning_old_block=false)
Definition: wallet.cpp:888
CWallet::IsScanning
bool IsScanning() const
Definition: wallet.h:465
CWallet::postInitProcess
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
Definition: wallet.cpp:2912
CAddressBookData::destdata
StringMap destdata
Definition: wallet.h:207
KNOWN_WALLET_FLAGS
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition: wallet.h:118
CWallet::UnlockCoin
bool UnlockCoin(const COutPoint &output, WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2277
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:574
MaybeResendWalletTxs
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
Definition: wallet.cpp:1809
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
CWallet::BackupWallet
bool BackupWallet(const std::string &strDest) const
Definition: wallet.cpp:2924
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:391
CWallet::m_pay_tx_fee
CFeeRate m_pay_tx_fee
Definition: wallet.h:592
LOCK
#define LOCK(cs)
Definition: sync.h:226
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:393
interfaces::Chain::Notifications
Chain notifications.
Definition: chain.h:236
DEFAULT_ADDRESS_TYPE
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
Definition: wallet.h:116
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:2496
CWallet::Lock
bool Lock()
Definition: wallet.cpp:2981
DEFAULT_PAY_TX_FEE
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:67
CWallet::GetLabelAddresses
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2196
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:228
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:46
CAddressBookData::m_label
std::string m_label
Definition: wallet.h:200
ReserveDestination::m_spk_man
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called.
Definition: wallet.h:163
m_wallet
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:502
CWallet::IsMine
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1328
CWallet::m_spk_managers
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
Definition: wallet.h:333
CWallet::GetAllScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
Definition: wallet.cpp:3024
CWallet::GetAddressReceiveRequests
std::vector< std::string > GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2482
GetWallet
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
Definition: wallet.cpp:149
LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: context.h:22
CWallet::m_allow_fallback_fee
bool m_allow_fallback_fee
will be false if -fallbackfee=0
Definition: wallet.h:598
DEFAULT_WALLETBROADCAST
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:96
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
CWallet::HasEncryptionKeys
bool HasEncryptionKeys() const override
Definition: wallet.cpp:3126
CWallet::IsLegacy
bool IsLegacy() const
Determine if we are a legacy wallet.
Definition: wallet.cpp:3263
CWallet::IncOrderPosNext
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
Definition: wallet.cpp:781
ReserveDestination::operator=
ReserveDestination & operator=(const ReserveDestination &)=delete
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:245
CWallet::GetWalletTx
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:361
CWallet::DeactivateScriptPubKeyMan
void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
Definition: wallet.cpp:3246
CWallet::cs_wallet
RecursiveMutex cs_wallet
Main wallet lock.
Definition: wallet.h:347
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:703
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:834
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:101
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:1549
ReserveDestination::ReserveDestination
ReserveDestination(CWallet *pwallet, OutputType type)
Construct a ReserveDestination object. This does NOT reserve an address yet.
Definition: wallet.h:174
CWallet::GetScriptPubKeyMan
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition: wallet.cpp:3033
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:1438
CWallet::UpdateWalletTxFn
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
Definition: wallet.h:507
CWallet::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, int sighash_type=1, bool sign=true, bool bip32derivs=true, size_t *n_signed=nullptr) const
Fills out a PSBT with information from the wallet.
Definition: wallet.cpp:1855
WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:75
walletdb.h
WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:14
DEFAULT_DISCARD_FEE
static const CAmount DEFAULT_DISCARD_FEE
-discardfee default
Definition: wallet.h:71
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
CWallet::GetScriptPubKeyMans
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:3043
CWallet::NotifyTransactionChanged
boost::signals2::signal< void(const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:709
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
CWallet::m_default_change_type
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
Definition: wallet.h:626
CWallet::SyncMetaData
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:531
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:105
CWallet::GetNewChangeDestination
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, bilingual_str &error)
Definition: wallet.cpp:2158
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:1508
COIN
static constexpr CAmount COIN
The amount of satoshis in one BTC.
Definition: amount.h:15
CWallet::ChangeWalletPassphrase
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:423
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:344
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
DatabaseStatus::SUCCESS
@ SUCCESS
CWallet::LoadActiveScriptPubKeyMan
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:3226
CWallet::Close
void Close()
Close wallet database.
Definition: wallet.cpp:526
CWallet::ScanningProgress
double ScanningProgress() const
Definition: wallet.h:467
DEFAULT_FALLBACK_FEE
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:69
CWallet::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1488
COutput
Definition: spend.h:16
CWallet::SignTransaction
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Fetch the inputs and sign with SIGHASH_ALL.
Definition: wallet.cpp:1822
CWallet::FindAddressBookEntry
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2869
CRecipient
Definition: wallet.h:217
WalletBatch
Access to the wallet database.
Definition: walletdb.h:178
amount.h
DEFAULT_TX_CONFIRM_TARGET
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
Definition: wallet.h:93
CWallet::CanGetAddresses
bool CanGetAddresses(bool internal=false) const
Definition: wallet.cpp:1381
CWallet::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: wallet.h:718
WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_KEY_ORIGIN_METADATA
Definition: walletutil.h:44
CWallet::GetKeyBirthTimes
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2319
WalletContext
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:34
WalletRescanReserver::isReserved
bool isReserved() const
Definition: wallet.h:911
CWallet::LoadToWallet
bool LoadToWallet(const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:991
WALLET_FLAG_MAP
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:130
CWallet::HaveChain
bool HaveChain() const
Interface to assert chain access.
Definition: wallet.h:382
CWallet::GUARDED_BY
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
CAddressBookData::StringMap
std::map< std::string, std::string > StringMap
Definition: wallet.h:206
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:1086
CWallet::SetBroadcastTransactions
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition: wallet.h:729
CWallet::m_min_fee
CFeeRate m_min_fee
Override with -mintxfee.
Definition: wallet.h:599
CWallet::Unlock
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
Definition: wallet.cpp:2995
CWallet::TransactionChangeType
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
Definition: wallet.cpp:1918
ReserveDestination::ReturnDestination
void ReturnDestination()
Return reserved address.
Definition: wallet.cpp:2243
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:2234
DEFAULT_TRANSACTION_MINFEE
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
Definition: wallet.h:73
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:117
CWallet::GetOrCreateLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
Definition: wallet.cpp:3101
CWallet::GetLastBlockHash
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:836
CWallet::LoadMinVersion
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:475
WALLET_FLAG_DESCRIPTORS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition: walletutil.h:65
FlatSigningProvider
Definition: signingprovider.h:73
CWallet::chainStateFlushed
void chainStateFlushed(const CBlockLocator &loc) override
Definition: wallet.cpp:469
CWallet::SubmitTxMemoryPoolAndRelay
bool SubmitTxMemoryPoolAndRelay(const 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:1723
CWallet::m_chain
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition: wallet.h:304
CAddressBookData::GetLabel
const std::string & GetLabel() const
Definition: wallet.h:210
DEFAULT_DISABLE_WALLET
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:97
CWallet::m_unlock_mutex
Mutex m_unlock_mutex
Definition: wallet.h:481
CWallet::SyncTransaction
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true, bool rescanning_old_block=false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1202
CWallet::DisplayAddress
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
Definition: wallet.cpp:2252