Bitcoin Core  0.18.99
P2P Digital Currency
wallet.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 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 <script/sign.h>
15 #include <streams.h>
16 #include <tinyformat.h>
17 #include <ui_interface.h>
18 #include <util/strencodings.h>
19 #include <util/system.h>
20 #include <validationinterface.h>
21 #include <wallet/coinselection.h>
22 #include <wallet/crypter.h>
23 #include <wallet/ismine.h>
24 #include <wallet/walletdb.h>
25 #include <wallet/walletutil.h>
26 
27 #include <algorithm>
28 #include <atomic>
29 #include <map>
30 #include <memory>
31 #include <set>
32 #include <stdexcept>
33 #include <stdint.h>
34 #include <string>
35 #include <utility>
36 #include <vector>
37 
38 #include <boost/signals2/signal.hpp>
39 
45 void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
46 
47 bool AddWallet(const std::shared_ptr<CWallet>& wallet);
48 bool RemoveWallet(const std::shared_ptr<CWallet>& wallet);
49 bool HasWallets();
50 std::vector<std::shared_ptr<CWallet>> GetWallets();
51 std::shared_ptr<CWallet> GetWallet(const std::string& name);
52 std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const WalletLocation& location, std::string& error, std::string& warning);
53 
58 };
59 
60 std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::string& name, std::string& error, std::string& warning, WalletCreationStatus& status, const SecureString& passphrase, uint64_t wallet_creation_flags);
61 
63 static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
67 static const CAmount DEFAULT_FALLBACK_FEE = 20000;
69 static const CAmount DEFAULT_DISCARD_FEE = 10000;
71 static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
75 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
77 static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
79 static const bool DEFAULT_AVOIDPARTIALSPENDS = false;
81 static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
83 static const bool DEFAULT_WALLET_RBF = false;
84 static const bool DEFAULT_WALLETBROADCAST = true;
85 static const bool DEFAULT_DISABLE_WALLET = false;
89 constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
92 
94 static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
95 
96 class CCoinControl;
97 class COutput;
98 class CScript;
99 class CWalletTx;
100 struct FeeCalculation;
101 enum class FeeEstimateMode;
102 class ReserveDestination;
103 
106 {
107  FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getwalletinfo's clientversion output)
108 
109  FEATURE_WALLETCRYPT = 40000, // wallet encryption
110  FEATURE_COMPRPUBKEY = 60000, // compressed public keys
111 
112  FEATURE_HD = 130000, // Hierarchical key derivation after BIP32 (HD Wallet)
113 
114  FEATURE_HD_SPLIT = 139900, // Wallet with HD chain split (change outputs will use m/0'/1'/k)
115 
116  FEATURE_NO_DEFAULT_KEY = 159900, // Wallet without a default key written
117 
118  FEATURE_PRE_SPLIT_KEYPOOL = 169900, // Upgraded to HD SPLIT and can have a pre-split keypool
119 
121 };
122 
125 
128 
129 enum WalletFlags : uint64_t {
130  // wallet flags in the upper section (> 1 << 31) will lead to not opening the wallet if flag is unknown
131  // unknown wallet flags in the lower section <= (1 << 31) will be tolerated
132 
133  // will categorize coins as clean (not reused) and dirty (reused), and handle
134  // them with privacy considerations in mind
135  WALLET_FLAG_AVOID_REUSE = (1ULL << 0),
136 
137  // Indicates that the metadata has already been upgraded to contain key origins
139 
140  // will enforce the rule that the wallet can't contain any private keys (only watch-only/pubkeys)
142 
153  WALLET_FLAG_BLANK_WALLET = (1ULL << 33),
154 };
155 
156 static constexpr uint64_t KNOWN_WALLET_FLAGS =
161 
162 static constexpr uint64_t MUTABLE_WALLET_FLAGS =
164 
165 static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
166  {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
167  {"blank", WALLET_FLAG_BLANK_WALLET},
168  {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
169  {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
170 };
171 
172 extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;
173 
218 class CKeyPool
219 {
220 public:
222  int64_t nTime;
226  bool fInternal;
229 
230  CKeyPool();
231  CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn);
232 
234 
235  template <typename Stream, typename Operation>
236  inline void SerializationOp(Stream& s, Operation ser_action) {
237  int nVersion = s.GetVersion();
238  if (!(s.GetType() & SER_GETHASH))
239  READWRITE(nVersion);
240  READWRITE(nTime);
241  READWRITE(vchPubKey);
242  if (ser_action.ForRead()) {
243  try {
244  READWRITE(fInternal);
245  }
246  catch (std::ios_base::failure&) {
247  /* flag as external address if we can't read the internal boolean
248  (this will be the case for any wallet before the HD chain split version) */
249  fInternal = false;
250  }
251  try {
252  READWRITE(m_pre_split);
253  }
254  catch (std::ios_base::failure&) {
255  /* flag as postsplit address if we can't read the m_pre_split boolean
256  (this will be the case for any wallet that upgrades to HD chain split)*/
257  m_pre_split = false;
258  }
259  }
260  else {
261  READWRITE(fInternal);
262  READWRITE(m_pre_split);
263  }
264  }
265 };
266 
283 {
284 protected:
288  int64_t nIndex{-1};
294  bool fInternal{false};
295 
296 public:
298  explicit ReserveDestination(CWallet* pwalletIn)
299  {
300  pwallet = pwalletIn;
301  }
302 
303  ReserveDestination(const ReserveDestination&) = delete;
304  ReserveDestination& operator=(const ReserveDestination&) = delete;
305 
308  {
309  ReturnDestination();
310  }
311 
313  bool GetReservedDestination(const OutputType type, CTxDestination& pubkey, bool internal);
315  void ReturnDestination();
317  void KeepDestination();
318 };
319 
322 {
323 public:
324  std::string name;
325  std::string purpose;
326 
327  CAddressBookData() : purpose("unknown") {}
328 
329  typedef std::map<std::string, std::string> StringMap;
330  StringMap destdata;
331 };
332 
334 {
338 };
339 
340 typedef std::map<std::string, std::string> mapValue_t;
341 
342 
343 static inline void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue)
344 {
345  if (!mapValue.count("n"))
346  {
347  nOrderPos = -1; // TODO: calculate elsewhere
348  return;
349  }
350  nOrderPos = atoi64(mapValue["n"].c_str());
351 }
352 
353 
354 static inline void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
355 {
356  if (nOrderPos == -1)
357  return;
358  mapValue["n"] = i64tostr(nOrderPos);
359 }
360 
362 {
365  int vout;
366 };
367 
370 {
371 private:
373  static const uint256 ABANDON_HASH;
374 
375 public:
378 
379  /* An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest
380  * block in the chain we know this or any in-wallet dependency conflicts
381  * with. Older clients interpret nIndex == -1 as unconfirmed for backward
382  * compatibility.
383  */
384  int nIndex;
385 
387  {
388  SetTx(MakeTransactionRef());
389  Init();
390  }
391 
393  {
394  SetTx(std::move(arg));
395  Init();
396  }
397 
398  void Init()
399  {
400  hashBlock = uint256();
401  nIndex = -1;
402  }
403 
405  {
406  tx = std::move(arg);
407  }
408 
410 
411  template <typename Stream, typename Operation>
412  inline void SerializationOp(Stream& s, Operation ser_action) {
413  std::vector<uint256> vMerkleBranch; // For compatibility with older versions.
414  READWRITE(tx);
415  READWRITE(hashBlock);
416  READWRITE(vMerkleBranch);
417  READWRITE(nIndex);
418  }
419 
420  void SetMerkleBranch(const uint256& block_hash, int posInBlock);
421 
428  int GetDepthInMainChain(interfaces::Chain::Lock& locked_chain) const;
429  bool IsInMainChain(interfaces::Chain::Lock& locked_chain) const { return GetDepthInMainChain(locked_chain) > 0; }
430 
436  int GetBlocksToMaturity(interfaces::Chain::Lock& locked_chain) const;
437  bool hashUnset() const { return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); }
438  bool isAbandoned() const { return (hashBlock == ABANDON_HASH); }
439  void setAbandoned() { hashBlock = ABANDON_HASH; }
440 
441  const uint256& GetHash() const { return tx->GetHash(); }
442  bool IsCoinBase() const { return tx->IsCoinBase(); }
443  bool IsImmatureCoinBase(interfaces::Chain::Lock& locked_chain) const;
444 };
445 
446 //Get the marginal bytes of spending the specified output
447 int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, bool use_max_sig = false);
448 
453 class CWalletTx : public CMerkleTx
454 {
455 private:
456  const CWallet* pwallet;
457 
458 public:
484  mapValue_t mapValue;
485  std::vector<std::pair<std::string, std::string> > vOrderForm;
486  unsigned int fTimeReceivedIsTxTime;
487  unsigned int nTimeReceived;
488 
497  unsigned int nTimeSmart;
503  char fFromMe;
504  int64_t nOrderPos;
505  std::multimap<int64_t, CWalletTx*>::const_iterator m_it_wtxOrdered;
506 
507  // memory only
508  enum AmountType { DEBIT, CREDIT, IMMATURE_CREDIT, AVAILABLE_CREDIT, AMOUNTTYPE_ENUM_ELEMENTS };
509  CAmount GetCachableAmount(AmountType type, const isminefilter& filter, bool recalculate = false) const;
510  mutable CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS];
511  mutable bool fChangeCached;
512  mutable bool fInMempool;
514 
515  CWalletTx(const CWallet* pwalletIn, CTransactionRef arg) : CMerkleTx(std::move(arg))
516  {
517  Init(pwalletIn);
518  }
519 
520  void Init(const CWallet* pwalletIn)
521  {
522  pwallet = pwalletIn;
523  mapValue.clear();
524  vOrderForm.clear();
525  fTimeReceivedIsTxTime = false;
526  nTimeReceived = 0;
527  nTimeSmart = 0;
528  fFromMe = false;
529  fChangeCached = false;
530  fInMempool = false;
531  nChangeCached = 0;
532  nOrderPos = -1;
533  }
534 
535  template<typename Stream>
536  void Serialize(Stream& s) const
537  {
538  char fSpent = false;
539  mapValue_t mapValueCopy = mapValue;
540 
541  mapValueCopy["fromaccount"] = "";
542  WriteOrderPos(nOrderPos, mapValueCopy);
543  if (nTimeSmart) {
544  mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
545  }
546 
547  s << static_cast<const CMerkleTx&>(*this);
548  std::vector<CMerkleTx> vUnused;
549  s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
550  }
551 
552  template<typename Stream>
553  void Unserialize(Stream& s)
554  {
555  Init(nullptr);
556  char fSpent;
557 
558  s >> static_cast<CMerkleTx&>(*this);
559  std::vector<CMerkleTx> vUnused;
560  s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
561 
562  ReadOrderPos(nOrderPos, mapValue);
563  nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
564 
565  mapValue.erase("fromaccount");
566  mapValue.erase("spent");
567  mapValue.erase("n");
568  mapValue.erase("timesmart");
569  }
570 
572  void MarkDirty()
573  {
574  m_amounts[DEBIT].Reset();
575  m_amounts[CREDIT].Reset();
576  m_amounts[IMMATURE_CREDIT].Reset();
577  m_amounts[AVAILABLE_CREDIT].Reset();
578  fChangeCached = false;
579  }
580 
581  void BindWallet(CWallet *pwalletIn)
582  {
583  pwallet = pwalletIn;
584  MarkDirty();
585  }
586 
588  CAmount GetDebit(const isminefilter& filter) const;
589  CAmount GetCredit(interfaces::Chain::Lock& locked_chain, const isminefilter& filter) const;
590  CAmount GetImmatureCredit(interfaces::Chain::Lock& locked_chain, bool fUseCache=true) const;
591  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
592  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The
593  // annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid
594  // having to resolve the issue of member access into incomplete type CWallet.
595  CAmount GetAvailableCredit(interfaces::Chain::Lock& locked_chain, bool fUseCache=true, const isminefilter& filter=ISMINE_SPENDABLE) const NO_THREAD_SAFETY_ANALYSIS;
596  CAmount GetImmatureWatchOnlyCredit(interfaces::Chain::Lock& locked_chain, const bool fUseCache=true) const;
597  CAmount GetChange() const;
598 
599  // Get the marginal bytes if spending the specified output from this transaction
600  int GetSpendSize(unsigned int out, bool use_max_sig = false) const
601  {
602  return CalculateMaximumSignedInputSize(tx->vout[out], pwallet, use_max_sig);
603  }
604 
605  void GetAmounts(std::list<COutputEntry>& listReceived,
606  std::list<COutputEntry>& listSent, CAmount& nFee, const isminefilter& filter) const;
607 
608  bool IsFromMe(const isminefilter& filter) const
609  {
610  return (GetDebit(filter) > 0);
611  }
612 
613  // True if only scriptSigs are different
614  bool IsEquivalentTo(const CWalletTx& tx) const;
615 
616  bool InMempool() const;
617  bool IsTrusted(interfaces::Chain::Lock& locked_chain) const;
618 
619  int64_t GetTxTime() const;
620 
621  // Pass this transaction to the node to relay to its peers
622  bool RelayWalletTransaction(interfaces::Chain::Lock& locked_chain);
623 
625  bool AcceptToMemoryPool(interfaces::Chain::Lock& locked_chain, CValidationState& state);
626 
627  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
628  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
629  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
630  // resolve the issue of member access into incomplete type CWallet. Note
631  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
632  // in place.
633  std::set<uint256> GetConflicts() const NO_THREAD_SAFETY_ANALYSIS;
634 };
635 
636 class COutput
637 {
638 public:
639  const CWalletTx *tx;
640  int i;
641  int nDepth;
642 
645 
648 
650  bool fSolvable;
651 
654 
660  bool fSafe;
661 
662  COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in = false)
663  {
664  tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; fSolvable = fSolvableIn; fSafe = fSafeIn; nInputBytes = -1; use_max_sig = use_max_sig_in;
665  // If known and signable by the given wallet, compute nInputBytes
666  // Failure will keep this value -1
667  if (fSpendable && tx) {
668  nInputBytes = tx->GetSpendSize(i, use_max_sig);
669  }
670  }
671 
672  std::string ToString() const;
673 
674  inline CInputCoin GetInputCoin() const
675  {
676  return CInputCoin(tx->tx, i, nInputBytes);
677  }
678 };
679 
682 {
683 public:
685  int64_t nTimeCreated;
686  int64_t nTimeExpires;
687  std::string strComment;
688  // todo: add something to note what created it (user, getnewaddress, change)
689  // maybe should have a map<string, string> property map
690 
691  explicit CWalletKey(int64_t nExpires=0);
692 
694 
695  template <typename Stream, typename Operation>
696  inline void SerializationOp(Stream& s, Operation ser_action) {
697  int nVersion = s.GetVersion();
698  if (!(s.GetType() & SER_GETHASH))
699  READWRITE(nVersion);
700  READWRITE(vchPrivKey);
701  READWRITE(nTimeCreated);
702  READWRITE(nTimeExpires);
703  READWRITE(LIMITED_STRING(strComment, 65536));
704  }
705 };
706 
708 {
709  bool use_bnb = true;
710  size_t change_output_size = 0;
711  size_t change_spend_size = 0;
712  CFeeRate effective_fee = CFeeRate(0);
713  size_t tx_noinputs_size = 0;
714 
715  CoinSelectionParams(bool use_bnb, size_t change_output_size, size_t change_spend_size, CFeeRate effective_fee, size_t tx_noinputs_size) : use_bnb(use_bnb), change_output_size(change_output_size), change_spend_size(change_spend_size), effective_fee(effective_fee), tx_noinputs_size(tx_noinputs_size) {}
717 };
718 
719 class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime
725 {
726 private:
727  CKeyingMaterial vMasterKey GUARDED_BY(cs_KeyStore);
728 
731  std::atomic<bool> fUseCrypto;
732 
735 
736  using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
737  using WatchOnlySet = std::set<CScript>;
738  using WatchKeyMap = std::map<CKeyID, CPubKey>;
739 
740  bool SetCrypted();
741 
743  bool EncryptKeys(CKeyingMaterial& vMasterKeyIn);
744 
745  bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys = false);
746  CryptedKeyMap mapCryptedKeys GUARDED_BY(cs_KeyStore);
747  WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
748  WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
749 
750  bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
751  bool AddKeyPubKeyInner(const CKey& key, const CPubKey &pubkey);
752 
753  std::atomic<bool> fAbortRescan{false};
754  std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
755  std::atomic<int64_t> m_scanning_start{0};
756  std::atomic<double> m_scanning_progress{0};
757  std::mutex mutexScanning;
758  friend class WalletRescanReserver;
759 
760  WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr;
761 
763  int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
764 
766  int nWalletMaxVersion GUARDED_BY(cs_wallet) = FEATURE_BASE;
767 
768  int64_t nNextResend = 0;
769  int64_t nLastResend = 0;
770  bool fBroadcastTransactions = false;
771  // Local time that the tip block was received. Used to schedule wallet rebroadcasts.
772  std::atomic<int64_t> m_best_block_time {0};
773 
779  typedef std::multimap<COutPoint, uint256> TxSpends;
780  TxSpends mapTxSpends GUARDED_BY(cs_wallet);
781  void AddToSpends(const COutPoint& outpoint, const uint256& wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
782  void AddToSpends(const uint256& wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
783 
797  bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const uint256& block_hash, int posInBlock, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
798 
799  /* Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. */
800  void MarkConflicted(const uint256& hashBlock, const uint256& hashTx);
801 
802  /* Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed */
803  void MarkInputsDirty(const CTransactionRef& tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
804 
805  void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
806 
807  /* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
808  * Should be called with non-zero block_hash and posInBlock if this is for a transaction that is included in a block. */
809  void SyncTransaction(const CTransactionRef& tx, const uint256& block_hash, int posInBlock = 0, bool update_tx = true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
810 
811  /* the HD chain data model (external chain counters) */
812  CHDChain hdChain;
813 
814  /* HD derive new child key (on internal or external chain) */
815  void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
816 
817  std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_wallet);
818  std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_wallet);
819  std::set<int64_t> set_pre_split_keypool GUARDED_BY(cs_wallet);
820  int64_t m_max_keypool_index GUARDED_BY(cs_wallet) = 0;
821  std::map<CKeyID, int64_t> m_pool_key_to_index;
822  std::atomic<uint64_t> m_wallet_flags{0};
823 
824  int64_t nTimeFirstKey GUARDED_BY(cs_wallet) = 0;
825 
835  bool AddWatchOnly(const CScript& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
836  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
837  bool AddWatchOnlyInMem(const CScript &dest);
838 
840  bool AddKeyOriginWithDB(WalletBatch& batch, const CPubKey& pubkey, const KeyOriginInfo& info);
841 
843  bool AddKeyPubKeyWithDB(WalletBatch &batch,const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
844 
846  bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest, int64_t create_time) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
847 
848  void AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch);
849 
850  bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
851 
853  bool AddCScriptWithDB(WalletBatch& batch, const CScript& script);
854 
856  void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
857 
860 
863 
865  std::unique_ptr<WalletDatabase> database;
866 
875  uint256 m_last_block_processed GUARDED_BY(cs_wallet);
876 
878  bool GetKeyFromPool(CPubKey &key, bool internal = false);
879 
880 public:
881  /*
882  * Main wallet lock.
883  * This lock protects all the fields added by CWallet.
884  */
886 
891  {
892  return *database;
893  }
894 
900  bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet,
901  const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool& bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
902 
903  const WalletLocation& GetLocation() const { return m_location; }
904 
907  const std::string& GetName() const { return m_location.GetName(); }
908 
909  void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
910  void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
911 
912  // Map from Key ID to key metadata.
913  std::map<CKeyID, CKeyMetadata> mapKeyMetadata GUARDED_BY(cs_wallet);
914 
915  // Map from Script ID to key metadata (for watch-only keys).
916  std::map<CScriptID, CKeyMetadata> m_script_metadata GUARDED_BY(cs_wallet);
917 
918  typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
919  MasterKeyMap mapMasterKeys;
920  unsigned int nMasterKeyMaxID = 0;
921 
923  CWallet(interfaces::Chain* chain, const WalletLocation& location, std::unique_ptr<WalletDatabase> database)
924  : fUseCrypto(false),
925  fDecryptionThoroughlyChecked(false),
926  m_chain(chain),
927  m_location(location),
928  database(std::move(database))
929  {
930  }
931 
933  {
934  // Should not have slots connected at this point.
935  assert(NotifyUnload.empty());
936  delete encrypted_batch;
937  encrypted_batch = nullptr;
938  }
939 
940  bool IsCrypted() const { return fUseCrypto; }
941  bool IsLocked() const;
942  bool Lock();
943 
944  std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
945 
946  typedef std::multimap<int64_t, CWalletTx*> TxItems;
947  TxItems wtxOrdered;
948 
949  int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
950  uint64_t nAccountingEntryNumber = 0;
951 
952  std::map<CTxDestination, CAddressBookData> mapAddressBook GUARDED_BY(cs_wallet);
953 
954  std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
955 
957  std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
958 
960  void handleNotifications();
961 
963  interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
964 
965  const CWalletTx* GetWalletTx(const uint256& hash) const;
966 
968  bool CanSupportFeature(enum WalletFeature wf) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }
969 
973  void AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<COutput>& vCoins, bool fOnlySafe=true, const CCoinControl *coinControl = nullptr, const CAmount& nMinimumAmount = 1, const CAmount& nMaximumAmount = MAX_MONEY, const CAmount& nMinimumSumAmount = MAX_MONEY, const uint64_t nMaximumCount = 0, const int nMinDepth = 0, const int nMaxDepth = 9999999) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
974 
978  std::map<CTxDestination, std::vector<COutput>> ListCoins(interfaces::Chain::Lock& locked_chain) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
979 
983  const CTxOut& FindNonChangeParentOutput(const CTransaction& tx, int output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
984 
991  bool SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<OutputGroup> groups,
992  std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CoinSelectionParams& coin_selection_params, bool& bnb_used) const;
993 
994  bool IsSpent(interfaces::Chain::Lock& locked_chain, const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
995 
996  // Whether this or any UTXO with the same CTxDestination has been spent.
997  bool IsUsedDestination(const CTxDestination& dst) const;
998  bool IsUsedDestination(const uint256& hash, unsigned int n) const;
999  void SetUsedDestinationState(const uint256& hash, unsigned int n, bool used);
1000 
1001  std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool single_coin) const;
1002 
1003  bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1004  void LockCoin(const COutPoint& output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1005  void UnlockCoin(const COutPoint& output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1006  void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1007  void ListLockedCoins(std::vector<COutPoint>& vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1008 
1009  /*
1010  * Rescan abort properties
1011  */
1012  void AbortRescan() { fAbortRescan = true; }
1013  bool IsAbortingRescan() { return fAbortRescan; }
1014  bool IsScanning() { return fScanningWallet; }
1015  int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
1016  double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
1017 
1022  CPubKey GenerateNewKey(WalletBatch& batch, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1024  bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1026  bool LoadKey(const CKey& key, const CPubKey &pubkey) { return AddKeyPubKeyInner(key, pubkey); }
1028  void LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1029  void LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1031  void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1032 
1033  bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
1034  void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1035 
1037  bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
1039  bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
1040  bool GetKey(const CKeyID &address, CKey& keyOut) const override;
1041  bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
1042  bool HaveKey(const CKeyID &address) const override;
1043  std::set<CKeyID> GetKeys() const override;
1044  bool AddCScript(const CScript& redeemScript) override;
1045  bool LoadCScript(const CScript& redeemScript);
1046 
1048  bool AddDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1050  bool EraseDestData(const CTxDestination& dest, const std::string& key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1052  void LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1054  bool GetDestData(const CTxDestination& dest, const std::string& key, std::string* value) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1056  std::vector<std::string> GetDestValues(const std::string& prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1057 
1059  bool AddWatchOnly(const CScript& dest, int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1060  bool RemoveWatchOnly(const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1062  bool LoadWatchOnly(const CScript &dest);
1064  bool HaveWatchOnly(const CScript &dest) const;
1066  bool HaveWatchOnly() const;
1068  bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
1069 
1071  int64_t nRelockTime = 0;
1072 
1073  bool Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys = false);
1074  bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
1075  bool EncryptWallet(const SecureString& strWalletPassphrase);
1076 
1077  void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1078  unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
1079 
1084  int64_t IncOrderPosNext(WalletBatch *batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1085  DBErrors ReorderTransactions();
1086 
1087  void MarkDirty();
1088  bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);
1089  void LoadToWallet(const CWalletTx& wtxIn) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1090  void TransactionAddedToMempool(const CTransactionRef& tx) override;
1091  void BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& vtxConflicted) override;
1092  void BlockDisconnected(const CBlock& block) override;
1093  void UpdatedBlockTip() override;
1094  int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
1095 
1096  struct ScanResult {
1097  enum { SUCCESS, FAILURE, USER_ABORT } status = SUCCESS;
1098 
1104 
1110  };
1111  ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
1112  void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;
1113  void ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1114  void ResendWalletTransactions();
1115  struct Balance {
1116  CAmount m_mine_trusted{0};
1117  CAmount m_mine_untrusted_pending{0};
1118  CAmount m_mine_immature{0};
1119  CAmount m_watchonly_trusted{0};
1120  CAmount m_watchonly_untrusted_pending{0};
1121  CAmount m_watchonly_immature{0};
1122  };
1123  Balance GetBalance(int min_depth = 0, bool avoid_reuse = true) const;
1124  CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
1125 
1126  OutputType TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend);
1127 
1132  bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, std::string& strFailReason, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl);
1134 
1140  bool CreateTransaction(interfaces::Chain::Lock& locked_chain, const std::vector<CRecipient>& vecSend, CTransactionRef& tx, ReserveDestination& reservedest, CAmount& nFeeRet, int& nChangePosInOut,
1141  std::string& strFailReason, const CCoinControl& coin_control, bool sign = true);
1142  bool CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, ReserveDestination& reservedest, CValidationState& state);
1143 
1144  bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, bool use_max_sig = false) const
1145  {
1146  std::vector<CTxOut> v_txouts(txouts.size());
1147  std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
1148  return DummySignTx(txNew, v_txouts, use_max_sig);
1149  }
1150  bool DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut> &txouts, bool use_max_sig = false) const;
1151  bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig = false) const;
1152 
1153  bool ImportScripts(const std::set<CScript> scripts) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1154  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1155  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);
1156  bool ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1157 
1159  unsigned int m_confirm_target{DEFAULT_TX_CONFIRM_TARGET};
1160  bool m_spend_zero_conf_change{DEFAULT_SPEND_ZEROCONF_CHANGE};
1161  bool m_signal_rbf{DEFAULT_WALLET_RBF};
1162  bool m_allow_fallback_fee{true};
1164 
1171  OutputType m_default_address_type{DEFAULT_ADDRESS_TYPE};
1172  OutputType m_default_change_type{DEFAULT_CHANGE_TYPE};
1174  CAmount m_default_max_tx_fee{DEFAULT_TRANSACTION_MAXFEE};
1175 
1176  bool NewKeyPool();
1177  size_t KeypoolCountExternalKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1178  bool TopUpKeyPool(unsigned int kpSize = 0);
1179 
1194  bool ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
1195  void KeepKey(int64_t nIndex);
1196  void ReturnKey(int64_t nIndex, bool fInternal, const CPubKey& pubkey);
1197  int64_t GetOldestKeyPoolTime();
1201  void MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1202  const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
1203 
1204  std::set<std::set<CTxDestination>> GetAddressGroupings() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1205  std::map<CTxDestination, CAmount> GetAddressBalances(interfaces::Chain::Lock& locked_chain);
1206 
1207  std::set<CTxDestination> GetLabelAddresses(const std::string& label) const;
1208 
1209  bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error);
1210  bool GetNewChangeDestination(const OutputType type, CTxDestination& dest, std::string& error);
1211 
1212  isminetype IsMine(const CTxIn& txin) const;
1217  CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
1218  isminetype IsMine(const CTxOut& txout) const;
1219  CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
1220  bool IsChange(const CTxOut& txout) const;
1221  bool IsChange(const CScript& script) const;
1222  CAmount GetChange(const CTxOut& txout) const;
1223  bool IsMine(const CTransaction& tx) const;
1225  bool IsFromMe(const CTransaction& tx) const;
1226  CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
1228  bool IsAllFromMe(const CTransaction& tx, const isminefilter& filter) const;
1229  CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
1230  CAmount GetChange(const CTransaction& tx) const;
1231  void ChainStateFlushed(const CBlockLocator& loc) override;
1232 
1233  DBErrors LoadWallet(bool& fFirstRunRet);
1234  DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx);
1235  DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1236 
1237  bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
1238 
1239  bool DelAddressBook(const CTxDestination& address);
1240 
1241  const std::string& GetLabelName(const CScript& scriptPubKey) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1242 
1243  unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
1244  {
1245  AssertLockHeld(cs_wallet);
1246  return setInternalKeyPool.size() + setExternalKeyPool.size();
1247  }
1248 
1250  void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr, bool fExplicit = false);
1251 
1253  bool SetMaxVersion(int nVersion);
1254 
1256  int GetVersion() { LOCK(cs_wallet); return nWalletVersion; }
1257 
1259  std::set<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1260 
1262  bool HasWalletSpend(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1263 
1265  void Flush(bool shutdown=false);
1266 
1268  boost::signals2::signal<void ()> NotifyUnload;
1269 
1274  boost::signals2::signal<void (CWallet *wallet, const CTxDestination
1275  &address, const std::string &label, bool isMine,
1276  const std::string &purpose,
1278 
1283  boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx,
1285 
1287  boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
1288 
1290  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
1291 
1293  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
1294 
1299  boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
1300 
1302  bool GetBroadcastTransactions() const { return fBroadcastTransactions; }
1304  void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
1305 
1307  bool TransactionCanBeAbandoned(const uint256& hashTx) const;
1308 
1309  /* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
1310  bool AbandonTransaction(interfaces::Chain::Lock& locked_chain, const uint256& hashTx);
1311 
1313  bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
1314 
1316  static bool Verify(interfaces::Chain& chain, const WalletLocation& location, bool salvage_wallet, std::string& error_string, std::string& warning_string);
1317 
1318  /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
1319  static std::shared_ptr<CWallet> CreateWalletFromFile(interfaces::Chain& chain, const WalletLocation& location, uint64_t wallet_creation_flags = 0);
1320 
1325  void postInitProcess();
1326 
1327  bool BackupWallet(const std::string& strDest);
1328 
1329  /* Set the HD chain model (chain child index counters) */
1330  void SetHDChain(const CHDChain& chain, bool memonly);
1331  const CHDChain& GetHDChain() const { return hdChain; }
1332 
1333  /* Returns true if HD is enabled */
1334  bool IsHDEnabled() const;
1335 
1336  /* Returns true if the wallet can generate new keys */
1337  bool CanGenerateKeys();
1338 
1339  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
1340  bool CanGetAddresses(bool internal = false);
1341 
1342  /* Generates a new HD seed (will not be activated) */
1343  CPubKey GenerateNewSeed();
1344 
1345  /* Derives a new HD seed (will not be activated) */
1346  CPubKey DeriveNewSeed(const CKey& key);
1347 
1348  /* Set the current HD seed (will reset the chain child index counters)
1349  Sets the seed's version based on the current wallet version (so the
1350  caller must ensure the current wallet version is correct before calling
1351  this function). */
1352  void SetHDSeed(const CPubKey& key);
1353 
1360  void BlockUntilSyncedToCurrentChain() LOCKS_EXCLUDED(cs_main, cs_wallet);
1361 
1368  void LearnRelatedScripts(const CPubKey& key, OutputType);
1369 
1374  void LearnAllRelatedScripts(const CPubKey& key);
1375 
1377  void SetWalletFlag(uint64_t flags);
1378 
1380  void UnsetWalletFlag(uint64_t flag);
1381 
1383  bool IsWalletFlagSet(uint64_t flag) const;
1384 
1387  bool SetWalletFlags(uint64_t overwriteFlags, bool memOnly);
1388 
1390  const std::string GetDisplayName() const {
1391  std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
1392  return strprintf("[%s]", wallet_name);
1393  };
1394 
1396  template<typename... Params>
1397  void WalletLogPrintf(std::string fmt, Params... parameters) const {
1398  LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
1399  };
1400 
1402  bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
1403 };
1404 
1409 void MaybeResendWalletTxs();
1410 
1413 {
1414 private:
1417 public:
1418  explicit WalletRescanReserver(CWallet* w) : m_wallet(w), m_could_reserve(false) {}
1419 
1420  bool reserve()
1421  {
1422  assert(!m_could_reserve);
1423  std::lock_guard<std::mutex> lock(m_wallet->mutexScanning);
1424  if (m_wallet->fScanningWallet) {
1425  return false;
1426  }
1427  m_wallet->m_scanning_start = GetTimeMillis();
1428  m_wallet->m_scanning_progress = 0;
1429  m_wallet->fScanningWallet = true;
1430  m_could_reserve = true;
1431  return true;
1432  }
1433 
1434  bool isReserved() const
1435  {
1436  return (m_could_reserve && m_wallet->fScanningWallet);
1437  }
1438 
1440  {
1441  std::lock_guard<std::mutex> lock(m_wallet->mutexScanning);
1442  if (m_could_reserve) {
1443  m_wallet->fScanningWallet = false;
1444  }
1445  }
1446 };
1447 
1448 // Calculate the size of the transaction assuming all signatures are max size
1449 // Use DummySignatureCreator, which inserts 71 byte signatures everywhere.
1450 // NOTE: this requires that all inputs must be in mapWallet (eg the tx should
1451 // be IsAllFromMe).
1452 int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig = false) EXCLUSIVE_LOCKS_REQUIRED(wallet->cs_wallet);
1453 int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, bool use_max_sig = false);
1454 #endif // BITCOIN_WALLET_WALLET_H
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:408
AmountType
Definition: wallet.h:508
int64_t nTimeCreated
Definition: wallet.h:685
bool fChangeCached
Definition: wallet.h:511
const CWallet * pwallet
Definition: wallet.h:456
std::atomic< bool > fScanningWallet
Definition: wallet.h:754
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:53
void SetTx(CTransactionRef arg)
Definition: wallet.h:404
static const uint256 ABANDON_HASH
Constant used in hashBlock to indicate tx has been abandoned.
Definition: wallet.h:373
std::unique_ptr< WalletDatabase > database
Internal database handle.
Definition: wallet.h:865
void SerializationOp(Stream &s, Operation ser_action)
Definition: wallet.h:696
int i
Definition: wallet.h:640
void BindWallet(CWallet *pwalletIn)
Definition: wallet.h:581
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition: wallet.h:957
std::map< std::string, std::string > mapValue_t
Definition: wallet.h:340
bool CanSupportFeature(enum WalletFeature wf) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature ...
Definition: wallet.h:968
bool fSolvable
Whether we know how to spend this output, ignoring the lack of keys.
Definition: wallet.h:650
CPrivKey vchPrivKey
Definition: wallet.h:684
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition: wallet.h:87
Describes a place in the block chain to another node such that if the other node doesn&#39;t have the sam...
Definition: block.h:126
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: wallet.h:1293
constexpr CAmount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
Definition: wallet.h:91
CTxDestination address
The destination.
Definition: wallet.h:292
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
Definition: wallet.h:1202
char fFromMe
From me flag is set to 1 for transactions that were created by the wallet on this bitcoin node...
Definition: wallet.h:503
CAmount nChangeCached
Definition: wallet.h:513
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:65
Definition: block.h:72
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:54
CCriticalSection cs_wallet
Definition: wallet.h:885
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition: amount.h:25
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1067
const uint256 & GetHash() const
Definition: wallet.h:441
bool IsFromMe(const isminefilter &filter) const
Definition: wallet.h:608
int nIndex
Definition: wallet.h:384
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
Definition: wallet.h:1144
constexpr OutputType DEFAULT_CHANGE_TYPE
Default for -changetype.
Definition: wallet.h:127
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses, and other watch only things, and is therefore "blank.".
Definition: wallet.h:153
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition: wallet.h:1102
bool use_max_sig
Whether to use the maximum sized, 72 byte signature when calculating the size of the input spend...
Definition: wallet.h:653
static const CAmount COIN
Definition: amount.h:14
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:52
FeeEstimateMode
Definition: fees.h:49
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
Definition: wallet.h:736
TxItems wtxOrdered
Definition: wallet.h:947
const char * prefix
Definition: rest.cpp:626
uint256 hashBlock
Definition: wallet.h:377
static CTransactionRef MakeTransactionRef()
Definition: transaction.h:409
CWallet(interfaces::Chain *chain, const WalletLocation &location, std::unique_ptr< WalletDatabase > database)
Construct wallet with specified name and database implementation.
Definition: wallet.h:923
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:779
Interface for querying locked chain state, used by legacy code that assumes state won&#39;t change betwee...
Definition: chain.h:68
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:60
int64_t nOrderPos
position in ordered transaction list
Definition: wallet.h:504
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const WalletLocation &location, std::string &error, std::string &warning)
Definition: wallet.cpp:141
std::multimap< int64_t, CWalletTx * >::const_iterator m_it_wtxOrdered
Definition: wallet.h:505
An instance of this class represents one database.
Definition: db.h:113
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:68
static void ReadOrderPos(int64_t &nOrderPos, mapValue_t &mapValue)
Definition: wallet.h:343
static void LogPrintf(const char *fmt, const Args &... args)
Definition: logging.h:144
CMerkleTx(CTransactionRef arg)
Definition: wallet.h:392
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:39
int nWalletVersion GUARDED_BY(cs_wallet)
the current wallet version: clients below this version are not able to load the wallet ...
Definition: wallet.h:763
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:85
WalletFeature
(client) version numbers for particular wallet features
Definition: wallet.h:105
std::set< CScript > WatchOnlySet
Definition: wallet.h:737
void MarkDirty()
make sure balances are recalculated
Definition: wallet.h:572
bool fSubtractFeeFromAmount
Definition: wallet.h:337
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition: wallet.h:918
std::string strComment
Definition: wallet.h:687
std::string name
Definition: wallet.h:324
int nInputBytes
Pre-computed estimated size of this output as a fully-signed input in a transaction.
Definition: wallet.h:644
UniValue SignTransaction(CMutableTransaction &mtx, const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins, bool is_temp_keystore, const UniValue &hashType)
Sign a transaction with the given keystore and previous transactions.
CWallet * pwallet
The wallet to reserve from.
Definition: wallet.h:286
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:118
int64_t ScanningDuration() const
Definition: wallet.h:1015
WalletCreationStatus
Definition: wallet.h:54
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: wallet.h:1299
DBErrors
Error statuses for the wallet database.
Definition: walletdb.h:48
bool fSpendable
Whether we have the private keys to spend this output.
Definition: wallet.h:647
int64_t nTimeExpires
Definition: wallet.h:686
bool IsNull() const
Definition: uint256.h:31
std::string purpose
Definition: wallet.h:325
void Init()
Definition: wallet.h:398
OutputType
Definition: outputtype.h:16
static const bool DEFAULT_WALLET_RBF
-walletrbf default
Definition: wallet.h:83
Coin Control Features.
Definition: coincontrol.h:16
std::atomic< bool > fUseCrypto
if fUseCrypto is true, mapKeys must be empty if fUseCrypto is false, vMasterKey must be empty ...
Definition: wallet.h:731
double ScanningProgress() const
Definition: wallet.h:1016
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee, bool test_accept)
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions repla...
Definition: validation.cpp:849
Access to the wallet database.
Definition: walletdb.h:152
mapValue_t mapValue
Key/value map with information about the transaction.
Definition: wallet.h:484
std::mutex mutexScanning
Definition: wallet.h:757
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:963
bool HaveKey(const CWallet &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
Definition: rpcwallet.cpp:56
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:1268
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:67
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
secure_allocator is defined in allocators.h CPrivKey is a serialized private key, with all parameters...
Definition: key.h:24
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:1284
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition: wallet.h:1304
ReserveDestination(CWallet *pwalletIn)
Construct a ReserveDestination object. This does NOT reserve an address yet.
Definition: wallet.h:298
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in=false)
Definition: wallet.h:662
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:165
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
Definition: wallet.h:222
void Unserialize(Stream &s)
Definition: wallet.h:553
CScript scriptPubKey
Definition: wallet.h:335
CCriticalSection cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition: validation.cpp:96
int nDepth
Definition: wallet.h:641
const std::string & GetName() const
Get wallet name.
Definition: walletutil.h:29
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::string &error, std::string &warning, WalletCreationStatus &status, const SecureString &passphrase, uint64_t wallet_creation_flags)
Definition: wallet.cpp:163
ChangeType
General change type (added, updated, removed).
Definition: ui_interface.h:26
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:1397
CTransactionRef tx
Definition: wallet.h:376
Chain & m_chain
Definition: chain.cpp:201
An input of a transaction.
Definition: transaction.h:63
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, bool use_max_sig=false)
Definition: wallet.cpp:1882
unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:1243
#define LOCK(cs)
Definition: sync.h:182
const char * name
Definition: rest.cpp:39
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
Definition: wallet.h:1256
CKeyPool()
Definition: wallet.cpp:4593
Chain notifications.
Definition: chain.h:228
void SerializationOp(Stream &s, Operation ser_action)
Definition: wallet.h:412
An encapsulated public key.
Definition: pubkey.h:30
Fillable signing provider that keeps keys in an address->secret map.
bool fSafe
Whether this output is considered safe to spend.
Definition: wallet.h:660
CAmount amount
Definition: wallet.h:364
std::string i64tostr(int64_t n)
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition: wallet.h:859
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:84
bool IsCoinBase() const
Definition: wallet.h:442
std::map< std::string, std::string > StringMap
Definition: wallet.h:329
uint8_t isminefilter
Definition: wallet.h:28
WalletDatabase & GetDBHandle()
Get database handle used by this wallet.
Definition: wallet.h:890
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet)
Definition: wallet.h:1026
bool m_pre_split
Whether this key was generated for a keypool before the wallet was upgraded to HD-split.
Definition: wallet.h:228
Definition: wallet.h:55
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:75
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
Definition: wallet.h:124
isminetype
IsMine() return codes.
Definition: ismine.h:18
An output of a transaction.
Definition: transaction.h:133
const WalletLocation & GetLocation() const
Definition: wallet.h:903
std::shared_ptr< CWallet > GetWallet(const std::string &name)
Definition: wallet.cpp:84
ADD_SERIALIZE_METHODS
Definition: wallet.h:409
static const bool DEFAULT_AVOIDPARTIALSPENDS
Default for -avoidpartialspends.
Definition: wallet.h:79
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
Definition: wallet.h:81
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:18
ADD_SERIALIZE_METHODS
Definition: wallet.h:233
unsigned int fTimeReceivedIsTxTime
Definition: wallet.h:486
Special output type for change outputs only.
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey&#39;ed, it will be returned to the keypool...
Definition: wallet.h:307
CAmount nAmount
Definition: wallet.h:336
RAII object to check and reserve a wallet rescan.
Definition: wallet.h:1412
bool HasWallets()
Definition: wallet.cpp:72
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:453
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
Definition: wallet.h:1302
CWallet * m_wallet
Definition: wallet.h:1415
isminetype IsMine(const CWallet &keystore, const CScript &scriptPubKey)
Definition: ismine.cpp:175
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:162
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:62
void Serialize(Stream &s) const
Definition: wallet.h:536
int flags
Definition: bitcoin-tx.cpp:507
bool fInMempool
Definition: wallet.h:512
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
Definition: wallet.h:77
Capture information about block/transaction validation.
Definition: validation.h:98
static void NotifyUnload(WalletModel *walletModel)
256-bit opaque blob.
Definition: uint256.h:121
void Init(const CWallet *pwalletIn)
Definition: wallet.h:520
CPubKey vchPubKey
The public key.
Definition: wallet.h:224
int64_t atoi64(const char *psz)
CWalletTx(const CWallet *pwalletIn, CTransactionRef arg)
Definition: wallet.h:515
void setAbandoned()
Definition: wallet.h:439
Cachable amount subdivided into watchonly and spendable parts.
Definition: ismine.h:37
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
WalletLocation m_location
Wallet location which includes wallet name (see WalletLocation).
Definition: wallet.h:862
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
Definition: wallet.h:71
static void WriteOrderPos(const int64_t &nOrderPos, mapValue_t &mapValue)
Definition: wallet.h:354
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0)
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:50
boost::signals2::signal< void(CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
Definition: wallet.h:1277
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:907
MasterKeyMap mapMasterKeys
Definition: wallet.h:919
int vout
Definition: wallet.h:365
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:58
Result CommitTransaction(CWallet *wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< std::string > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
Definition: feebumper.cpp:308
Address book data.
Definition: wallet.h:321
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:390
StringMap destdata
Definition: wallet.h:330
CTxDestination destination
Definition: wallet.h:363
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
Definition: sign.cpp:52
unsigned int nTimeSmart
Stable timestamp that never changes, and reflects the order a transaction was added to the wallet...
Definition: wallet.h:497
CInputCoin GetInputCoin() const
Definition: wallet.h:674
void Reset()
Definition: ismine.h:42
int GetSpendSize(unsigned int out, bool use_max_sig=false) const
Definition: wallet.h:600
ADD_SERIALIZE_METHODS
Definition: wallet.h:693
Private key that includes an expiration date in case it never gets used.
Definition: wallet.h:681
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:20
const CWalletTx * tx
Definition: wallet.h:639
#define LIMITED_STRING(obj, n)
Definition: serialize.h:424
CoinSelectionParams(bool use_bnb, size_t change_output_size, size_t change_spend_size, CFeeRate effective_fee, size_t tx_noinputs_size)
Definition: wallet.h:715
bool IsScanning()
Definition: wallet.h:1014
bool IsCrypted() const
Definition: wallet.h:940
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:724
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:19
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
Definition: wallet.cpp:2367
bool IsInMainChain(interfaces::Chain::Lock &locked_chain) const
Definition: wallet.h:429
A wrapper to reserve an address from a wallet.
Definition: wallet.h:282
void AbortRescan()
Definition: wallet.h:1012
Definition: wallet.h:361
#define GUARDED_BY(x)
Definition: threadsafety.h:38
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, CAmount &fee_out, int &change_position, UniValue options)
Definition: rpcwallet.cpp:2960
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:1287
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:22
void SerializationOp(Stream &s, Operation ser_action)
Definition: wallet.h:236
Optional< int > last_scanned_height
Definition: wallet.h:1103
A mutable version of CTransaction.
Definition: transaction.h:366
uint256 last_failed_block
Height of the most recent block that could not be scanned due to read errors or pruning.
Definition: wallet.h:1109
bool IsAbortingRescan()
Definition: wallet.h:1013
WalletFlags
Definition: wallet.h:129
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
Definition: wallet.h:73
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:1033
static std::vector< COutput > vCoins
The WalletLocation class provides wallet information.
Definition: walletutil.h:19
CMerkleTx()
Definition: wallet.h:386
std::atomic< int64_t > m_scanning_start
Definition: wallet.h:755
unsigned int nTimeReceived
time received by this node
Definition: wallet.h:487
An encapsulated private key.
Definition: key.h:27
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:270
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:14
bool isReserved() const
Definition: wallet.h:1434
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
Definition: wallet.h:63
bool hashUnset() const
Definition: wallet.h:437
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:139
std::atomic< double > m_scanning_progress
Definition: wallet.h:756
const CHDChain & GetHDChain() const
Definition: wallet.h:1331
AssertLockHeld(g_cs_orphans)
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
Definition: wallet.h:734
WalletRescanReserver(CWallet *w)
Definition: wallet.h:1418
#define READWRITE(...)
Definition: serialize.h:184
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:1290
std::multimap< int64_t, CWalletTx * > TxItems
Definition: wallet.h:946
bool error(const char *fmt, const Args &... args)
Definition: system.h:59
static const CAmount DEFAULT_DISCARD_FEE
-discardfee default
Definition: wallet.h:69
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
Definition: wallet.h:226
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig=false) EXCLUSIVE_LOCKS_REQUIRED(wallet -> cs_wallet)
Definition: wallet.cpp:1853
std::vector< std::shared_ptr< CWallet > > GetWallets()
Definition: dummywallet.cpp:67
CPubKey vchPubKey
The public key for the address.
Definition: wallet.h:290
A transaction with a merkle branch linking it to the block chain.
Definition: wallet.h:369
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition: wallet.h:156
std::map< CKeyID, CPubKey > WatchKeyMap
Definition: wallet.h:738
~CWallet()
Definition: wallet.h:932
A key from a CWallet&#39;s keypool.
Definition: wallet.h:218
constexpr CAmount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
Definition: wallet.h:89
std::vector< std::pair< std::string, std::string > > vOrderForm
Definition: wallet.h:485
bool isAbandoned() const
Definition: wallet.h:438
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE
Pre-calculated constants for input size estimation in virtual size
Definition: wallet.h:94