Bitcoin Core  21.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/scriptpubkeyman.h>
25 #include <external_signer.h>
26 #include <wallet/walletdb.h>
27 #include <wallet/walletutil.h>
28 
29 #include <algorithm>
30 #include <atomic>
31 #include <map>
32 #include <memory>
33 #include <optional>
34 #include <set>
35 #include <stdexcept>
36 #include <stdint.h>
37 #include <string>
38 #include <utility>
39 #include <vector>
40 
41 #include <boost/signals2/signal.hpp>
42 
43 using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
44 
45 struct bilingual_str;
46 
52 void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
53 
54 bool AddWallet(const std::shared_ptr<CWallet>& wallet);
55 bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
56 bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start);
57 std::vector<std::shared_ptr<CWallet>> GetWallets();
58 std::shared_ptr<CWallet> GetWallet(const std::string& name);
59 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);
60 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);
61 std::unique_ptr<interfaces::Handler> HandleLoadWallet(LoadWalletFn load_wallet);
62 std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
63 
67 static const CAmount DEFAULT_FALLBACK_FEE = 0;
69 static const CAmount DEFAULT_DISCARD_FEE = 10000;
71 static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
81 constexpr CAmount HIGH_APS_FEE{COIN / 10000};
85 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
87 static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
89 static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
91 static const bool DEFAULT_WALLET_RBF = false;
92 static const bool DEFAULT_WALLETBROADCAST = true;
93 static const bool DEFAULT_DISABLE_WALLET = false;
97 constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
101 static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
102 
103 class CCoinControl;
104 class COutput;
105 class CScript;
106 class CWalletTx;
107 struct FeeCalculation;
108 enum class FeeEstimateMode;
109 class ReserveDestination;
110 
113 
114 static constexpr uint64_t KNOWN_WALLET_FLAGS =
121 
122 static constexpr uint64_t MUTABLE_WALLET_FLAGS =
124 
125 static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
126  {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
127  {"blank", WALLET_FLAG_BLANK_WALLET},
128  {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
129  {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
130  {"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
131  {"external_signer", WALLET_FLAG_EXTERNAL_SIGNER}
132 };
133 
134 extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;
135 
152 {
153 protected:
155  const CWallet* const pwallet;
160  int64_t nIndex{-1};
164  bool fInternal{false};
165 
166 public:
169  : pwallet(pwallet)
170  , type(type) { }
171 
172  ReserveDestination(const ReserveDestination&) = delete;
174 
177  {
179  }
180 
182  bool GetReservedDestination(CTxDestination& pubkey, bool internal);
184  void ReturnDestination();
186  void KeepDestination();
187 };
188 
191 {
192 private:
193  bool m_change{true};
194  std::string m_label;
195 public:
196  std::string purpose;
197 
198  CAddressBookData() : purpose("unknown") {}
199 
200  typedef std::map<std::string, std::string> StringMap;
202 
203  bool IsChange() const { return m_change; }
204  const std::string& GetLabel() const { return m_label; }
205  void SetLabel(const std::string& label) {
206  m_change = false;
207  m_label = label;
208  }
209 };
210 
212 {
216 };
217 
218 typedef std::map<std::string, std::string> mapValue_t;
219 
220 
221 static inline void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue)
222 {
223  if (!mapValue.count("n"))
224  {
225  nOrderPos = -1; // TODO: calculate elsewhere
226  return;
227  }
228  nOrderPos = atoi64(mapValue["n"]);
229 }
230 
231 
232 static inline void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
233 {
234  if (nOrderPos == -1)
235  return;
236  mapValue["n"] = ToString(nOrderPos);
237 }
238 
240 {
243  int vout;
244 };
245 
252 {
253 public:
254  template<typename Stream>
255  void Unserialize(Stream& s)
256  {
257  CTransactionRef tx;
258  uint256 hashBlock;
259  std::vector<uint256> vMerkleBranch;
260  int nIndex;
261 
262  s >> tx >> hashBlock >> vMerkleBranch >> nIndex;
263  }
264 };
265 
266 //Get the marginal bytes of spending the specified output
267 int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, bool use_max_sig = false);
268 
274 {
275 private:
276  const CWallet* const pwallet;
277 
281  static constexpr const uint256& ABANDON_HASH = uint256::ONE;
282 
283 public:
310  std::vector<std::pair<std::string, std::string> > vOrderForm;
311  unsigned int fTimeReceivedIsTxTime;
312  unsigned int nTimeReceived;
313 
322  unsigned int nTimeSmart;
328  bool fFromMe;
329  int64_t nOrderPos;
330  std::multimap<int64_t, CWalletTx*>::const_iterator m_it_wtxOrdered;
331 
332  // memory only
334  CAmount GetCachableAmount(AmountType type, const isminefilter& filter, bool recalculate = false) const;
342  mutable bool m_is_cache_empty{true};
343  mutable bool fChangeCached;
344  mutable bool fInMempool;
346 
348  : pwallet(wallet),
349  tx(std::move(arg))
350  {
351  Init();
352  }
353 
354  void Init()
355  {
356  mapValue.clear();
357  vOrderForm.clear();
358  fTimeReceivedIsTxTime = false;
359  nTimeReceived = 0;
360  nTimeSmart = 0;
361  fFromMe = false;
362  fChangeCached = false;
363  fInMempool = false;
364  nChangeCached = 0;
365  nOrderPos = -1;
367  }
368 
370 
371  /* New transactions start as UNCONFIRMED. At BlockConnected,
372  * they will transition to CONFIRMED. In case of reorg, at BlockDisconnected,
373  * they roll back to UNCONFIRMED. If we detect a conflicting transaction at
374  * block connection, we update conflicted tx and its dependencies as CONFLICTED.
375  * If tx isn't confirmed and outside of mempool, the user may switch it to ABANDONED
376  * by using the abandontransaction call. This last status may be override by a CONFLICTED
377  * or CONFIRMED transition.
378  */
379  enum Status {
384  };
385 
386  /* Confirmation includes tx status and a triplet of {block height/block hash/tx index in block}
387  * at which tx has been confirmed. All three are set to 0 if tx is unconfirmed or abandoned.
388  * Meaning of these fields changes with CONFLICTED state where they instead point to block hash
389  * and block height of the deepest conflicting tx.
390  */
391  struct Confirmation {
395  int nIndex;
396  Confirmation(Status s = UNCONFIRMED, int b = 0, uint256 h = uint256(), int i = 0) : status(s), block_height(b), hashBlock(h), nIndex(i) {}
397  };
398 
400 
401  template<typename Stream>
402  void Serialize(Stream& s) const
403  {
404  mapValue_t mapValueCopy = mapValue;
405 
406  mapValueCopy["fromaccount"] = "";
407  WriteOrderPos(nOrderPos, mapValueCopy);
408  if (nTimeSmart) {
409  mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
410  }
411 
412  std::vector<char> dummy_vector1;
413  std::vector<char> dummy_vector2;
414  bool dummy_bool = false;
415  uint256 serializedHash = isAbandoned() ? ABANDON_HASH : m_confirm.hashBlock;
416  int serializedIndex = isAbandoned() || isConflicted() ? -1 : m_confirm.nIndex;
417  s << tx << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << dummy_bool;
418  }
419 
420  template<typename Stream>
421  void Unserialize(Stream& s)
422  {
423  Init();
424 
425  std::vector<uint256> dummy_vector1;
426  std::vector<CMerkleTx> dummy_vector2;
427  bool dummy_bool;
428  int serializedIndex;
429  s >> tx >> m_confirm.hashBlock >> dummy_vector1 >> serializedIndex >> dummy_vector2 >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> dummy_bool;
430 
431  /* At serialization/deserialization, an nIndex == -1 means that hashBlock refers to
432  * the earliest block in the chain we know this or any in-wallet ancestor conflicts
433  * with. If nIndex == -1 and hashBlock is ABANDON_HASH, it means transaction is abandoned.
434  * In same context, an nIndex >= 0 refers to a confirmed transaction (if hashBlock set) or
435  * unconfirmed one. Older clients interpret nIndex == -1 as unconfirmed for backward
436  * compatibility (pre-commit 9ac63d6).
437  */
438  if (serializedIndex == -1 && m_confirm.hashBlock == ABANDON_HASH) {
439  setAbandoned();
440  } else if (serializedIndex == -1) {
441  setConflicted();
442  } else if (!m_confirm.hashBlock.IsNull()) {
443  m_confirm.nIndex = serializedIndex;
444  setConfirmed();
445  }
446 
448  nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
449 
450  mapValue.erase("fromaccount");
451  mapValue.erase("spent");
452  mapValue.erase("n");
453  mapValue.erase("timesmart");
454  }
455 
457  {
458  tx = std::move(arg);
459  }
460 
462  void MarkDirty()
463  {
464  m_amounts[DEBIT].Reset();
468  fChangeCached = false;
469  m_is_cache_empty = true;
470  }
471 
473  CAmount GetDebit(const isminefilter& filter) const;
474  CAmount GetCredit(const isminefilter& filter) const;
475  CAmount GetImmatureCredit(bool fUseCache = true) const;
476  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
477  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The
478  // annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid
479  // having to resolve the issue of member access into incomplete type CWallet.
480  CAmount GetAvailableCredit(bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE) const NO_THREAD_SAFETY_ANALYSIS;
481  CAmount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const;
482  CAmount GetChange() const;
483 
484  // Get the marginal bytes if spending the specified output from this transaction
485  int GetSpendSize(unsigned int out, bool use_max_sig = false) const
486  {
487  return CalculateMaximumSignedInputSize(tx->vout[out], pwallet, use_max_sig);
488  }
489 
490  void GetAmounts(std::list<COutputEntry>& listReceived,
491  std::list<COutputEntry>& listSent, CAmount& nFee, const isminefilter& filter) const;
492 
493  bool IsFromMe(const isminefilter& filter) const
494  {
495  return (GetDebit(filter) > 0);
496  }
497 
498  // True if only scriptSigs are different
499  bool IsEquivalentTo(const CWalletTx& tx) const;
500 
501  bool InMempool() const;
502  bool IsTrusted() const;
503 
504  int64_t GetTxTime() const;
505 
506  // Pass this transaction to node for mempool insertion and relay to peers if flag set to true
507  bool SubmitMemoryPoolAndRelay(std::string& err_string, bool relay);
508 
509  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
510  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
511  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
512  // resolve the issue of member access into incomplete type CWallet. Note
513  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
514  // in place.
515  std::set<uint256> GetConflicts() const NO_THREAD_SAFETY_ANALYSIS;
516 
523  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
524  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
525  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
526  // resolve the issue of member access into incomplete type CWallet. Note
527  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
528  // in place.
530  bool IsInMainChain() const { return GetDepthInMainChain() > 0; }
531 
537  int GetBlocksToMaturity() const;
538  bool isAbandoned() const { return m_confirm.status == CWalletTx::ABANDONED; }
540  {
544  m_confirm.nIndex = 0;
545  }
550  bool isConfirmed() const { return m_confirm.status == CWalletTx::CONFIRMED; }
552  const uint256& GetHash() const { return tx->GetHash(); }
553  bool IsCoinBase() const { return tx->IsCoinBase(); }
554  bool IsImmatureCoinBase() const;
555 
556  // Disable copying of CWalletTx objects to prevent bugs where instances get
557  // copied in and out of the mapWallet map, and fields are updated in the
558  // wrong copy.
559  CWalletTx(CWalletTx const &) = delete;
560  void operator=(CWalletTx const &x) = delete;
561 };
562 
563 class COutput
564 {
565 public:
566  const CWalletTx *tx;
567  int i;
568  int nDepth;
569 
572 
575 
577  bool fSolvable;
578 
581 
587  bool fSafe;
588 
589  COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in = false)
590  {
591  tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; fSolvable = fSolvableIn; fSafe = fSafeIn; nInputBytes = -1; use_max_sig = use_max_sig_in;
592  // If known and signable by the given wallet, compute nInputBytes
593  // Failure will keep this value -1
594  if (fSpendable && tx) {
596  }
597  }
598 
599  std::string ToString() const;
600 
601  inline CInputCoin GetInputCoin() const
602  {
603  return CInputCoin(tx->tx, i, nInputBytes);
604  }
605 };
606 
608 {
609  bool use_bnb = true;
610  size_t change_output_size = 0;
611  size_t change_spend_size = 0;
615  size_t tx_noinputs_size = 0;
619 
621  CFeeRate long_term_feerate, CFeeRate discard_feerate, size_t tx_noinputs_size, bool avoid_partial) :
622  use_bnb(use_bnb),
625  m_effective_feerate(effective_feerate),
626  m_long_term_feerate(long_term_feerate),
627  m_discard_feerate(discard_feerate),
629  m_avoid_partial_spends(avoid_partial)
630  {}
632 };
633 
634 class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime
639 {
640 private:
642 
643 
644  bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys = false);
645 
646  std::atomic<bool> fAbortRescan{false};
647  std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
648  std::atomic<int64_t> m_scanning_start{0};
649  std::atomic<double> m_scanning_progress{0};
650  friend class WalletRescanReserver;
651 
653  int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
654 
655  int64_t nNextResend = 0;
657  // Local time that the tip block was received. Used to schedule wallet rebroadcasts.
658  std::atomic<int64_t> m_best_block_time {0};
659 
665  typedef std::multimap<COutPoint, uint256> TxSpends;
666  TxSpends mapTxSpends GUARDED_BY(cs_wallet);
667  void AddToSpends(const COutPoint& outpoint, const uint256& wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
669 
684 
685  /* Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. */
686  void MarkConflicted(const uint256& hashBlock, int conflicting_height, const uint256& hashTx);
687 
688  /* Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed */
690 
691  void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
692 
693  /* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
694  * Should be called with non-zero block_hash and posInBlock if this is for a transaction that is included in a block. */
695  void SyncTransaction(const CTransactionRef& tx, CWalletTx::Confirmation confirm, bool update_tx = true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
696 
697  std::atomic<uint64_t> m_wallet_flags{0};
698 
699  bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
700 
702  void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
703 
705  void UnsetBlankWalletFlag(WalletBatch& batch) override;
706 
709 
711  std::string m_name;
712 
714  std::unique_ptr<WalletDatabase> const m_database;
715 
723  uint256 m_last_block_processed GUARDED_BY(cs_wallet);
724 
725  /* Height of last block processed is used by wallet to know depth of transactions
726  * without relying on Chain interface beyond asynchronous updates. For safety, we
727  * initialize it to -1. Height is a pointer on node's tip and doesn't imply
728  * that the wallet has scanned sequentially all blocks up to this one.
729  */
730  int m_last_block_processed_height GUARDED_BY(cs_wallet) = -1;
731 
732  std::map<OutputType, ScriptPubKeyMan*> m_external_spk_managers;
733  std::map<OutputType, ScriptPubKeyMan*> m_internal_spk_managers;
734 
735  // Indexed by a unique identifier produced by each ScriptPubKeyMan using
736  // ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal structure
737  std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
738 
739  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);
740 
741 public:
742  /*
743  * Main wallet lock.
744  * This lock protects all the fields added by CWallet.
745  */
747 
748  WalletDatabase& GetDatabase() const override
749  {
750  assert(static_cast<bool>(m_database));
751  return *m_database;
752  }
753 
759  bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet,
760  const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool& bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
761 
764  const std::string& GetName() const { return m_name; }
765 
766  typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
768  unsigned int nMasterKeyMaxID = 0;
769 
771  CWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database)
772  : m_chain(chain),
773  m_name(name),
774  m_database(std::move(database))
775  {
776  }
777 
779  {
780  // Should not have slots connected at this point.
781  assert(NotifyUnload.empty());
782  }
783 
784  bool IsCrypted() const;
785  bool IsLocked() const override;
786  bool Lock();
787 
789  bool HaveChain() const { return m_chain ? true : false; }
790 
791  std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
792 
793  typedef std::multimap<int64_t, CWalletTx*> TxItems;
795 
796  int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
798 
799  std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
800  const CAddressBookData* FindAddressBookEntry(const CTxDestination&, bool allow_change = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
801 
802  std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
803 
805  std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
806 
808  interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
809 
811  bool IsTrusted(const CWalletTx& wtx, std::set<uint256>& trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
812 
814  bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return IsFeatureSupported(nWalletVersion, wf); }
815 
819  void AvailableCoins(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 EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
820 
824  std::map<CTxDestination, std::vector<COutput>> ListCoins() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
825 
830 
837  bool SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins,
838  std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CoinSelectionParams& coin_selection_params, bool& bnb_used) const;
839 
840  bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
841 
842  // Whether this or any known UTXO with the same single key has been spent.
843  bool IsSpentKey(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
844  void SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
845 
846  std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool separate_coins, const CFeeRate& effective_feerate, const CFeeRate& long_term_feerate, const CoinEligibilityFilter& filter, bool positive_only) const;
847 
850 
851  bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
855  void ListLockedCoins(std::vector<COutPoint>& vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
856 
857  /*
858  * Rescan abort properties
859  */
860  void AbortRescan() { fAbortRescan = true; }
861  bool IsAbortingRescan() const { return fAbortRescan; }
862  bool IsScanning() const { return fScanningWallet; }
863  int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
864  double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
865 
868 
869  bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; return true; }
870 
875  bool AddDestData(WalletBatch& batch, const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
877  bool EraseDestData(WalletBatch& batch, const CTxDestination& dest, const std::string& key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
879  void LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
881  bool GetDestData(const CTxDestination& dest, const std::string& key, std::string* value) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
883  std::vector<std::string> GetDestValues(const std::string& prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
884 
886  int64_t nRelockTime GUARDED_BY(cs_wallet){0};
887 
888  // Used to prevent concurrent calls to walletpassphrase RPC.
890  bool Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys = false);
891  bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
892  bool EncryptWallet(const SecureString& strWalletPassphrase);
893 
894  void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
895  unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
896 
903 
904  void MarkDirty();
905 
912  using UpdateWalletTxFn = std::function<bool(CWalletTx& wtx, bool new_tx)>;
913 
914  CWalletTx* AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation& confirm, const UpdateWalletTxFn& update_wtx=nullptr, bool fFlushOnClose=true);
915  bool LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
916  void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override;
917  void blockConnected(const CBlock& block, int height) override;
918  void blockDisconnected(const CBlock& block, int height) override;
919  void updatedBlockTip() override;
920  int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
921 
922  struct ScanResult {
923  enum { SUCCESS, FAILURE, USER_ABORT } status = SUCCESS;
924 
929  std::optional<int> last_scanned_height;
930 
936  };
937  ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate);
938  void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override;
941  struct Balance {
942  CAmount m_mine_trusted{0};
943  CAmount m_mine_untrusted_pending{0};
944  CAmount m_mine_immature{0};
945  CAmount m_watchonly_trusted{0};
946  CAmount m_watchonly_untrusted_pending{0};
947  CAmount m_watchonly_immature{0};
948  };
949  Balance GetBalance(int min_depth = 0, bool avoid_reuse = true) const;
950  CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
951 
952  OutputType TransactionChangeType(const std::optional<OutputType>& change_type, const std::vector<CRecipient>& vecSend) const;
953 
958  bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl);
959  // Fetch the inputs and sign with SIGHASH_ALL.
961  // Sign the tx given the input coins and sighash.
962  bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, std::string>& input_errors) const;
963  SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const;
964 
979  bool& complete,
980  int sighash_type = 1 /* SIGHASH_ALL */,
981  bool sign = true,
982  bool bip32derivs = true,
983  size_t* n_signed = nullptr) const;
984 
990  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);
1000  void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm);
1001 
1002  bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts, bool use_max_sig = false) const
1003  {
1004  std::vector<CTxOut> v_txouts(txouts.size());
1005  std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
1006  return DummySignTx(txNew, v_txouts, use_max_sig);
1007  }
1008  bool DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut> &txouts, bool use_max_sig = false) const;
1009  bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig = false) const;
1010 
1011  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1012  bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1013  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);
1014  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);
1015 
1022 
1037  std::optional<OutputType> m_default_change_type{};
1040 
1042  bool TopUpKeyPool(unsigned int kpSize = 0);
1043 
1044  int64_t GetOldestKeyPoolTime() const;
1045 
1047  std::map<CTxDestination, CAmount> GetAddressBalances() const;
1048 
1049  std::set<CTxDestination> GetLabelAddresses(const std::string& label) const;
1050 
1055  void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1056 
1057  bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error);
1058  bool GetNewChangeDestination(const OutputType type, CTxDestination& dest, std::string& error);
1059 
1067  CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
1069  CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
1070  bool IsChange(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1071  bool IsChange(const CScript& script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1073  bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1075  bool IsFromMe(const CTransaction& tx) const;
1076  CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
1078  bool IsAllFromMe(const CTransaction& tx, const isminefilter& filter) const;
1079  CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
1080  CAmount GetChange(const CTransaction& tx) const;
1081  void chainStateFlushed(const CBlockLocator& loc) override;
1082 
1083  DBErrors LoadWallet(bool& fFirstRunRet);
1084  DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1085 
1086  bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
1087 
1088  bool DelAddressBook(const CTxDestination& address);
1089 
1090  unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1091 
1093  void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr) override;
1094 
1096  int GetVersion() const { LOCK(cs_wallet); return nWalletVersion; }
1097 
1099  std::set<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1100 
1102  bool HasWalletSpend(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1103 
1105  void Flush();
1106 
1108  void Close();
1109 
1111  boost::signals2::signal<void ()> NotifyUnload;
1112 
1117  boost::signals2::signal<void (CWallet *wallet, const CTxDestination
1118  &address, const std::string &label, bool isMine,
1119  const std::string &purpose,
1121 
1126  boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx,
1128 
1130  boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
1131 
1133  boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
1134 
1136  boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
1137 
1142  boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
1143 
1147  void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
1148 
1150  bool TransactionCanBeAbandoned(const uint256& hashTx) const;
1151 
1152  /* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
1153  bool AbandonTransaction(const uint256& hashTx);
1154 
1156  bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
1157 
1158  /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
1159  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);
1160 
1165  void postInitProcess();
1166 
1167  bool BackupWallet(const std::string& strDest) const;
1168 
1169  /* Returns true if HD is enabled */
1170  bool IsHDEnabled() const;
1171 
1172  /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
1173  bool CanGetAddresses(bool internal = false) const;
1174 
1181  void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(::cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_wallet);
1182 
1184  void SetWalletFlag(uint64_t flags);
1185 
1187  void UnsetWalletFlag(uint64_t flag);
1188 
1190  bool IsWalletFlagSet(uint64_t flag) const override;
1191 
1194  bool AddWalletFlags(uint64_t flags);
1196  bool LoadWalletFlags(uint64_t flags);
1197 
1199  bool IsLegacy() const;
1200 
1202  const std::string GetDisplayName() const override {
1203  std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
1204  return strprintf("[%s]", wallet_name);
1205  };
1206 
1208  template<typename... Params>
1209  void WalletLogPrintf(std::string fmt, Params... parameters) const {
1210  LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
1211  };
1212 
1214  bool UpgradeWallet(int version, bilingual_str& error);
1215 
1217  std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
1218 
1220  std::set<ScriptPubKeyMan*> GetAllScriptPubKeyMans() const;
1221 
1223  ScriptPubKeyMan* GetScriptPubKeyMan(const OutputType& type, bool internal) const;
1224 
1226  ScriptPubKeyMan* GetScriptPubKeyMan(const CScript& script) const;
1228  ScriptPubKeyMan* GetScriptPubKeyMan(const uint256& id) const;
1229 
1231  std::set<ScriptPubKeyMan*> GetScriptPubKeyMans(const CScript& script, SignatureData& sigdata) const;
1232 
1234  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const;
1235  std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script, SignatureData& sigdata) const;
1236 
1240 
1243 
1244  const CKeyingMaterial& GetEncryptionKey() const override;
1245  bool HasEncryptionKeys() const override;
1246 
1249  {
1251  assert(m_last_block_processed_height >= 0);
1252  return m_last_block_processed_height;
1253  };
1255  {
1257  assert(m_last_block_processed_height >= 0);
1258  return m_last_block_processed;
1259  }
1262  {
1264  m_last_block_processed_height = block_height;
1265  m_last_block_processed = block_hash;
1266  };
1267 
1270 
1273 
1278  void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
1279 
1284  void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
1285 
1288 
1291 
1293  ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal);
1294 };
1295 
1300 void MaybeResendWalletTxs();
1301 
1304 {
1305 private:
1308 public:
1310 
1311  bool reserve()
1312  {
1314  if (m_wallet.fScanningWallet.exchange(true)) {
1315  return false;
1316  }
1317  m_wallet.m_scanning_start = GetTimeMillis();
1318  m_wallet.m_scanning_progress = 0;
1319  m_could_reserve = true;
1320  return true;
1321  }
1322 
1323  bool isReserved() const
1324  {
1325  return (m_could_reserve && m_wallet.fScanningWallet);
1326  }
1327 
1329  {
1330  if (m_could_reserve) {
1331  m_wallet.fScanningWallet = false;
1332  }
1333  }
1334 };
1335 
1336 // Calculate the size of the transaction assuming all signatures are max size
1337 // Use DummySignatureCreator, which inserts 71 byte signatures everywhere.
1338 // NOTE: this requires that all inputs must be in mapWallet (eg the tx should
1339 // be IsAllFromMe).
1340 std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig = false) EXCLUSIVE_LOCKS_REQUIRED(wallet->cs_wallet);
1341 std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, bool use_max_sig = false);
1342 
1344 bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
1345 
1347 bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
1348 
1349 #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:73
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:935
CWallet::GetKeyPoolSize
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3332
DatabaseOptions
Definition: db.h:203
CTxIn
An input of a transaction.
Definition: transaction.h:65
interfaces
Definition: dummywallet.cpp:10
atoi64
int64_t atoi64(const std::string &str)
Definition: strencodings.cpp:440
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:1209
COutput::use_max_sig
bool use_max_sig
Whether to use the maximum sized, 72 byte signature when calculating the size of the input spend.
Definition: wallet.h:580
CWallet::m_discard_rate
CFeeRate m_discard_rate
Definition: wallet.h:1028
CWallet::AddDestData
bool AddDestData(WalletBatch &batch, const CTxDestination &dest, const std::string &key, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Adds a destination data tuple to the store, and saves it to disk When adding new fields,...
Definition: wallet.cpp:3770
CWallet::ComputeTimeSmart
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
Definition: wallet.cpp:3731
CWallet::ConnectScriptPubKeyManNotifiers
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition: wallet.cpp:4491
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)
Definition: wallet.cpp:2758
crypter.h
ReserveDestination::fInternal
bool fInternal
Whether this is from the internal (change output) keypool.
Definition: wallet.h:164
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:771
CoinSelectionParams::change_output_size
size_t change_output_size
Definition: wallet.h:610
CWallet::GetActiveScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition: wallet.cpp:4369
CWalletTx::GetBlocksToMaturity
int GetBlocksToMaturity() const
Definition: wallet.cpp:4225
feerate.h
CRecipient::fSubtractFeeFromAmount
bool fSubtractFeeFromAmount
Definition: wallet.h:215
CWalletTx::GetChange
CAmount GetChange() const
Definition: wallet.cpp:2042
CWalletTx::CONFLICTED
@ CONFLICTED
Definition: wallet.h:382
CWallet::UnlockCoin
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3622
CWallet::nMasterKeyMaxID
unsigned int nMasterKeyMaxID
Definition: wallet.h:768
CWallet::m_signal_rbf
bool m_signal_rbf
Definition: wallet.h:1019
CAddressBookData::IsChange
bool IsChange() const
Definition: wallet.h:203
CWallet::m_external_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Definition: wallet.h:732
CWalletTx::IsEquivalentTo
bool IsEquivalentTo(const CWalletTx &tx) const
Definition: wallet.cpp:2095
OutputType
OutputType
Definition: outputtype.h:17
ToString
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:79
ui_change_type.h
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: wallet.cpp:2336
CWallet::GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3449
CWallet::MarkConflicted
void MarkConflicted(const uint256 &hashBlock, int conflicting_height, const uint256 &hashTx)
Definition: wallet.cpp:1130
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:653
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:1027
DatabaseStatus
DatabaseStatus
Definition: db.h:212
CWallet::ResendWalletTransactions
void ResendWalletTransactions()
Definition: wallet.cpp:2113
ReserveDestination::~ReserveDestination
~ReserveDestination()
Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool.
Definition: wallet.h:176
CWalletTx::setConflicted
void setConflicted()
Definition: wallet.h:547
CWallet::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
Definition: wallet.cpp:4433
CWallet::MasterKeyMap
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition: wallet.h:766
OutputGroup
Definition: coinselection.h:72
CoinSelectionParams::use_bnb
bool use_bnb
Definition: wallet.h:609
WalletRescanReserver::WalletRescanReserver
WalletRescanReserver(CWallet &w)
Definition: wallet.h:1309
CWallet::blockDisconnected
void blockDisconnected(const CBlock &block, int height) override
Definition: wallet.cpp:1253
isminefilter
uint8_t isminefilter
Definition: wallet.h:36
CWallet::m_confirm_target
unsigned int m_confirm_target
Definition: wallet.h:1017
CWallet::IsAbortingRescan
bool IsAbortingRescan() const
Definition: wallet.h:861
CWallet::IsFromMe
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
Definition: wallet.cpp:1390
CWallet::ReacceptWalletTransactions
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1877
CWallet::m_scanning_start
std::atomic< int64_t > m_scanning_start
Definition: wallet.h:648
flags
int flags
Definition: bitcoin-tx.cpp:512
CWalletTx::fTimeReceivedIsTxTime
unsigned int fTimeReceivedIsTxTime
Definition: wallet.h:311
CWallet::GetCredit
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
Definition: wallet.cpp:1338
CWallet::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const
Definition: wallet.cpp:3387
CWalletTx::AVAILABLE_CREDIT
@ AVAILABLE_CREDIT
Definition: wallet.h:333
WALLET_FLAG_CAVEATS
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:48
COutput::COutput
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in=false)
Definition: wallet.h:589
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:4622
CWallet::GetAvailableBalance
CAmount GetAvailableBalance(const CCoinControl *coinControl=nullptr) const
Definition: wallet.cpp:2194
CWallet::m_wallet_flags
std::atomic< uint64_t > m_wallet_flags
Definition: wallet.h:697
CWallet::GetLastBlockHeight
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
Definition: wallet.h:1248
CoinSelectionParams::CoinSelectionParams
CoinSelectionParams(bool use_bnb, size_t change_output_size, size_t change_spend_size, CFeeRate effective_feerate, CFeeRate long_term_feerate, CFeeRate discard_feerate, size_t tx_noinputs_size, bool avoid_partial)
Definition: wallet.h:620
CWallet::GetBalance
Balance GetBalance(int min_depth=0, bool avoid_reuse=true) const
Definition: wallet.cpp:2165
CWalletTx::Serialize
void Serialize(Stream &s) const
Definition: wallet.h:402
CWallet::IsWalletFlagSet
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
Definition: wallet.cpp:1503
CWallet::CanSupportFeature
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
Definition: wallet.h:814
string.h
CWalletTx::mapValue
mapValue_t mapValue
Key/value map with information about the transaction.
Definition: wallet.h:309
CWallet::LoadDescriptorScriptPubKeyMan
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition: wallet.cpp:4499
CWallet::IsChange
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1346
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:87
GetWallet
std::shared_ptr< CWallet > GetWallet(const std::string &name)
Definition: wallet.cpp:142
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:79
outputtype.h
CWallet::ScanResult::last_scanned_height
std::optional< int > last_scanned_height
Definition: wallet.h:929
CWallet::ScanResult::last_scanned_block
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition: wallet.h:928
CWalletTx::ABANDONED
@ ABANDONED
Definition: wallet.h:383
CWalletTx::GetAvailableCredit
CAmount GetAvailableCredit(bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) const NO_THREAD_SAFETY_ANALYSIS
Definition: wallet.cpp:1996
CKeyingMaterial
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
Definition: crypter.h:61
CWalletTx::IsImmatureCoinBase
bool IsImmatureCoinBase() const
Definition: wallet.cpp:4234
CCoinControl
Coin Control Features.
Definition: coincontrol.h:23
WriteOrderPos
static void WriteOrderPos(const int64_t &nOrderPos, mapValue_t &mapValue)
Definition: wallet.h:232
validationinterface.h
CWalletTx::setConfirmed
void setConfirmed()
Definition: wallet.h:551
MakeWalletDatabase
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Definition: wallet.cpp:3820
CWalletTx::Init
void Init()
Definition: wallet.h:354
CWalletTx::CWalletTx
CWalletTx(const CWallet *wallet, CTransactionRef arg)
Definition: wallet.h:347
handler.h
CWallet::GetEncryptionKey
const CKeyingMaterial & GetEncryptionKey() const override
Definition: wallet.cpp:4481
CWallet::chain
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:808
WALLET_FLAG_EXTERNAL_SIGNER
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
Definition: walletutil.h:65
ReserveDestination::address
CTxDestination address
The destination.
Definition: wallet.h:162
CWalletTx::setUnconfirmed
void setUnconfirmed()
Definition: wallet.h:549
COutput::nInputBytes
int nInputBytes
Pre-computed estimated size of this output as a fully-signed input in a transaction.
Definition: wallet.h:571
CWallet::m_scanning_progress
std::atomic< double > m_scanning_progress
Definition: wallet.h:649
CWallet::IsCrypted
bool IsCrypted() const
Definition: wallet.cpp:4326
CWallet::NotifyUnload
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:1111
CWallet::m_max_aps_fee
CAmount m_max_aps_fee
note: this is absolute fee, not fee rate
Definition: wallet.h:1029
CWalletTx::AmountType
AmountType
Definition: wallet.h:333
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
CWallet::FindNonChangeParentOutput
const CTxOut & FindNonChangeParentOutput(const CTransaction &tx, int output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Find non-change parent output.
Definition: wallet.cpp:2377
ReserveDestination::pwallet
const CWallet *const pwallet
The wallet to reserve from.
Definition: wallet.h:155
CWalletTx::GetDepthInMainChain
int GetDepthInMainChain() const NO_THREAD_SAFETY_ANALYSIS
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
Definition: wallet.cpp:4216
CWallet::IsSpentKey
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:833
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:797
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:1774
CWallet::AbortRescan
void AbortRescan()
Definition: wallet.h:860
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:778
CWallet::GetChange
CAmount GetChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1373
AnnotatedMixin< std::recursive_mutex >
CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:1130
ReserveDestination::nIndex
int64_t nIndex
The index of the address's key in the keypool.
Definition: wallet.h:160
CWallet::EraseDestData
bool EraseDestData(WalletBatch &batch, const CTxDestination &dest, const std::string &key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Erases a destination data tuple in the store and on disk.
Definition: wallet.cpp:3779
CWalletTx::isConfirmed
bool isConfirmed() const
Definition: wallet.h:550
CWalletTx::m_confirm
Confirmation m_confirm
Definition: wallet.h:399
wallet
Definition: interfaces.cpp:47
CWallet::AvailableCoins
void AvailableCoins(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 EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
populate vCoins with vector of available COutputs.
Definition: wallet.cpp:2209
WalletDatabase
An instance of this class represents one database.
Definition: db.h:103
WalletRescanReserver::reserve
bool reserve()
Definition: wallet.h:1311
CWallet::AddToWallet
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
Definition: wallet.cpp:868
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:21
CWallet::GetBroadcastTransactions
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
Definition: wallet.h:1145
ReserveDestination
A wrapper to reserve an address from a wallet.
Definition: wallet.h:151
CWalletTx::m_is_cache_empty
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
Definition: wallet.h:342
CWalletTx::Unserialize
void Unserialize(Stream &s)
Definition: wallet.h:421
LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:257
CoinEligibilityFilter
Definition: coinselection.h:59
CWallet::blockConnected
void blockConnected(const CBlock &block, int height) override
Definition: wallet.cpp:1240
chain.h
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
CWalletTx::GetSpendSize
int GetSpendSize(unsigned int out, bool use_max_sig=false) const
Definition: wallet.h:485
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:131
CWalletTx::Confirmation::block_height
int block_height
Definition: wallet.h:393
CWallet::AddToSpends
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:574
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:110
CWallet::GetNewChangeDestination
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
Definition: wallet.cpp:3372
CWallet::UnsetBlankWalletFlag
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
Definition: wallet.cpp:1498
CWallet::IsAllFromMe
bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const
Returns whether all of the inputs match the filter.
Definition: wallet.cpp:1407
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:99
CWallet::NotifyStatusChanged
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: wallet.h:1142
CWallet::IsTrusted
bool IsTrusted(const CWalletTx &wtx, std::set< uint256 > &trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2063
SigningResult
SigningResult
Definition: message.h:42
CWalletTx::nChangeCached
CAmount nChangeCached
Definition: wallet.h:345
CWalletTx::nTimeSmart
unsigned int nTimeSmart
Stable timestamp that never changes, and reflects the order a transaction was added to the wallet.
Definition: wallet.h:322
CWallet::SignMessage
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Definition: wallet.cpp:2606
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
CWalletTx::IsTrusted
bool IsTrusted() const
Definition: wallet.cpp:2056
scriptpubkeyman.h
CWallet::Balance
Definition: wallet.h:941
tinyformat.h
CWallet::ZapSelectTx
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3234
CWalletTx::SetTx
void SetTx(CTransactionRef arg)
Definition: wallet.h:456
COutput::fSolvable
bool fSolvable
Whether we know how to spend this output, ignoring the lack of keys.
Definition: wallet.h:577
CWallet::GetVersion
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition: wallet.h:1096
prefix
const char * prefix
Definition: rest.cpp:682
CWallet::SetAddressBook
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:3285
WalletRescanReserver::m_wallet
CWallet & m_wallet
Definition: wallet.h:1306
LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: wallet.h:43
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:1202
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:495
DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:517
CWallet::MarkDirty
void MarkDirty()
Definition: wallet.cpp:769
CWallet::IsLockedCoin
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3634
COutput::GetInputCoin
CInputCoin GetInputCoin() const
Definition: wallet.h:601
CWallet::DelAddressBook
bool DelAddressBook(const CTxDestination &address)
Definition: wallet.cpp:3291
strencodings.h
CWallet::TransactionCanBeAbandoned
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
Definition: wallet.cpp:1059
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:4331
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:502
CWalletTx::nTimeReceived
unsigned int nTimeReceived
time received by this node
Definition: wallet.h:312
external_signer.h
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:1039
NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:51
COutput::ToString
std::string ToString() const
Definition: wallet.cpp:352
CMerkleTx
Legacy class used for deserializing vtxPrev for backwards compatibility.
Definition: wallet.h:251
CWalletTx::isAbandoned
bool isAbandoned() const
Definition: wallet.h:538
CWallet::UpgradeKeyMetadata
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: wallet.cpp:366
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:214
CWalletTx::Confirmation::status
Status status
Definition: wallet.h:392
CWallet::ScanningDuration
int64_t ScanningDuration() const
Definition: wallet.h:863
CWallet::LoadWalletFlags
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
Definition: wallet.cpp:1508
CWallet::NotifyTransactionChanged
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:1127
SignatureData
Definition: sign.h:60
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: wallet.cpp:2618
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:3165
CWalletTx::GetCredit
CAmount GetCredit(const isminefilter &filter) const
Definition: wallet.cpp:1970
CWalletTx::nOrderPos
int64_t nOrderPos
position in ordered transaction list
Definition: wallet.h:329
CAddressBookData::m_change
bool m_change
Definition: wallet.h:193
CTxOut
An output of a transaction.
Definition: transaction.h:128
CWallet::GetAddressBalances
std::map< CTxDestination, CAmount > GetAddressBalances() const
Definition: wallet.cpp:3411
CoinSelectionParams::m_long_term_feerate
CFeeRate m_long_term_feerate
Definition: wallet.h:613
CWallet::m_best_block_time
std::atomic< int64_t > m_best_block_time
Definition: wallet.h:658
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:1605
CWallet::fScanningWallet
std::atomic< bool > fScanningWallet
Definition: wallet.h:647
CWallet::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1585
CWalletTx::fChangeCached
bool fChangeCached
Definition: wallet.h:343
CWallet::m_name
std::string m_name
Wallet name: relative directory name or "" for default wallet.
Definition: wallet.h:711
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:3786
message.h
CWallet::UnsetWalletFlag
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
Definition: wallet.cpp:1484
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:665
CWalletTx::ABANDON_HASH
static constexpr const uint256 & ABANDON_HASH
Constant used in hashBlock to indicate tx has been abandoned, only used at serialization/deserializat...
Definition: wallet.h:281
CWallet::m_default_address_type
OutputType m_default_address_type
Definition: wallet.h:1030
CWallet::m_spend_zero_conf_change
bool m_spend_zero_conf_change
Definition: wallet.h:1018
COutputEntry::vout
int vout
Definition: wallet.h:243
WALLET_INCREMENTAL_RELAY_FEE
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
Definition: wallet.h:83
CWallet::updatedBlockTip
void updatedBlockTip() override
Definition: wallet.cpp:1268
CWallet::SetupDescriptorScriptPubKeyMans
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition: wallet.cpp:4514
CWallet::UnsetWalletFlagWithDB
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
Definition: wallet.cpp:1490
DEFAULT_TRANSACTION_MAXFEE
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition: wallet.h:95
FeeEstimateMode
FeeEstimateMode
Definition: feerate.h:18
CWalletTx::tx
CTransactionRef tx
Definition: wallet.h:369
HIGH_APS_FEE
constexpr CAmount HIGH_APS_FEE
discourage APS fee higher than this amount
Definition: wallet.h:81
WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:41
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, bool &bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Select a set of coins such that nValueRet >= nTargetValue and at least all coins from coinControl are...
Definition: wallet.cpp:2426
CWalletTx::GetDebit
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
Definition: wallet.cpp:1955
CAddressBookData
Address book data.
Definition: wallet.h:190
COutputEntry::destination
CTxDestination destination
Definition: wallet.h:241
CWallet::nNextResend
int64_t nNextResend
Definition: wallet.h:655
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:3844
DEFAULT_WALLET_RBF
static const bool DEFAULT_WALLET_RBF
-walletrbf default
Definition: wallet.h:91
MUTABLE_WALLET_FLAGS
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:122
ReadOrderPos
static void ReadOrderPos(int64_t &nOrderPos, mapValue_t &mapValue)
Definition: wallet.h:221
CoinSelectionParams
Definition: wallet.h:607
CWallet::wtxOrdered
TxItems wtxOrdered
Definition: wallet.h:794
mapValue_t
std::map< std::string, std::string > mapValue_t
Definition: wallet.h:218
CWalletTx::pwallet
const CWallet *const pwallet
Definition: wallet.h:276
CWallet::DummySignInput
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
Definition: wallet.cpp:1540
CWallet::m_chain_notifications_handler
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition: wallet.h:805
COutputEntry
Definition: wallet.h:239
CWalletTx::isUnconfirmed
bool isUnconfirmed() const
Definition: wallet.h:548
CAddressBookData::SetLabel
void SetLabel(const std::string &label)
Definition: wallet.h:205
CWallet::LoadWallet
DBErrors LoadWallet(bool &fFirstRunRet)
Definition: wallet.cpp:3205
LogPrintf
#define LogPrintf(...)
Definition: logging.h:183
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:1303
CWallet::AddActiveScriptPubKeyMan
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:4580
CWallet::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:1133
CWallet::SetMinVersion
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
Definition: wallet.cpp:456
CWallet::IsHDEnabled
bool IsHDEnabled() const
Definition: wallet.cpp:1453
CWallet::~CWallet
~CWallet()
Definition: wallet.h:778
WalletRescanReserver::m_could_reserve
bool m_could_reserve
Definition: wallet.h:1307
CWallet::fBroadcastTransactions
bool fBroadcastTransactions
Definition: wallet.h:656
CWallet::GetDatabase
WalletDatabase & GetDatabase() const override
Definition: wallet.h:748
CalculateMaximumSignedInputSize
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, bool use_max_sig=false)
Definition: wallet.cpp:1657
CWallet::NotifyAddressBookChanged
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:1120
CWallet::transactionAddedToMempool
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Definition: wallet.cpp:1193
CWallet::SyncTransaction
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1182
CWallet::GetName
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:764
AssertLockHeld
#define AssertLockHeld(cs)
Definition: sync.h:81
CWallet::mapMasterKeys
MasterKeyMap mapMasterKeys
Definition: wallet.h:767
CWallet::ReorderTransactions
DBErrors ReorderTransactions()
Definition: wallet.cpp:700
CWallet::fAbortRescan
std::atomic< bool > fAbortRescan
Definition: wallet.h:646
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:1261
CWallet::UnlockAllCoins
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3628
CWalletTx::vOrderForm
std::vector< std::pair< std::string, std::string > > vOrderForm
Definition: wallet.h:310
uint256
256-bit opaque blob.
Definition: uint256.h:124
CWallet::ScanResult
Definition: wallet.h:922
CWallet::DummySignTx
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
Definition: wallet.h:1002
CWallet::AbandonTransaction
bool AbandonTransaction(const uint256 &hashTx)
Definition: wallet.cpp:1076
CWalletTx::CONFIRMED
@ CONFIRMED
Definition: wallet.h:381
CWalletTx::Confirmation::Confirmation
Confirmation(Status s=UNCONFIRMED, int b=0, uint256 h=uint256(), int i=0)
Definition: wallet.h:396
CWalletTx::Confirmation
Definition: wallet.h:391
CWallet::UpgradeWallet
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
Definition: wallet.cpp:4151
CWallet::GetDescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition: wallet.cpp:4609
CWalletTx::GetTxTime
int64_t GetTxTime() const
Definition: wallet.cpp:1532
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
CWalletTx::Confirmation::hashBlock
uint256 hashBlock
Definition: wallet.h:394
CWallet::GetLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition: wallet.cpp:4449
CWallet::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3320
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:3397
COutput::fSpendable
bool fSpendable
Whether we have the private keys to spend this output.
Definition: wallet.h:574
COutput::fSafe
bool fSafe
Whether this output is considered safe to spend.
Definition: wallet.h:587
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:59
CWallet::ListLockedCoins
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3642
CoinSelectionParams::change_spend_size
size_t change_spend_size
Definition: wallet.h:611
COutput::nDepth
int nDepth
Definition: wallet.h:568
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:1300
CWallet::TxItems
std::multimap< int64_t, CWalletTx * > TxItems
Definition: wallet.h:793
IsFeatureSupported
bool IsFeatureSupported(int wallet_version, int feature_version)
Definition: walletutil.cpp:32
CAddressBookData::CAddressBookData
CAddressBookData()
Definition: wallet.h:198
CoinSelectionParams::tx_noinputs_size
size_t tx_noinputs_size
Definition: wallet.h:615
CWalletTx::InMempool
bool InMempool() const
Definition: wallet.cpp:2051
CInputCoin
Definition: coinselection.h:18
CWallet::SetupLegacyScriptPubKeyMan
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition: wallet.cpp:4467
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:472
CoinSelectionParams::m_subtract_fee_outputs
bool m_subtract_fee_outputs
Indicate that we are subtracting the fee from outputs.
Definition: wallet.h:617
CWalletTx::GetConflicts
std::set< uint256 > GetConflicts() const NO_THREAD_SAFETY_ANALYSIS
Definition: wallet.cpp:1933
WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition: walletutil.h:47
name
const char * name
Definition: rest.cpp:43
CWallet::EncryptWallet
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:598
CRecipient::scriptPubKey
CScript scriptPubKey
Definition: wallet.h:213
WalletRescanReserver::~WalletRescanReserver
~WalletRescanReserver()
Definition: wallet.h:1328
CWalletTx::GetImmatureCredit
CAmount GetImmatureCredit(bool fUseCache=true) const
Definition: wallet.cpp:1987
ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: ismine.h:42
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:733
COutput::tx
const CWalletTx * tx
Definition: wallet.h:566
PKHash
Definition: standard.h:140
UnloadWallet
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:182
CWalletTx::Confirmation::nIndex
int nIndex
Definition: wallet.h:395
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:62
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
ReserveDestination::type
const OutputType type
Definition: wallet.h:158
CWalletTx::setAbandoned
void setAbandoned()
Definition: wallet.h:539
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:714
CAddressBookData::purpose
std::string purpose
Definition: wallet.h:196
CWallet::transactionRemovedFromMempool
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Definition: wallet.cpp:1203
DEFAULT_SPEND_ZEROCONF_CHANGE
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:85
CalculateMaximumSignedTxSize
std::pair< int64_t, int64_t > CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig=false) EXCLUSIVE_LOCKS_REQUIRED(wallet -> cs_wallet)
Definition: wallet.cpp:1629
base_blob::IsNull
bool IsNull() const
Definition: uint256.h:31
CWalletTx::GetImmatureWatchOnlyCredit
CAmount GetImmatureWatchOnlyCredit(const bool fUseCache=true) const
Definition: wallet.cpp:2033
CWallet::SelectCoinsMinConf
bool SelectCoinsMinConf(const CAmount &nTargetValue, const CoinEligibilityFilter &eligibility_filter, std::vector< COutput > coins, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CoinSelectionParams &coin_selection_params, bool &bnb_used) const
Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is st...
Definition: wallet.cpp:2395
CWalletTx::m_it_wtxOrdered
std::multimap< int64_t, CWalletTx * >::const_iterator m_it_wtxOrdered
Definition: wallet.h:330
LOCKS_EXCLUDED
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
MaybeResendWalletTxs
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
Definition: wallet.cpp:2151
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:3265
CWalletTx::IsCoinBase
bool IsCoinBase() const
Definition: wallet.h:553
CWalletTx::IsInMainChain
bool IsInMainChain() const
Definition: wallet.h:530
CWalletTx::CREDIT
@ CREDIT
Definition: wallet.h:333
CWallet::GetLabelAddresses
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const
Definition: wallet.cpp:3542
CWallet::TopUpKeyPool
bool TopUpKeyPool(unsigned int kpSize=0)
Definition: wallet.cpp:3343
CWallet::IsScanning
bool IsScanning() const
Definition: wallet.h:862
CWallet::postInitProcess
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
Definition: wallet.cpp:4184
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:1015
CAddressBookData::destdata
StringMap destdata
Definition: wallet.h:201
KNOWN_WALLET_FLAGS
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition: wallet.h:114
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:555
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
CWallet::BackupWallet
bool BackupWallet(const std::string &strDest) const
Definition: wallet.cpp:4196
CWallet::LockCoin
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3616
CWalletTx::isConflicted
bool isConflicted() const
Definition: wallet.h:546
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:391
ReserveDestination::GetReservedDestination
bool GetReservedDestination(CTxDestination &pubkey, bool internal)
Reserve an address.
Definition: wallet.cpp:3557
CWallet::m_pay_tx_fee
CFeeRate m_pay_tx_fee
Definition: wallet.h:1016
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:112
CWallet::Lock
bool Lock()
Definition: wallet.cpp:4340
DEFAULT_PAY_TX_FEE
constexpr CAmount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:65
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:638
CWalletTx::GetHash
const uint256 & GetHash() const
Definition: wallet.h:552
AddWallet
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:98
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:273
CAddressBookData::m_label
std::string m_label
Definition: wallet.h:194
ReserveDestination::m_spk_man
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called.
Definition: wallet.h:157
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: wallet.cpp:3130
m_wallet
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:498
CWallet::IsMine
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1322
CWallet::m_spk_managers
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
Definition: wallet.h:737
CWallet::GetAllScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
Definition: wallet.cpp:4383
CWalletTx::Status
Status
Definition: wallet.h:379
COutputEntry::amount
CAmount amount
Definition: wallet.h:242
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:1020
DEFAULT_WALLETBROADCAST
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:92
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:538
CWallet::HasEncryptionKeys
bool HasEncryptionKeys() const override
Definition: wallet.cpp:4486
GetWallets
std::vector< std::shared_ptr< CWallet > > GetWallets()
Definition: wallet.cpp:136
CWallet::IsLegacy
bool IsLegacy() const
Determine if we are a legacy wallet.
Definition: wallet.cpp:4600
CWalletTx::GetCachableAmount
CAmount GetCachableAmount(AmountType type, const isminefilter &filter, bool recalculate=false) const
Definition: wallet.cpp:1945
CWallet::IncOrderPosNext
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
Definition: wallet.cpp:757
ReserveDestination::operator=
ReserveDestination & operator=(const ReserveDestination &)=delete
CWallet::GetWalletTx
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:357
CoinSelectionParams::m_effective_feerate
CFeeRate m_effective_feerate
Definition: wallet.h:612
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:212
CWallet::cs_wallet
RecursiveMutex cs_wallet
Definition: wallet.h:746
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:813
CoinSelectionParams::m_discard_feerate
CFeeRate m_discard_feerate
Definition: wallet.h:614
CWalletTx::fFromMe
bool fFromMe
From me flag is set to 1 for transactions that were created by the wallet on this bitcoin node,...
Definition: wallet.h:328
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:97
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:1731
ReserveDestination::ReserveDestination
ReserveDestination(CWallet *pwallet, OutputType type)
Construct a ReserveDestination object. This does NOT reserve an address yet.
Definition: wallet.h:168
CWalletTx::fInMempool
bool fInMempool
Definition: wallet.h:344
CachableAmount::Reset
void Reset()
Definition: ismine.h:59
CWalletTx::MarkDirty
void MarkDirty()
make sure balances are recalculated
Definition: wallet.h:462
CWallet::GetScriptPubKeyMan
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition: wallet.cpp:4392
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:1520
CWalletTx::operator=
void operator=(CWalletTx const &x)=delete
CWallet::UpdateWalletTxFn
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
Definition: wallet.h:912
CWalletTx::IMMATURE_CREDIT
@ IMMATURE_CREDIT
Definition: wallet.h:333
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:2556
WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:72
CachableAmount
Cachable amount subdivided into watchonly and spendable parts.
Definition: ismine.h:54
COutput::i
int i
Definition: wallet.h:567
CWallet::GetDestData
bool GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Look up a destination data tuple in the store, return true if found false otherwise.
Definition: wallet.cpp:3791
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:69
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
coin_selection_params
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), CFeeRate(0), CFeeRate(0), 0, false)
CWalletTx::DEBIT
@ DEBIT
Definition: wallet.h:333
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:4403
CoinSelectionParams::CoinSelectionParams
CoinSelectionParams()
Definition: wallet.h:631
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:50
CWalletTx::m_amounts
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
Definition: wallet.h:335
CWallet::m_default_change_type
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
Definition: wallet.h:1037
CWallet::SyncMetaData
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:512
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:101
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:1595
CWallet::ChangeWalletPassphrase
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:404
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:4589
CWallet::Close
void Close()
Close wallet database.
Definition: wallet.cpp:507
CWallet::ScanningProgress
double ScanningProgress() const
Definition: wallet.h:864
CWallet::GetDestValues
std::vector< std::string > GetDestValues(const std::string &prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get all destination values matching a prefix.
Definition: wallet.cpp:3807
DEFAULT_FALLBACK_FEE
static const CAmount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:67
CWallet::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1575
CMerkleTx::Unserialize
void Unserialize(Stream &s)
Definition: wallet.h:255
CoinSelectionParams::m_avoid_partial_spends
bool m_avoid_partial_spends
Definition: wallet.h:618
COutput
Definition: wallet.h:563
CWallet::SignTransaction
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2523
CWallet::FindAddressBookEntry
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4141
CRecipient
Definition: wallet.h:211
WalletBatch
Access to the wallet database.
Definition: walletdb.h:176
amount.h
CWalletTx::UNCONFIRMED
@ UNCONFIRMED
Definition: wallet.h:380
DEFAULT_TX_CONFIRM_TARGET
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
Definition: wallet.h:89
CWallet::CanGetAddresses
bool CanGetAddresses(bool internal=false) const
Definition: wallet.cpp:1463
CWallet::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: wallet.h:1136
WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_KEY_ORIGIN_METADATA
Definition: walletutil.h:44
assert
assert(std::addressof(::ChainstateActive().CoinsTip())==std::addressof(coins_cache))
CWallet::GetKeyBirthTimes
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3654
WalletRescanReserver::isReserved
bool isReserved() const
Definition: wallet.h:1323
CWalletTx::AMOUNTTYPE_ENUM_ELEMENTS
@ AMOUNTTYPE_ENUM_ELEMENTS
Definition: wallet.h:333
CWallet::GetNewDestination
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
Definition: wallet.cpp:3353
CWallet::LoadToWallet
bool LoadToWallet(const uint256 &hash, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:971
WALLET_FLAG_MAP
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:125
CWallet::HaveChain
bool HaveChain() const
Interface to assert chain access.
Definition: wallet.h:789
CWallet::GUARDED_BY
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
CAddressBookData::StringMap
std::map< std::string, std::string > StringMap
Definition: wallet.h:200
CWallet::MarkInputsDirty
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1066
CWallet::SetBroadcastTransactions
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition: wallet.h:1147
CWallet::m_min_fee
CFeeRate m_min_fee
Override with -mintxfee.
Definition: wallet.h:1021
CWallet::GroupOutputs
std::vector< OutputGroup > GroupOutputs(const std::vector< COutput > &outputs, bool separate_coins, const CFeeRate &effective_feerate, const CFeeRate &long_term_feerate, const CoinEligibilityFilter &filter, bool positive_only) const
Definition: wallet.cpp:4240
CWallet::Unlock
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
Definition: wallet.cpp:4354
CWallet::TransactionChangeType
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
Definition: wallet.cpp:2730
CWalletTx::SubmitMemoryPoolAndRelay
bool SubmitMemoryPoolAndRelay(std::string &err_string, bool relay)
Definition: wallet.cpp:1905
ReserveDestination::ReturnDestination
void ReturnDestination()
Return reserved address.
Definition: wallet.cpp:3588
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:3579
DEFAULT_TRANSACTION_MINFEE
static const CAmount DEFAULT_TRANSACTION_MINFEE
-mintxfee default
Definition: wallet.h:71
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:117
CWallet::GetOrCreateLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
Definition: wallet.cpp:4461
CWallet::GetLastBlockHash
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:1254
CWalletTx::GetAmounts
void GetAmounts(std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter) const
Definition: wallet.cpp:1667
CWallet::LoadMinVersion
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:869
WALLET_FLAG_DESCRIPTORS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition: walletutil.h:62
FlatSigningProvider
Definition: signingprovider.h:47
CWallet::chainStateFlushed
void chainStateFlushed(const CBlockLocator &loc) override
Definition: wallet.cpp:450
CWallet::m_chain
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition: wallet.h:708
CAddressBookData::GetLabel
const std::string & GetLabel() const
Definition: wallet.h:204
DEFAULT_DISABLE_WALLET
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:93
CWalletTx::IsFromMe
bool IsFromMe(const isminefilter &filter) const
Definition: wallet.h:493
HandleLoadWallet
std::unique_ptr< interfaces::Handler > HandleLoadWallet(LoadWalletFn load_wallet)
Definition: wallet.cpp:151
CWallet::m_unlock_mutex
Mutex m_unlock_mutex
Definition: wallet.h:886
uint256::ONE
static const uint256 ONE
Definition: uint256.h:130
CWallet::DisplayAddress
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
Definition: wallet.cpp:3597