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 <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/receive.h>
25 #include <wallet/scriptpubkeyman.h>
26 #include <wallet/spend.h>
27 #include <wallet/transaction.h>
28 #include <wallet/walletdb.h>
29 #include <wallet/walletutil.h>
30 
31 #include <algorithm>
32 #include <atomic>
33 #include <map>
34 #include <memory>
35 #include <optional>
36 #include <set>
37 #include <stdexcept>
38 #include <stdint.h>
39 #include <string>
40 #include <utility>
41 #include <vector>
42 
43 #include <boost/signals2/signal.hpp>
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(const std::shared_ptr<CWallet>& wallet);
57 bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
58 bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start);
59 std::vector<std::shared_ptr<CWallet>> GetWallets();
60 std::shared_ptr<CWallet> GetWallet(const std::string& name);
61 std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
62 std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
63 std::unique_ptr<interfaces::Handler> HandleLoadWallet(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;
83 constexpr CAmount HIGH_APS_FEE{COIN / 10000};
87 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
89 static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
91 static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
93 static const bool DEFAULT_WALLET_RBF = false;
94 static const bool DEFAULT_WALLETBROADCAST = true;
95 static const bool DEFAULT_DISABLE_WALLET = false;
99 constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
103 static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
104 
105 class CCoinControl;
106 class COutput;
107 class CScript;
108 class CWalletTx;
109 struct FeeCalculation;
110 enum class FeeEstimateMode;
111 class ReserveDestination;
112 
115 
116 static constexpr uint64_t KNOWN_WALLET_FLAGS =
124 
125 static constexpr uint64_t MUTABLE_WALLET_FLAGS =
127 
128 static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
129  {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
130  {"blank", WALLET_FLAG_BLANK_WALLET},
131  {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
132  {"last_hardened_xpub_cached", WALLET_FLAG_LAST_HARDENED_XPUB_CACHED},
133  {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
134  {"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
135  {"external_signer", WALLET_FLAG_EXTERNAL_SIGNER}
136 };
137 
138 extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;
139 
156 {
157 protected:
159  const CWallet* const pwallet;
164  int64_t nIndex{-1};
168  bool fInternal{false};
169 
170 public:
173  : pwallet(pwallet)
174  , type(type) { }
175 
176  ReserveDestination(const ReserveDestination&) = delete;
178 
181  {
183  }
184 
186  bool GetReservedDestination(CTxDestination& pubkey, bool internal, std::string& error);
188  void ReturnDestination();
190  void KeepDestination();
191 };
192 
195 {
196 private:
197  bool m_change{true};
198  std::string m_label;
199 public:
200  std::string purpose;
201 
202  CAddressBookData() : purpose("unknown") {}
203 
204  typedef std::map<std::string, std::string> StringMap;
206 
207  bool IsChange() const { return m_change; }
208  const std::string& GetLabel() const { return m_label; }
209  void SetLabel(const std::string& label) {
210  m_change = false;
211  m_label = label;
212  }
213 };
214 
216 {
220 };
221 
222 class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime
227 {
228 private:
230 
231  bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys = false);
232 
233  std::atomic<bool> fAbortRescan{false};
234  std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
235  std::atomic<int64_t> m_scanning_start{0};
236  std::atomic<double> m_scanning_progress{0};
237  friend class WalletRescanReserver;
238 
240  int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
241 
243  int64_t nNextResend = 0;
247  // Local time that the tip block was received. Used to schedule wallet rebroadcasts.
248  std::atomic<int64_t> m_best_block_time {0};
249 
255  typedef std::multimap<COutPoint, uint256> TxSpends;
256  TxSpends mapTxSpends GUARDED_BY(cs_wallet);
257  void AddToSpends(const COutPoint& outpoint, const uint256& wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
259 
274 
276  void MarkConflicted(const uint256& hashBlock, int conflicting_height, const uint256& hashTx);
277 
280 
281  void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
282 
283  /* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
284  * Should be called with non-zero block_hash and posInBlock if this is for a transaction that is included in a block. */
285  void SyncTransaction(const CTransactionRef& tx, CWalletTx::Confirmation confirm, bool update_tx = true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
286 
288  std::atomic<uint64_t> m_wallet_flags{0};
289 
290  bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
291 
293  void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
294 
296  void UnsetBlankWalletFlag(WalletBatch& batch) override;
297 
300 
302  std::string m_name;
303 
305  std::unique_ptr<WalletDatabase> const m_database;
306 
314  uint256 m_last_block_processed GUARDED_BY(cs_wallet);
315 
321  int m_last_block_processed_height GUARDED_BY(cs_wallet) = -1;
322 
323  std::map<OutputType, ScriptPubKeyMan*> m_external_spk_managers;
324  std::map<OutputType, ScriptPubKeyMan*> m_internal_spk_managers;
325 
326  // Indexed by a unique identifier produced by each ScriptPubKeyMan using
327  // ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal structure
328  std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
329 
330  bool CreateTransactionInternal(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, FeeCalculation& fee_calc_out, bool sign) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
331 
337  static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, bilingual_str& error, std::vector<bilingual_str>& warnings);
338 
339 public:
345 
346  WalletDatabase& GetDatabase() const override
347  {
348  assert(static_cast<bool>(m_database));
349  return *m_database;
350  }
351 
360  bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet,
362 
365  const std::string& GetName() const { return m_name; }
366 
367  typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
369  unsigned int nMasterKeyMaxID = 0;
370 
372  CWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database)
373  : m_chain(chain),
374  m_name(name),
375  m_database(std::move(database))
376  {
377  }
378 
380  {
381  // Should not have slots connected at this point.
382  assert(NotifyUnload.empty());
383  }
384 
385  bool IsCrypted() const;
386  bool IsLocked() const override;
387  bool Lock();
388 
390  bool HaveChain() const { return m_chain ? true : false; }
391 
394  std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
395 
396  typedef std::multimap<int64_t, CWalletTx*> TxItems;
398 
399  int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
401 
402  std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
403  const CAddressBookData* FindAddressBookEntry(const CTxDestination&, bool allow_change = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
404 
409  std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
410 
412  std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
413 
415  interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
416 
418  bool IsTrusted(const CWalletTx& wtx, std::set<uint256>& trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
419 
421  bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return IsFeatureSupported(nWalletVersion, wf); }
422 
426  void AvailableCoins(std::vector<COutput>& vCoins, const CCoinControl* coinControl = nullptr, const CAmount& nMinimumAmount = 1, const CAmount& nMaximumAmount = MAX_MONEY, const CAmount& nMinimumSumAmount = MAX_MONEY, const uint64_t nMaximumCount = 0) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
427 
431  std::map<CTxDestination, std::vector<COutput>> ListCoins() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
432 
437 
449  bool AttemptSelection(const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins,
450  std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CoinSelectionParams& coin_selection_params) const;
451 
452  bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
453 
454  // Whether this or any known UTXO with the same single key has been spent.
455  bool IsSpentKey(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
456  void SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
457 
458  std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, const CoinSelectionParams& coin_sel_params, const CoinEligibilityFilter& filter, bool positive_only) const;
459 
462 
463  bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
467  void ListLockedCoins(std::vector<COutPoint>& vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
468 
469  /*
470  * Rescan abort properties
471  */
472  void AbortRescan() { fAbortRescan = true; }
473  bool IsAbortingRescan() const { return fAbortRescan; }
474  bool IsScanning() const { return fScanningWallet; }
475  int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
476  double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
477 
480 
483 
484  bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; return true; }
485 
487  void LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
488 
490  int64_t nRelockTime GUARDED_BY(cs_wallet){0};
491 
492  // Used to prevent concurrent calls to walletpassphrase RPC.
494  bool Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys = false);
495  bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
496  bool EncryptWallet(const SecureString& strWalletPassphrase);
497 
498  void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
499  unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
500 
507 
508  void MarkDirty();
509 
516  using UpdateWalletTxFn = std::function<bool(CWalletTx& wtx, bool new_tx)>;
517 
518  CWalletTx* AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation& confirm, const UpdateWalletTxFn& update_wtx=nullptr, bool fFlushOnClose=true);
519  bool LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
520  void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override;
521  void blockConnected(const CBlock& block, int height) override;
522  void blockDisconnected(const CBlock& block, int height) override;
523  void updatedBlockTip() override;
524  int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
525 
526  struct ScanResult {
527  enum { SUCCESS, FAILURE, USER_ABORT } status = SUCCESS;
528 
533  std::optional<int> last_scanned_height;
534 
540  };
541  ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate);
542  void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override;
545  struct Balance {
546  CAmount m_mine_trusted{0};
547  CAmount m_mine_untrusted_pending{0};
548  CAmount m_mine_immature{0};
549  CAmount m_watchonly_trusted{0};
550  CAmount m_watchonly_untrusted_pending{0};
551  CAmount m_watchonly_immature{0};
552  };
553  Balance GetBalance(int min_depth = 0, bool avoid_reuse = true) const;
554  CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
555 
556  OutputType TransactionChangeType(const std::optional<OutputType>& change_type, const std::vector<CRecipient>& vecSend) const;
557 
562  bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl);
566  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, std::string>& input_errors) const;
567  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const;
568 
583  bool& complete,
584  int sighash_type = 1 /* SIGHASH_ALL */,
585  bool sign = true,
586  bool bip32derivs = true,
587  size_t* n_signed = nullptr) const;
588 
594  bool CreateTransaction(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, FeeCalculation& fee_calc_out, bool sign = true);
604  void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm);
605 
606  bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, bool use_max_sig = false) const
607  {
608  std::vector<CTxOut> v_txouts(txouts.size());
609  std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
610  return DummySignTx(txNew, v_txouts, use_max_sig);
611  }
612  bool DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut> &txouts, bool use_max_sig = false) const;
613  bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig = false) const;
614 
615  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
616  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
617  bool ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
618  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);
619 
626  bool m_allow_fallback_fee{true};
628 
634 
638 
648  std::optional<OutputType> m_default_change_type{};
651 
653  bool TopUpKeyPool(unsigned int kpSize = 0);
654 
655  int64_t GetOldestKeyPoolTime() const;
656 
658  std::map<CTxDestination, CAmount> GetAddressBalances() const;
659 
660  std::set<CTxDestination> GetLabelAddresses(const std::string& label) const;
661 
666  void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
667 
668  bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error);
669  bool GetNewChangeDestination(const OutputType type, CTxDestination& dest, std::string& error);
670 
678  CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
680  CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
681  bool IsChange(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
682  bool IsChange(const CScript& script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
684  bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
686  bool IsFromMe(const CTransaction& tx) const;
687  CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
689  bool IsAllFromMe(const CTransaction& tx, const isminefilter& filter) const;
690  CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
691  CAmount GetChange(const CTransaction& tx) const;
692  void chainStateFlushed(const CBlockLocator& loc) override;
693 
695  DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
696 
697  bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
698 
699  bool DelAddressBook(const CTxDestination& address);
700 
702  bool SetAddressUsed(WalletBatch& batch, const CTxDestination& dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
703 
704  std::vector<std::string> GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
705  bool SetAddressReceiveRequest(WalletBatch& batch, const CTxDestination& dest, const std::string& id, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
706 
707  unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
708 
710  void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr) override;
711 
713  int GetVersion() const { LOCK(cs_wallet); return nWalletVersion; }
714 
716  std::set<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
717 
719  bool HasWalletSpend(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
720 
722  void Flush();
723 
725  void Close();
726 
728  boost::signals2::signal<void ()> NotifyUnload;
729 
734  boost::signals2::signal<void(const CTxDestination& address,
735  const std::string& label, bool isMine,
736  const std::string& purpose, ChangeType status)>
738 
743  boost::signals2::signal<void(const uint256& hashTx, ChangeType status)> NotifyTransactionChanged;
744 
746  boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
747 
749  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
750 
752  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
753 
758  boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
759 
763  void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
764 
766  bool TransactionCanBeAbandoned(const uint256& hashTx) const;
767 
768  /* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
769  bool AbandonTransaction(const uint256& hashTx);
770 
772  bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
773 
774  /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
775  static std::shared_ptr<CWallet> Create(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings);
776 
781  void postInitProcess();
782 
783  bool BackupWallet(const std::string& strDest) const;
784 
785  /* Returns true if HD is enabled */
786  bool IsHDEnabled() const;
787 
788  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
789  bool CanGetAddresses(bool internal = false) const;
790 
797  void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(::cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_wallet);
798 
800  void SetWalletFlag(uint64_t flags);
801 
803  void UnsetWalletFlag(uint64_t flag);
804 
806  bool IsWalletFlagSet(uint64_t flag) const override;
807 
810  bool AddWalletFlags(uint64_t flags);
812  bool LoadWalletFlags(uint64_t flags);
813 
815  bool IsLegacy() const;
816 
818  const std::string GetDisplayName() const override {
819  std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
820  return strprintf("[%s]", wallet_name);
821  };
822 
824  template<typename... Params>
825  void WalletLogPrintf(std::string fmt, Params... parameters) const {
826  LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
827  };
828 
830  bool UpgradeWallet(int version, bilingual_str& error);
831 
833  std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
834 
836  std::set<ScriptPubKeyMan*> GetAllScriptPubKeyMans() const;
837 
839  ScriptPubKeyMan* GetScriptPubKeyMan(const OutputType& type, bool internal) const;
840 
842  ScriptPubKeyMan* GetScriptPubKeyMan(const CScript& script) const;
844  ScriptPubKeyMan* GetScriptPubKeyMan(const uint256& id) const;
845 
847  std::set<ScriptPubKeyMan*> GetScriptPubKeyMans(const CScript& script, SignatureData& sigdata) const;
848 
850  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const;
851  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script, SignatureData& sigdata) const;
852 
856 
859 
860  const CKeyingMaterial& GetEncryptionKey() const override;
861  bool HasEncryptionKeys() const override;
862 
865  {
867  assert(m_last_block_processed_height >= 0);
868  return m_last_block_processed_height;
869  };
871  {
873  assert(m_last_block_processed_height >= 0);
874  return m_last_block_processed;
875  }
878  {
880  m_last_block_processed_height = block_height;
881  m_last_block_processed = block_hash;
882  };
883 
886 
889 
894  void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
895 
900  void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
901 
906  void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal);
907 
910 
913 
915  ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal);
916 };
917 
922 void MaybeResendWalletTxs();
923 
926 {
927 private:
930 public:
932 
933  bool reserve()
934  {
936  if (m_wallet.fScanningWallet.exchange(true)) {
937  return false;
938  }
939  m_wallet.m_scanning_start = GetTimeMillis();
940  m_wallet.m_scanning_progress = 0;
941  m_could_reserve = true;
942  return true;
943  }
944 
945  bool isReserved() const
946  {
947  return (m_could_reserve && m_wallet.fScanningWallet);
948  }
949 
951  {
952  if (m_could_reserve) {
953  m_wallet.fScanningWallet = false;
954  }
955  }
956 };
957 
958 struct TxSize {
959  int64_t vsize{-1};
960  int64_t weight{-1};
961 };
962 
968 TxSize CalculateMaximumSignedTxSize(const CTransaction& tx, const CWallet* wallet, const std::vector<CTxOut>& txouts, bool use_max_sig = false);
969 
971 bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
972 
974 bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
975 
976 #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:72
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:539
CWallet::GetKeyPoolSize
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2110
DatabaseOptions
Definition: db.h:203
CTxIn
An input of a transaction.
Definition: transaction.h:65
interfaces
Definition: dummywallet.cpp:10
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:825
CWallet::UpgradeDescriptorCache
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade DescriptorCaches.
Definition: wallet.cpp:377
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:637
CWallet::ComputeTimeSmart
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
Definition: wallet.cpp:2378
CWallet::ConnectScriptPubKeyManNotifiers
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition: wallet.cpp:3082
crypter.h
ReserveDestination::fInternal
bool fInternal
Whether this is from the internal (change output) keypool.
Definition: wallet.h:168
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:372
CWallet::GetActiveScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition: wallet.cpp:2961
feerate.h
CRecipient::fSubtractFeeFromAmount
bool fSubtractFeeFromAmount
Definition: wallet.h:219
CWallet::UnlockCoin
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2265
CWallet::nMasterKeyMaxID
unsigned int nMasterKeyMaxID
Definition: wallet.h:369
CWallet::m_signal_rbf
bool m_signal_rbf
Definition: wallet.h:625
CAddressBookData::IsChange
bool IsChange() const
Definition: wallet.h:207
CWallet::m_external_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Definition: wallet.h:323
CWallet::GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: receive.cpp:380
OutputType
OutputType
Definition: outputtype.h:17
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:1140
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:240
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:633
DatabaseStatus
DatabaseStatus
Definition: db.h:212
CWallet::ResendWalletTransactions
void ResendWalletTransactions()
Definition: wallet.cpp:1760
ReserveDestination::~ReserveDestination
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool.
Definition: wallet.h:180
CWallet::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
Definition: wallet.cpp:3024
CWallet::MasterKeyMap
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition: wallet.h:367
OutputGroup
A group of UTXOs paid to the same output script.
Definition: coinselection.h:124
WalletRescanReserver::WalletRescanReserver
WalletRescanReserver(CWallet &w)
Definition: wallet.h:931
CWallet::blockDisconnected
void blockDisconnected(const CBlock &block, int height) override
Definition: wallet.cpp:1263
isminefilter
uint8_t isminefilter
Definition: wallet.h:36
CWallet::m_confirm_target
unsigned int m_confirm_target
Definition: wallet.h:621
CWallet::IsAbortingRescan
bool IsAbortingRescan() const
Definition: wallet.h:473
CWallet::IsFromMe
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
Definition: wallet.cpp:1343
CWallet::ReacceptWalletTransactions
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1683
CWallet::m_scanning_start
std::atomic< int64_t > m_scanning_start
Definition: wallet.h:235
flags
int flags
Definition: bitcoin-tx.cpp:512
CWallet::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const
Definition: wallet.cpp:2164
WALLET_FLAG_CAVEATS
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:49
CWallet::AddWalletDescriptor
ScriptPubKeyMan * AddWalletDescriptor(WalletDescriptor &desc, const FlatSigningProvider &signing_provider, const std::string &label, bool internal)
Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type.
Definition: wallet.cpp:3235
CWallet::m_wallet_flags
std::atomic< uint64_t > m_wallet_flags
WalletFlags set on this wallet.
Definition: wallet.h:288
CWallet::GetLastBlockHeight
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
Definition: wallet.h:864
CWallet::AvailableCoins
void AvailableCoins(std::vector< COutput > &vCoins, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
populate vCoins with vector of available COutputs.
Definition: spend.cpp:67
CWallet::IsWalletFlagSet
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
Definition: wallet.cpp:1410
CWallet::CanSupportFeature
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
Definition: wallet.h:421
string.h
CWallet::LoadDescriptorScriptPubKeyMan
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition: wallet.cpp:3090
vCoins
static std::vector< COutput > vCoins
Definition: coinselector_tests.cpp:29
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:89
GetWallet
std::shared_ptr< CWallet > GetWallet(const std::string &name)
Definition: wallet.cpp:141
FEATURE_BASE
@ FEATURE_BASE
Definition: walletutil.h:16
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:81
outputtype.h
CWallet::ScanResult::last_scanned_height
std::optional< int > last_scanned_height
Definition: wallet.h:533
CWallet::ScanResult::last_scanned_block
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition: wallet.h:532
CKeyingMaterial
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:61
CCoinControl
Coin Control Features.
Definition: coincontrol.h:23
CWallet::GetAddressBalances
std::map< CTxDestination, CAmount > GetAddressBalances() const
Definition: receive.cpp:342
validationinterface.h
MakeWalletDatabase
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Definition: wallet.cpp:2481
CWallet::GetBalance
Balance GetBalance(int min_depth=0, bool avoid_reuse=true) const
Definition: receive.cpp:313
handler.h
CWallet::GetEncryptionKey
const CKeyingMaterial & GetEncryptionKey() const override
Definition: wallet.cpp:3072
CWallet::chain
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:415
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:166
CWallet::m_scanning_progress
std::atomic< double > m_scanning_progress
Definition: wallet.h:236
CWallet::IsCrypted
bool IsCrypted() const
Definition: wallet.cpp:2918
CWallet::NotifyUnload
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:728
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:640
LoadWallet
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:237
ReserveDestination::pwallet
const CWallet *const pwallet
The wallet to reserve from.
Definition: wallet.h:159
CWallet::IsSpentKey
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:843
CreateWallet
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:250
CWallet::nAccountingEntryNumber
uint64_t nAccountingEntryNumber
Definition: wallet.h:400
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:1580
CWallet::AbortRescan
void AbortRescan()
Definition: wallet.h:472
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:789
AnnotatedMixin< std::recursive_mutex >
CWallet::ListCoins
std::map< CTxDestination, std::vector< COutput > > ListCoins() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Return list of available coins and locked coins grouped by non-change output address.
Definition: spend.cpp:228
CWallet::SelectCoins
bool SelectCoins(const std::vector< COutput > &vAvailableCoins, const CAmount &nTargetValue, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CCoinControl &coin_control, CoinSelectionParams &coin_selection_params) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Select a set of coins such that nValueRet >= nTargetValue and at least all coins from coin_control ar...
Definition: spend.cpp:373
CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:746
ReserveDestination::nIndex
int64_t nIndex
The index of the address's key in the keypool.
Definition: wallet.h:164
wallet
Definition: interfaces.cpp:47
WalletDatabase
An instance of this class represents one database.
Definition: db.h:103
WalletRescanReserver::reserve
bool reserve()
Definition: wallet.h:933
CWallet::AddToWallet
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
Definition: wallet.cpp:878
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:761
ReserveDestination
A wrapper to reserve an address from a wallet.
Definition: wallet.h:155
LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:261
CoinEligibilityFilter
Parameters for filtering which OutputGroups we may use in coin selection.
Definition: coinselection.h:104
CWallet::CreateTransaction
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
Definition: spend.cpp:873
CWallet::blockConnected
void blockConnected(const CBlock &block, int height) override
Definition: wallet.cpp:1250
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:2417
CWallet::AddToSpends
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:585
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
RemoveWallet
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:109
CWallet::GetNewChangeDestination
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
Definition: wallet.cpp:2150
CWallet::IsAddressUsed
bool IsAddressUsed(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2438
CWallet::UnsetBlankWalletFlag
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
Definition: wallet.cpp:1405
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:101
CWallet::NotifyStatusChanged
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: wallet.h:758
CWallet::IsChange
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: receive.cpp:86
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:1895
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
AssertLockHeld
AssertLockHeld(pool.cs)
scriptpubkeyman.h
CWallet::Balance
Definition: wallet.h:545
tinyformat.h
CWallet::ZapSelectTx
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2007
CWallet::GetAvailableBalance
CAmount GetAvailableBalance(const CCoinControl *coinControl=nullptr) const
Definition: spend.cpp:195
CWallet::GetVersion
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition: wallet.h:713
CWallet::SetAddressBook
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:2058
WalletRescanReserver::m_wallet
CWallet & m_wallet
Definition: wallet.h:928
LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: wallet.h:45
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:818
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:506
DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:519
CWallet::MarkDirty
void MarkDirty()
Definition: wallet.cpp:780
TxSize
Definition: wallet.h:958
CWallet::IsLockedCoin
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2277
CWallet::DelAddressBook
bool DelAddressBook(const CTxDestination &address)
Definition: wallet.cpp:2064
strencodings.h
CalculateMaximumSignedTxSize
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig=false) EXCLUSIVE_LOCKS_REQUIRED(wallet -> cs_wallet)
Calculate the size of the transaction assuming all signatures are max size Use DummySignatureCreator,...
Definition: spend.cpp:52
CWallet::TransactionCanBeAbandoned
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
Definition: wallet.cpp:1069
CWallet::LoadWallet
DBErrors LoadWallet()
Definition: wallet.cpp:1981
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:89
CWallet::IsLocked
bool IsLocked() const override
Definition: wallet.cpp:2923
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:60
CWallet::Flush
void Flush()
Flush wallet (bitdb flush)
Definition: wallet.cpp:513
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:650
CWallet::UpgradeKeyMetadata
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: wallet.cpp:362
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:218
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
CWallet::ScanningDuration
int64_t ScanningDuration() const
Definition: wallet.h:475
CWallet::LoadWalletFlags
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
Definition: wallet.cpp:1415
SignatureData
Definition: sign.h:64
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:1941
CAddressBookData::m_change
bool m_change
Definition: wallet.h:197
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:248
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:1506
CWallet::fScanningWallet
std::atomic< bool > fScanningWallet
Definition: wallet.h:234
CWallet::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1486
CWallet::m_name
std::string m_name
Wallet name: relative directory name or "" for default wallet.
Definition: wallet.h:302
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:2433
message.h
CWallet::UnsetWalletFlag
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
Definition: wallet.cpp:1391
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:255
CWallet::m_default_address_type
OutputType m_default_address_type
Definition: wallet.h:641
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:624
WALLET_INCREMENTAL_RELAY_FEE
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
Definition: wallet.h:85
CWallet::updatedBlockTip
void updatedBlockTip() override
Definition: wallet.cpp:1278
CWallet::SetupDescriptorScriptPubKeyMans
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition: wallet.cpp:3101
CWallet::UnsetWalletFlagWithDB
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
Definition: wallet.cpp:1397
DEFAULT_TRANSACTION_MAXFEE
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition: wallet.h:97
FeeEstimateMode
FeeEstimateMode
Definition: feerate.h:18
HIGH_APS_FEE
constexpr CAmount HIGH_APS_FEE
discourage APS fee higher than this amount
Definition: wallet.h:83
WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:41
CWallet::FundTransaction
bool FundTransaction(CMutableTransaction &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl)
Insert additional inputs into the transaction by calling CreateTransaction();.
Definition: spend.cpp:920
CAddressBookData
Address book data.
Definition: wallet.h:194
CWallet::nNextResend
int64_t nNextResend
The next scheduled rebroadcast of wallet transactions.
Definition: wallet.h:243
DEFAULT_WALLET_RBF
static const bool DEFAULT_WALLET_RBF
-walletrbf default
Definition: wallet.h:93
MUTABLE_WALLET_FLAGS
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:125
CoinSelectionParams
Parameters for one iteration of Coin Selection.
Definition: coinselection.h:61
CWallet::wtxOrdered
TxItems wtxOrdered
Definition: wallet.h:397
CWallet::DummySignInput
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
Definition: wallet.cpp:1441
CWallet::m_chain_notifications_handler
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition: wallet.h:412
CAddressBookData::SetLabel
void SetLabel(const std::string &label)
Definition: wallet.h:209
LogPrintf
#define LogPrintf(...)
Definition: logging.h:184
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:925
CWallet::IsTrusted
bool IsTrusted(const CWalletTx &wtx, std::set< uint256 > &trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: receive.cpp:274
CWallet::AddActiveScriptPubKeyMan
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:3168
CWallet::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:749
CWallet::SetMinVersion
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
Definition: wallet.cpp:467
CWallet::IsHDEnabled
bool IsHDEnabled() const
Definition: wallet.cpp:1360
CWallet::~CWallet
~CWallet()
Definition: wallet.h:379
WalletRescanReserver::m_could_reserve
bool m_could_reserve
Definition: wallet.h:929
CWallet::fBroadcastTransactions
bool fBroadcastTransactions
Whether this wallet will submit newly created transactions to the node's mempool and prompt rebroadca...
Definition: wallet.h:246
CWallet::GetDatabase
WalletDatabase & GetDatabase() const override
Definition: wallet.h:346
CWallet::transactionAddedToMempool
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Definition: wallet.cpp:1203
CWallet::SyncTransaction
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1192
CWallet::GetName
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:365
CWallet::mapMasterKeys
MasterKeyMap mapMasterKeys
Definition: wallet.h:368
CWallet::ReorderTransactions
DBErrors ReorderTransactions()
Definition: wallet.cpp:711
CWallet::fAbortRescan
std::atomic< bool > fAbortRescan
Definition: wallet.h:233
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:877
CWallet::UnlockAllCoins
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2271
CWallet::FindNonChangeParentOutput
const CTxOut & FindNonChangeParentOutput(const CTransaction &tx, int output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Find non-change parent output.
Definition: spend.cpp:210
uint256
256-bit opaque blob.
Definition: uint256.h:124
CWallet::GroupOutputs
std::vector< OutputGroup > GroupOutputs(const std::vector< COutput > &outputs, const CoinSelectionParams &coin_sel_params, const CoinEligibilityFilter &filter, bool positive_only) const
Definition: spend.cpp:269
CWallet::ScanResult
Definition: wallet.h:526
CWallet::DummySignTx
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
Definition: wallet.h:606
CWallet::AbandonTransaction
bool AbandonTransaction(const uint256 &hashTx)
Definition: wallet.cpp:1086
CWalletTx::Confirmation
Confirmation includes tx status and a triplet of {block height/block hash/tx index in block} at which...
Definition: transaction.h:186
CWallet::UpgradeWallet
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
Definition: wallet.cpp:2829
CWallet::GetDescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition: wallet.cpp:3222
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
coin_selection_params
CoinSelectionParams coin_selection_params(0, 0, CFeeRate(0), CFeeRate(0), CFeeRate(0), 0, false)
CWallet::GetLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition: wallet.cpp:3040
CWallet::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2093
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:2174
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:2285
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:1296
CWallet::TxItems
std::multimap< int64_t, CWalletTx * > TxItems
Definition: wallet.h:396
IsFeatureSupported
bool IsFeatureSupported(int wallet_version, int feature_version)
Definition: walletutil.cpp:32
CAddressBookData::CAddressBookData
CAddressBookData()
Definition: wallet.h:202
CInputCoin
A UTXO under consideration for use in funding a new transaction.
Definition: coinselection.h:19
CWallet::SetupLegacyScriptPubKeyMan
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition: wallet.cpp:3058
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:483
CWallet::Create
static std::shared_ptr< CWallet > Create(interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:2505
CWallet::IsAllFromMe
bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const
Returns whether all of the inputs match the filter.
Definition: receive.cpp:23
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:609
CRecipient::scriptPubKey
CScript scriptPubKey
Definition: wallet.h:217
WalletRescanReserver::~WalletRescanReserver
~WalletRescanReserver()
Definition: wallet.h:950
transaction.h
CWallet::AttachChain
static bool AttachChain(const std::shared_ptr< CWallet > &wallet, interfaces::Chain &chain, bilingual_str &error, std::vector< bilingual_str > &warnings)
Catch wallet up to current chain, scanning new blocks, updating the best block locator and m_last_blo...
Definition: wallet.cpp:2733
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:324
PKHash
Definition: standard.h:79
UnloadWallet
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:181
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:61
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
CWallet::GetChange
CAmount GetChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: receive.cpp:91
ReserveDestination::type
const OutputType type
Definition: wallet.h:162
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:305
CAddressBookData::purpose
std::string purpose
Definition: wallet.h:200
CWallet::transactionRemovedFromMempool
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Definition: wallet.cpp:1213
DEFAULT_SPEND_ZEROCONF_CHANGE
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:87
LOCKS_EXCLUDED
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
MaybeResendWalletTxs
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
Definition: wallet.cpp:1798
ScriptPubKeyMan
Definition: scriptpubkeyman.h:169
CWallet::SetAddressBookWithDB
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
Definition: wallet.cpp:2038
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:115
CWallet::GetLabelAddresses
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const
Definition: wallet.cpp:2188
CWallet::TopUpKeyPool
bool TopUpKeyPool(unsigned int kpSize=0)
Definition: wallet.cpp:2121
CWallet::IsScanning
bool IsScanning() const
Definition: wallet.h:474
CWallet::postInitProcess
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
Definition: wallet.cpp:2862
CWallet::AddToWalletIfInvolvingMe
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
Definition: wallet.cpp:1025
CAddressBookData::destdata
StringMap destdata
Definition: wallet.h:205
KNOWN_WALLET_FLAGS
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition: wallet.h:116
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:566
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
CWallet::BackupWallet
bool BackupWallet(const std::string &strDest) const
Definition: wallet.cpp:2874
CWallet::LockCoin
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2259
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:620
LOCK
#define LOCK(cs)
Definition: sync.h:232
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:395
interfaces::Chain::Notifications
Chain notifications.
Definition: chain.h:233
DEFAULT_ADDRESS_TYPE
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
Definition: wallet.h:114
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:2467
CWallet::Lock
bool Lock()
Definition: wallet.cpp:2932
DEFAULT_PAY_TX_FEE
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:67
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:226
AddWallet
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:97
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:68
CAddressBookData::m_label
std::string m_label
Definition: wallet.h:198
ReserveDestination::m_spk_man
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called.
Definition: wallet.h:161
m_wallet
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:496
CWallet::IsMine
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1318
CWallet::m_spk_managers
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
Definition: wallet.h:328
CWallet::GetAllScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
Definition: wallet.cpp:2975
CWallet::GetAddressReceiveRequests
std::vector< std::string > GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2453
MAX_MONEY
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition: amount.h:25
CWallet::m_allow_fallback_fee
bool m_allow_fallback_fee
will be false if -fallbackfee=0
Definition: wallet.h:626
DEFAULT_WALLETBROADCAST
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:94
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:535
CWallet::HasEncryptionKeys
bool HasEncryptionKeys() const override
Definition: wallet.cpp:3077
GetWallets
std::vector< std::shared_ptr< CWallet > > GetWallets()
Definition: wallet.cpp:135
CWallet::IsLegacy
bool IsLegacy() const
Determine if we are a legacy wallet.
Definition: wallet.cpp:3213
CWallet::IncOrderPosNext
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
Definition: wallet.cpp:768
ReserveDestination::operator=
ReserveDestination & operator=(const ReserveDestination &)=delete
CWallet::GetWalletTx
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:353
CWallet::DeactivateScriptPubKeyMan
void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
Definition: wallet.cpp:3196
CWallet::cs_wallet
RecursiveMutex cs_wallet
Main wallet lock.
Definition: wallet.h:344
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:737
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:824
ReserveDestination::GetReservedDestination
bool GetReservedDestination(CTxDestination &pubkey, bool internal, std::string &error)
Reserve an address.
Definition: wallet.cpp:2203
COIN
static const CAmount COIN
Definition: amount.h:14
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:99
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:1537
ReserveDestination::ReserveDestination
ReserveDestination(CWallet *pwallet, OutputType type)
Construct a ReserveDestination object. This does NOT reserve an address yet.
Definition: wallet.h:172
CWallet::GetScriptPubKeyMan
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition: wallet.cpp:2984
CWallet::CreateTransactionInternal
bool CreateTransactionInternal(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: spend.cpp:571
receive.h
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:1427
CWallet::UpdateWalletTxFn
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
Definition: wallet.h:516
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:1844
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:2994
CWallet::NotifyTransactionChanged
boost::signals2::signal< void(const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:743
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:648
CWallet::SyncMetaData
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:523
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:103
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:1496
CWallet::ChangeWalletPassphrase
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:415
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:3177
CWallet::Close
void Close()
Close wallet database.
Definition: wallet.cpp:518
CWallet::ScanningProgress
double ScanningProgress() const
Definition: wallet.h:476
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:1476
COutput
Definition: spend.h:12
CWallet::SignTransaction
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Fetch the inputs and sign with SIGHASH_ALL.
Definition: wallet.cpp:1811
CWallet::FindAddressBookEntry
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2819
CRecipient
Definition: wallet.h:215
WalletBatch
Access to the wallet database.
Definition: walletdb.h:176
amount.h
DEFAULT_TX_CONFIRM_TARGET
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
Definition: wallet.h:91
CWallet::CanGetAddresses
bool CanGetAddresses(bool internal=false) const
Definition: wallet.cpp:1370
CWallet::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: wallet.h:752
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:2297
WalletRescanReserver::isReserved
bool isReserved() const
Definition: wallet.h:945
CWallet::GetNewDestination
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
Definition: wallet.cpp:2131
spend.h
CWallet::LoadToWallet
bool LoadToWallet(const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:981
WALLET_FLAG_MAP
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:128
CWallet::HaveChain
bool HaveChain() const
Interface to assert chain access.
Definition: wallet.h:390
CWallet::GUARDED_BY
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
CAddressBookData::StringMap
std::map< std::string, std::string > StringMap
Definition: wallet.h:204
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:1076
CWallet::SetBroadcastTransactions
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition: wallet.h:763
CWallet::m_min_fee
CFeeRate m_min_fee
Override with -mintxfee.
Definition: wallet.h:627
CWallet::Unlock
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
Definition: wallet.cpp:2946
CWallet::TransactionChangeType
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
Definition: wallet.cpp:1907
CWallet::GetCredit
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
Definition: receive.cpp:44
ReserveDestination::ReturnDestination
void ReturnDestination()
Return reserved address.
Definition: wallet.cpp:2235
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:2226
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:3052
CWallet::GetLastBlockHash
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:870
CWallet::LoadMinVersion
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:484
WALLET_FLAG_DESCRIPTORS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition: walletutil.h:65
FlatSigningProvider
Definition: signingprovider.h:49
CWallet::chainStateFlushed
void chainStateFlushed(const CBlockLocator &loc) override
Definition: wallet.cpp:461
CWallet::m_chain
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition: wallet.h:299
CAddressBookData::GetLabel
const std::string & GetLabel() const
Definition: wallet.h:208
CWallet::AttemptSelection
bool AttemptSelection(const CAmount &nTargetValue, const CoinEligibilityFilter &eligibility_filter, std::vector< COutput > coins, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CoinSelectionParams &coin_selection_params) const
Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is st...
Definition: spend.cpp:355
DEFAULT_DISABLE_WALLET
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:95
HandleLoadWallet
std::unique_ptr< interfaces::Handler > HandleLoadWallet(LoadWalletFn load_wallet)
Definition: wallet.cpp:150
CWallet::m_unlock_mutex
Mutex m_unlock_mutex
Definition: wallet.h:490
CWallet::DisplayAddress
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
Definition: wallet.cpp:2244