Bitcoin ABC  0.24.10
P2P Digital Currency
wallet.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Copyright (c) 2018-2020 The Bitcoin developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef BITCOIN_WALLET_WALLET_H
8 #define BITCOIN_WALLET_WALLET_H
9 
10 #include <amount.h>
11 #include <interfaces/chain.h>
12 #include <interfaces/handler.h>
13 #include <outputtype.h>
14 #include <primitives/blockhash.h>
15 #include <psbt.h>
16 #include <tinyformat.h>
17 #include <util/message.h>
18 #include <util/strencodings.h>
19 #include <util/string.h>
20 #include <util/system.h>
21 #include <util/translation.h>
22 #include <util/ui_change_type.h>
23 #include <validationinterface.h>
24 #include <wallet/coinselection.h>
25 #include <wallet/crypter.h>
26 #include <wallet/rpcwallet.h>
27 #include <wallet/scriptpubkeyman.h>
28 #include <wallet/walletdb.h>
29 #include <wallet/walletutil.h>
30 
31 #include <algorithm>
32 #include <atomic>
33 #include <cstdint>
34 #include <map>
35 #include <memory>
36 #include <optional>
37 #include <set>
38 #include <stdexcept>
39 #include <string>
40 #include <utility>
41 #include <vector>
42 
43 #include <boost/signals2/signal.hpp>
44 
45 using LoadWalletFn =
46  std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
47 
48 struct bilingual_str;
49 
55 void UnloadWallet(std::shared_ptr<CWallet> &&wallet);
56 
57 bool AddWallet(const std::shared_ptr<CWallet> &wallet);
58 bool RemoveWallet(const std::shared_ptr<CWallet> &wallet,
59  std::optional<bool> load_on_start,
60  std::vector<bilingual_str> &warnings);
61 bool RemoveWallet(const std::shared_ptr<CWallet> &wallet,
62  std::optional<bool> load_on_start);
63 std::vector<std::shared_ptr<CWallet>> GetWallets();
64 std::shared_ptr<CWallet> GetWallet(const std::string &name);
65 std::shared_ptr<CWallet>
66 LoadWallet(interfaces::Chain &chain, const std::string &name,
67  std::optional<bool> load_on_start, const DatabaseOptions &options,
69  std::vector<bilingual_str> &warnings);
70 std::shared_ptr<CWallet>
71 CreateWallet(interfaces::Chain &chain, const std::string &name,
72  std::optional<bool> load_on_start, const DatabaseOptions &options,
74  std::vector<bilingual_str> &warnings);
75 std::unique_ptr<interfaces::Handler> HandleLoadWallet(LoadWalletFn load_wallet);
76 std::unique_ptr<WalletDatabase>
77 MakeWalletDatabase(const std::string &name, const DatabaseOptions &options,
79 
98 constexpr Amount HIGH_APS_FEE{COIN / 10000};
100 static const Amount WALLET_INCREMENTAL_RELAY_FEE(5000 * SATOSHI);
102 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
104 static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
105 static const bool DEFAULT_WALLETBROADCAST = true;
106 static const bool DEFAULT_DISABLE_WALLET = false;
110 constexpr Amount HIGH_TX_FEE_PER_KB{COIN / 100};
115 static constexpr size_t DUMMY_P2PKH_INPUT_SIZE = 148;
116 
117 class CChainParams;
118 class CCoinControl;
119 class COutput;
120 class CScript;
121 class CTxMemPool;
122 class CWalletTx;
123 class ReserveDestination;
124 
127 
128 static constexpr uint64_t KNOWN_WALLET_FLAGS =
132 
133 static constexpr uint64_t MUTABLE_WALLET_FLAGS = WALLET_FLAG_AVOID_REUSE;
134 
135 static const std::map<std::string, WalletFlags> WALLET_FLAG_MAP{
136  {"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
137  {"blank", WALLET_FLAG_BLANK_WALLET},
138  {"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
139  {"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
140  {"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
141 };
142 
143 extern const std::map<uint64_t, std::string> WALLET_FLAG_CAVEATS;
144 
162 protected:
164  const CWallet *const pwallet;
170  int64_t nIndex{-1};
174  bool fInternal{false};
175 
176 public:
179  explicit ReserveDestination(CWallet *_pwallet, OutputType _type)
180  : pwallet(_pwallet), type(_type) {}
181 
182  ReserveDestination(const ReserveDestination &) = delete;
184 
188 
190  bool GetReservedDestination(CTxDestination &pubkey, bool internal);
192  void ReturnDestination();
195  void KeepDestination();
196 };
197 
200 private:
201  bool m_change{true};
202  std::string m_label;
203 
204 public:
205  std::string purpose;
206 
207  CAddressBookData() : purpose("unknown") {}
208 
209  typedef std::map<std::string, std::string> StringMap;
211 
212  bool IsChange() const { return m_change; }
213  const std::string &GetLabel() const { return m_label; }
214  void SetLabel(const std::string &label) {
215  m_change = false;
216  m_label = label;
217  }
218 };
219 
220 struct CRecipient {
224 };
225 
226 typedef std::map<std::string, std::string> mapValue_t;
227 
228 static inline void ReadOrderPos(int64_t &nOrderPos, mapValue_t &mapValue) {
229  if (!mapValue.count("n")) {
230  // TODO: calculate elsewhere
231  nOrderPos = -1;
232  return;
233  }
234 
235  nOrderPos = atoi64(mapValue["n"]);
236 }
237 
238 static inline void WriteOrderPos(const int64_t &nOrderPos,
239  mapValue_t &mapValue) {
240  if (nOrderPos == -1) {
241  return;
242  }
243  mapValue["n"] = ToString(nOrderPos);
244 }
245 
246 struct COutputEntry {
249  int vout;
250 };
251 
259 class CMerkleTx {
260 public:
261  template <typename Stream> void Unserialize(Stream &s) {
262  CTransactionRef tx;
263  BlockHash hashBlock;
264  std::vector<uint256> vMerkleBranch;
265  int nIndex = 0;
266 
267  s >> tx >> hashBlock >> vMerkleBranch >> nIndex;
268  }
269 };
270 
271 // Get the marginal bytes of spending the specified output
272 int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet,
273  bool use_max_sig = false);
274 
280 class CWalletTx {
281 private:
282  const CWallet *const pwallet;
283 
288  static constexpr const uint256 &ABANDON_HASH = uint256::ONE;
289 
290 public:
317  std::vector<std::pair<std::string, std::string>> vOrderForm;
318  unsigned int fTimeReceivedIsTxTime;
320  unsigned int nTimeReceived;
330  unsigned int nTimeSmart;
336  bool fFromMe;
338  int64_t nOrderPos;
339  std::multimap<int64_t, CWalletTx *>::const_iterator m_it_wtxOrdered;
340 
341  // memory only
342  enum AmountType {
348  };
349  Amount GetCachableAmount(AmountType type, const isminefilter &filter,
350  bool recalculate = false) const;
358  mutable bool m_is_cache_empty{true};
359  mutable bool fChangeCached;
360  mutable bool fInMempool;
362 
363  CWalletTx(const CWallet *wallet, CTransactionRef arg)
364  : pwallet(wallet), tx(std::move(arg)) {
365  Init();
366  }
367 
368  void Init() {
369  mapValue.clear();
370  vOrderForm.clear();
371  fTimeReceivedIsTxTime = false;
372  nTimeReceived = 0;
373  nTimeSmart = 0;
374  fFromMe = false;
375  fChangeCached = false;
376  fInMempool = false;
378  nOrderPos = -1;
380  }
381 
383 
395 
403  struct Confirmation {
407  int nIndex;
409  BlockHash h = BlockHash(), int i = 0)
410  : status(s), block_height(b), hashBlock(h), nIndex(i) {}
411  };
412 
414 
415  template <typename Stream> void Serialize(Stream &s) const {
416  mapValue_t mapValueCopy = mapValue;
417 
418  mapValueCopy["fromaccount"] = "";
419  WriteOrderPos(nOrderPos, mapValueCopy);
420  if (nTimeSmart) {
421  mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
422  }
423 
425  std::vector<char> dummy_vector1;
427  std::vector<char> dummy_vector2;
429  bool dummy_bool = false;
430  uint256 serializedHash =
432  int serializedIndex =
434  s << tx << serializedHash << dummy_vector1 << serializedIndex
435  << dummy_vector2 << mapValueCopy << vOrderForm
436  << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << dummy_bool;
437  }
438 
439  template <typename Stream> void Unserialize(Stream &s) {
440  Init();
441 
443  std::vector<uint256> dummy_vector1;
445  std::vector<CMerkleTx> dummy_vector2;
447  bool dummy_bool;
448  int serializedIndex;
449  s >> tx >> m_confirm.hashBlock >> dummy_vector1 >> serializedIndex >>
450  dummy_vector2 >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >>
451  nTimeReceived >> fFromMe >> dummy_bool;
452 
453  /*
454  * At serialization/deserialization, an nIndex == -1 means that
455  * hashBlock refers to the earliest block in the chain we know this or
456  * any in-wallet ancestor conflicts with. If nIndex == -1 and hashBlock
457  * is ABANDON_HASH, it means transaction is abandoned. In same context,
458  * an nIndex >= 0 refers to a confirmed transaction (if hashBlock set)
459  * or unconfirmed one. Older clients interpret nIndex == -1 as
460  * unconfirmed for backward compatibility (pre-commit 9ac63d6).
461  */
462  if (serializedIndex == -1 && m_confirm.hashBlock == ABANDON_HASH) {
463  setAbandoned();
464  } else if (serializedIndex == -1) {
465  setConflicted();
466  } else if (!m_confirm.hashBlock.IsNull()) {
467  m_confirm.nIndex = serializedIndex;
468  setConfirmed();
469  }
470 
472  nTimeSmart = mapValue.count("timesmart")
473  ? (unsigned int)atoi64(mapValue["timesmart"])
474  : 0;
475 
476  mapValue.erase("fromaccount");
477  mapValue.erase("spent");
478  mapValue.erase("n");
479  mapValue.erase("timesmart");
480  }
481 
482  void SetTx(CTransactionRef arg) { tx = std::move(arg); }
483 
485  void MarkDirty() {
486  m_amounts[DEBIT].Reset();
490  fChangeCached = false;
491  m_is_cache_empty = true;
492  }
493 
495  Amount GetDebit(const isminefilter &filter) const;
496  Amount GetCredit(const isminefilter &filter) const;
497  Amount GetImmatureCredit(bool fUseCache = true) const;
498  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
499  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The
500  // annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid
501  // having to resolve the issue of member access into incomplete type
502  // CWallet.
503  Amount GetAvailableCredit(bool fUseCache = true,
504  const isminefilter &filter = ISMINE_SPENDABLE)
506  Amount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const;
507  Amount GetChange() const;
508 
509  // Get the marginal bytes if spending the specified output from this
510  // transaction
511  int GetSpendSize(unsigned int out, bool use_max_sig = false) const {
512  return CalculateMaximumSignedInputSize(tx->vout[out], pwallet,
513  use_max_sig);
514  }
515 
516  void GetAmounts(std::list<COutputEntry> &listReceived,
517  std::list<COutputEntry> &listSent, Amount &nFee,
518  const isminefilter &filter) const;
519 
520  bool IsFromMe(const isminefilter &filter) const {
521  return GetDebit(filter) > Amount::zero();
522  }
523 
524  // True if only scriptSigs are different
525  bool IsEquivalentTo(const CWalletTx &tx) const;
526 
527  bool InMempool() const;
528  bool IsTrusted() const;
529 
530  int64_t GetTxTime() const;
531 
532  // Pass this transaction to node for mempool insertion and relay to peers if
533  // flag set to true
534  bool SubmitMemoryPoolAndRelay(std::string &err_string, bool relay);
535 
536  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
537  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
538  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
539  // resolve the issue of member access into incomplete type CWallet. Note
540  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
541  // in place.
542  std::set<TxId> GetConflicts() const NO_THREAD_SAFETY_ANALYSIS;
543 
550  // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
551  // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
552  // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
553  // resolve the issue of member access into incomplete type CWallet. Note
554  // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
555  // in place.
557  bool IsInMainChain() const { return GetDepthInMainChain() > 0; }
558 
564  int GetBlocksToMaturity() const;
565  bool isAbandoned() const {
567  }
568  void setAbandoned() {
572  m_confirm.nIndex = 0;
573  }
574  bool isConflicted() const {
576  }
578  bool isUnconfirmed() const {
580  }
582  bool isConfirmed() const {
584  }
586  TxId GetId() const { return tx->GetId(); }
587  bool IsCoinBase() const { return tx->IsCoinBase(); }
588  bool IsImmatureCoinBase() const;
589 
590  // Disable copying of CWalletTx objects to prevent bugs where instances get
591  // copied in and out of the mapWallet map, and fields are updated in the
592  // wrong copy.
593  CWalletTx(CWalletTx const &) = delete;
594  void operator=(CWalletTx const &x) = delete;
595 };
596 
597 class COutput {
598 public:
599  const CWalletTx *tx;
600  int i;
601  int nDepth;
602 
608 
611 
613  bool fSolvable;
614 
621 
627  bool fSafe;
628 
629  COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn,
630  bool fSolvableIn, bool fSafeIn, bool use_max_sig_in = false) {
631  tx = txIn;
632  i = iIn;
633  nDepth = nDepthIn;
634  fSpendable = fSpendableIn;
635  fSolvable = fSolvableIn;
636  fSafe = fSafeIn;
637  nInputBytes = -1;
638  use_max_sig = use_max_sig_in;
639  // If known and signable by the given wallet, compute nInputBytes
640  // Failure will keep this value -1
641  if (fSpendable && tx) {
643  }
644  }
645 
646  std::string ToString() const;
647 
648  inline CInputCoin GetInputCoin() const {
649  return CInputCoin(tx->tx, i, nInputBytes);
650  }
651 };
652 
654  bool use_bnb = true;
655  size_t change_output_size = 0;
656  size_t change_spend_size = 0;
658  size_t tx_noinputs_size = 0;
661 
662  CoinSelectionParams(bool use_bnb_, size_t change_output_size_,
663  size_t change_spend_size_, CFeeRate effective_fee_,
664  size_t tx_noinputs_size_)
665  : use_bnb(use_bnb_), change_output_size(change_output_size_),
666  change_spend_size(change_spend_size_), effective_fee(effective_fee_),
667  tx_noinputs_size(tx_noinputs_size_) {}
669 };
670 
671 // forward declarations for ScanForWalletTransactions/RescanFromTime
673 
678 class CWallet final : public WalletStorage,
680 private:
682 
683  bool Unlock(const CKeyingMaterial &vMasterKeyIn,
684  bool accept_no_keys = false);
685 
686  std::atomic<bool> fAbortRescan{false};
687  // controlled by WalletRescanReserver
688  std::atomic<bool> fScanningWallet{false};
689  std::atomic<int64_t> m_scanning_start{0};
690  std::atomic<double> m_scanning_progress{0};
691  friend class WalletRescanReserver;
692 
695  int nWalletVersion GUARDED_BY(cs_wallet) = FEATURE_BASE;
696 
699  int nWalletMaxVersion GUARDED_BY(cs_wallet) = FEATURE_BASE;
700 
701  int64_t nNextResend = 0;
703  // Local time that the tip block was received. Used to schedule wallet
704  // rebroadcasts.
705  std::atomic<int64_t> m_best_block_time{0};
706 
711  typedef std::multimap<COutPoint, TxId> TxSpends;
712  TxSpends mapTxSpends GUARDED_BY(cs_wallet);
713  void AddToSpends(const COutPoint &outpoint, const TxId &wtxid)
716 
733  CWalletTx::Confirmation confirm, bool fUpdate)
735 
740  void MarkConflicted(const BlockHash &hashBlock, int conflicting_height,
741  const TxId &txid);
742 
747  void MarkInputsDirty(const CTransactionRef &tx)
749 
750  void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>)
752 
759  void SyncTransaction(const CTransactionRef &tx,
760  CWalletTx::Confirmation confirm, bool update_tx = true)
762 
763  std::atomic<uint64_t> m_wallet_flags{0};
764 
765  bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address,
766  const std::string &strName,
767  const std::string &strPurpose);
768 
770  void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag);
771 
773  void UnsetBlankWalletFlag(WalletBatch &batch) override;
774 
777 
779  std::string m_name;
780 
782  std::unique_ptr<WalletDatabase> database;
783 
791  BlockHash m_last_block_processed GUARDED_BY(cs_wallet);
792 
793  /* Height of last block processed is used by wallet to know depth of
794  * transactions without relying on Chain interface beyond asynchronous
795  * updates. For safety, we initialize it to -1. Height is a pointer on
796  * node's tip and doesn't imply that the wallet has scanned sequentially all
797  * blocks up to this one.
798  */
799  int m_last_block_processed_height GUARDED_BY(cs_wallet) = -1;
800 
801  bool CreateTransactionInternal(const std::vector<CRecipient> &vecSend,
802  CTransactionRef &tx, Amount &nFeeRet,
803  int &nChangePosInOut, bilingual_str &error,
804  const CCoinControl &coin_control, bool sign);
805 
806  std::map<OutputType, ScriptPubKeyMan *> m_external_spk_managers;
807  std::map<OutputType, ScriptPubKeyMan *> m_internal_spk_managers;
808 
809  // Indexed by a unique identifier produced by each ScriptPubKeyMan using
810  // ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal
811  // structure
812  std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
813 
814 public:
815  /*
816  * Main wallet lock.
817  * This lock protects all the fields added by CWallet.
818  */
820 
826  WalletDatabase &GetDatabase() override { return *database; }
827 
833  bool SelectCoins(const std::vector<COutput> &vAvailableCoins,
834  const Amount nTargetValue,
835  std::set<CInputCoin> &setCoinsRet, Amount &nValueRet,
836  const CCoinControl &coin_control,
838  bool &bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
839 
843  const std::string &GetName() const { return m_name; }
844 
845  typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
847  unsigned int nMasterKeyMaxID = 0;
848 
850  CWallet(interfaces::Chain *chain, const std::string &name,
851  std::unique_ptr<WalletDatabase> _database)
852  : m_chain(chain), m_name(name), database(std::move(_database)) {}
853 
855  // Should not have slots connected at this point.
856  assert(NotifyUnload.empty());
857  }
858 
859  /* Returns the chain params used by this wallet. */
860  const CChainParams &GetChainParams() const override;
861 
862  bool IsCrypted() const;
863  bool IsLocked() const override;
864  bool Lock();
865 
867  bool HaveChain() const { return m_chain ? true : false; }
868 
869  std::map<TxId, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
870 
871  typedef std::multimap<int64_t, CWalletTx *> TxItems;
873 
874  int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
876 
877  std::map<CTxDestination, CAddressBookData>
878  m_address_book GUARDED_BY(cs_wallet);
879  const CAddressBookData *
881  bool allow_change = false) const
883 
884  std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
885 
887  std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
888 
890  interfaces::Chain &chain() const {
891  assert(m_chain);
892  return *m_chain;
893  }
894 
895  const CWalletTx *GetWalletTx(const TxId &txid) const
897  bool IsTrusted(const CWalletTx &wtx, std::set<TxId> &trusted_parents) const
899 
902  bool CanSupportFeature(enum WalletFeature wf) const override
905  return nWalletMaxVersion >= wf;
906  }
907 
911  void AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe = true,
912  const CCoinControl *coinControl = nullptr,
913  const Amount nMinimumAmount = SATOSHI,
914  const Amount nMaximumAmount = MAX_MONEY,
915  const Amount nMinimumSumAmount = MAX_MONEY,
916  const uint64_t nMaximumCount = 0) const
918 
923  std::map<CTxDestination, std::vector<COutput>> ListCoins() const
925 
930  int output) const
932 
939  bool SelectCoinsMinConf(const Amount nTargetValue,
940  const CoinEligibilityFilter &eligibility_filter,
941  std::vector<OutputGroup> groups,
942  std::set<CInputCoin> &setCoinsRet,
943  Amount &nValueRet,
945  bool &bnb_used) const;
946 
947  bool IsSpent(const COutPoint &outpoint) const
949 
950  // Whether this or any UTXO with the same CTxDestination has been spent.
951  bool IsSpentKey(const TxId &txid, unsigned int n) const
953  void SetSpentKeyState(WalletBatch &batch, const TxId &txid, unsigned int n,
954  bool used, std::set<CTxDestination> &tx_destinations)
956 
957  std::vector<OutputGroup> GroupOutputs(const std::vector<COutput> &outputs,
958  bool single_coin,
959  const size_t max_ancestors) const;
960 
961  bool IsLockedCoin(const COutPoint &outpoint) const
964  void UnlockCoin(const COutPoint &output)
967  void ListLockedCoins(std::vector<COutPoint> &vOutpts) const
969 
970  /*
971  * Rescan abort properties
972  */
973  void AbortRescan() { fAbortRescan = true; }
974  bool IsAbortingRescan() const { return fAbortRescan; }
975  bool IsScanning() const { return fScanningWallet; }
976  int64_t ScanningDuration() const {
978  }
979  double ScanningProgress() const {
980  return fScanningWallet ? double(m_scanning_progress) : 0;
981  }
982 
986 
989  nWalletVersion = nVersion;
990  nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion);
991  return true;
992  }
993 
999  bool AddDestData(WalletBatch &batch, const CTxDestination &dest,
1000  const std::string &key, const std::string &value)
1003  bool EraseDestData(WalletBatch &batch, const CTxDestination &dest,
1004  const std::string &key)
1007  void LoadDestData(const CTxDestination &dest, const std::string &key,
1008  const std::string &value)
1012  bool GetDestData(const CTxDestination &dest, const std::string &key,
1013  std::string *value) const
1016  std::vector<std::string> GetDestValues(const std::string &prefix) const
1018 
1022  int64_t nRelockTime GUARDED_BY(cs_wallet){0};
1023 
1024  // Used to prevent concurrent calls to walletpassphrase RPC.
1026  bool Unlock(const SecureString &strWalletPassphrase,
1027  bool accept_no_keys = false);
1028  bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase,
1029  const SecureString &strNewWalletPassphrase);
1030  bool EncryptWallet(const SecureString &strWalletPassphrase);
1031 
1032  void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const
1034  unsigned int ComputeTimeSmart(const CWalletTx &wtx) const;
1035 
1040  int64_t IncOrderPosNext(WalletBatch *batch = nullptr)
1043 
1044  void MarkDirty();
1045 
1054  using UpdateWalletTxFn = std::function<bool(CWalletTx &wtx, bool new_tx)>;
1055 
1057  const CWalletTx::Confirmation &confirm,
1058  const UpdateWalletTxFn &update_wtx = nullptr,
1059  bool fFlushOnClose = true);
1060  bool LoadToWallet(const TxId &txid, const UpdateWalletTxFn &fill_wtx)
1063  uint64_t mempool_sequence) override;
1064  void blockConnected(const CBlock &block, int height) override;
1065  void blockDisconnected(const CBlock &block, int height) override;
1066  void updatedBlockTip() override;
1067  int64_t RescanFromTime(int64_t startTime,
1068  const WalletRescanReserver &reserver, bool update);
1069 
1070  struct ScanResult {
1071  enum { SUCCESS, FAILURE, USER_ABORT } status = SUCCESS;
1072 
1077  std::optional<int> last_scanned_height;
1078 
1084  };
1085  ScanResult ScanForWalletTransactions(const BlockHash &start_block,
1086  int start_height,
1087  std::optional<int> max_height,
1088  const WalletRescanReserver &reserver,
1089  bool fUpdate);
1091  MemPoolRemovalReason reason,
1092  uint64_t mempool_sequence) override;
1094  void ResendWalletTransactions();
1095  struct Balance {
1097  Amount m_mine_trusted{Amount::zero()};
1099  Amount m_mine_untrusted_pending{Amount::zero()};
1101  Amount m_mine_immature{Amount::zero()};
1102  Amount m_watchonly_trusted{Amount::zero()};
1103  Amount m_watchonly_untrusted_pending{Amount::zero()};
1104  Amount m_watchonly_immature{Amount::zero()};
1105  };
1106  Balance GetBalance(int min_depth = 0, bool avoid_reuse = true) const;
1107  Amount GetAvailableBalance(const CCoinControl *coinControl = nullptr) const;
1108 
1109  OutputType
1110  TransactionChangeType(const std::optional<OutputType> &change_type,
1111  const std::vector<CRecipient> &vecSend);
1112 
1117  bool FundTransaction(CMutableTransaction &tx, Amount &nFeeRet,
1118  int &nChangePosInOut, bilingual_str &error,
1119  bool lockUnspents,
1120  const std::set<int> &setSubtractFeeFromOutputs,
1121  CCoinControl coinControl);
1122  // Fetch the inputs and sign with SIGHASH_ALL.
1123  bool SignTransaction(CMutableTransaction &tx) const
1125  // Sign the tx given the input coins and sighash.
1127  const std::map<COutPoint, Coin> &coins,
1128  SigHashType sighash,
1129  std::map<int, std::string> &input_errors) const;
1130  SigningResult SignMessage(const std::string &message, const PKHash &pkhash,
1131  std::string &str_sig) const;
1132 
1149  FillPSBT(PartiallySignedTransaction &psbtx, bool &complete,
1150  SigHashType sighash_type = SigHashType().withForkId(),
1151  bool sign = true, bool bip32derivs = true) const;
1152 
1159  bool CreateTransaction(const std::vector<CRecipient> &vecSend,
1160  CTransactionRef &tx, Amount &nFeeRet,
1161  int &nChangePosInOut, bilingual_str &error,
1162  const CCoinControl &coin_control, bool sign = true);
1163 
1174  void CommitTransaction(
1175  CTransactionRef tx, mapValue_t mapValue,
1176  std::vector<std::pair<std::string, std::string>> orderForm);
1177 
1178  bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts,
1179  bool use_max_sig = false) const {
1180  std::vector<CTxOut> v_txouts(txouts.size());
1181  std::copy(txouts.begin(), txouts.end(), v_txouts.begin());
1182  return DummySignTx(txNew, v_txouts, use_max_sig);
1183  }
1184  bool DummySignTx(CMutableTransaction &txNew,
1185  const std::vector<CTxOut> &txouts,
1186  bool use_max_sig = false) const;
1187  bool DummySignInput(CTxIn &tx_in, const CTxOut &txout,
1188  bool use_max_sig = false) const;
1189 
1190  bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp)
1192  bool ImportPrivKeys(const std::map<CKeyID, CKey> &privkey_map,
1193  const int64_t timestamp)
1195  bool ImportPubKeys(
1196  const std::vector<CKeyID> &ordered_pubkeys,
1197  const std::map<CKeyID, CPubKey> &pubkey_map,
1198  const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
1199  const bool add_keypool, const bool internal, const int64_t timestamp)
1201  bool ImportScriptPubKeys(const std::string &label,
1202  const std::set<CScript> &script_pub_keys,
1203  const bool have_solving_data,
1204  const bool apply_label, const int64_t timestamp)
1206 
1211  // Override with -mintxfee
1228  std::optional<OutputType> m_default_change_type{};
1234 
1236  bool TopUpKeyPool(unsigned int kpSize = 0);
1237 
1238  int64_t GetOldestKeyPoolTime() const;
1239 
1240  std::set<std::set<CTxDestination>> GetAddressGroupings() const
1242  std::map<CTxDestination, Amount> GetAddressBalances() const;
1243 
1244  std::set<CTxDestination> GetLabelAddresses(const std::string &label) const;
1245 
1250  void MarkDestinationsDirty(const std::set<CTxDestination> &destinations)
1252 
1253  bool GetNewDestination(const OutputType type, const std::string label,
1254  CTxDestination &dest, std::string &error);
1255  bool GetNewChangeDestination(const OutputType type, CTxDestination &dest,
1256  std::string &error);
1257 
1258  isminetype IsMine(const CTxDestination &dest) const
1260  isminetype IsMine(const CScript &script) const
1262  isminetype IsMine(const CTxIn &txin) const
1268  Amount GetDebit(const CTxIn &txin, const isminefilter &filter) const;
1269  isminetype IsMine(const CTxOut &txout) const
1271  ;
1272  Amount GetCredit(const CTxOut &txout, const isminefilter &filter) const;
1273  bool IsChange(const CTxOut &txout) const
1275  bool IsChange(const CScript &script) const
1277  Amount GetChange(const CTxOut &txout) const
1279  bool IsMine(const CTransaction &tx) const
1282  bool IsFromMe(const CTransaction &tx) const;
1283  Amount GetDebit(const CTransaction &tx, const isminefilter &filter) const;
1285  bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const;
1286  Amount GetCredit(const CTransaction &tx, const isminefilter &filter) const;
1287  Amount GetChange(const CTransaction &tx) const;
1288  void chainStateFlushed(const CBlockLocator &loc) override;
1289 
1290  DBErrors LoadWallet(bool &fFirstRunRet);
1291  DBErrors ZapSelectTx(std::vector<TxId> &txIdsIn,
1292  std::vector<TxId> &txIdsOut)
1294 
1295  bool SetAddressBook(const CTxDestination &address,
1296  const std::string &strName, const std::string &purpose);
1297 
1298  bool DelAddressBook(const CTxDestination &address);
1299 
1300  unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
1301 
1304  void SetMinVersion(enum WalletFeature, WalletBatch *batch_in = nullptr,
1305  bool fExplicit = false) override;
1306 
1309  bool SetMaxVersion(int nVersion);
1310 
1313  int GetVersion() const {
1314  LOCK(cs_wallet);
1315  return nWalletVersion;
1316  }
1317 
1320  std::set<TxId> GetConflicts(const TxId &txid) const
1322 
1325  bool HasWalletSpend(const TxId &txid) const
1327 
1329  void Flush();
1330 
1332  void Close();
1333 
1335  boost::signals2::signal<void()> NotifyUnload;
1336 
1341  boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address,
1342  const std::string &label, bool isMine,
1343  const std::string &purpose, ChangeType status)>
1345 
1350  boost::signals2::signal<void(CWallet *wallet, const TxId &txid,
1351  ChangeType status)>
1353 
1355  boost::signals2::signal<void(const std::string &title, int nProgress)>
1357 
1359  boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged;
1360 
1362  boost::signals2::signal<void()> NotifyCanGetAddressesChanged;
1363 
1368  boost::signals2::signal<void(CWallet *wallet)> NotifyStatusChanged;
1369 
1373  void SetBroadcastTransactions(bool broadcast) {
1374  fBroadcastTransactions = broadcast;
1375  }
1376 
1378  bool TransactionCanBeAbandoned(const TxId &txid) const;
1379 
1384  bool AbandonTransaction(const TxId &txid);
1385 
1390  static std::shared_ptr<CWallet>
1391  Create(interfaces::Chain &chain, const std::string &name,
1392  std::unique_ptr<WalletDatabase> database,
1393  uint64_t wallet_creation_flags, bilingual_str &error,
1394  std::vector<bilingual_str> &warnings);
1395 
1401  void postInitProcess();
1402 
1403  bool BackupWallet(const std::string &strDest) const;
1404 
1405  /* Returns true if HD is enabled */
1406  bool IsHDEnabled() const;
1407 
1412  bool CanGetAddresses(bool internal = false) const;
1413 
1420  void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(::cs_main)
1422 
1426  void SetWalletFlag(uint64_t flags);
1427 
1431  void UnsetWalletFlag(uint64_t flag);
1432 
1436  bool IsWalletFlagSet(uint64_t flag) const override;
1437 
1442  bool AddWalletFlags(uint64_t flags);
1444  bool LoadWalletFlags(uint64_t flags);
1445 
1447  bool IsLegacy() const;
1448 
1453  const std::string GetDisplayName() const override {
1454  std::string wallet_name =
1455  GetName().length() == 0 ? "default wallet" : GetName();
1456  return strprintf("[%s]", wallet_name);
1457  };
1458 
1463  template <typename... Params>
1464  void WalletLogPrintf(std::string fmt, Params... parameters) const {
1465  LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
1466  };
1467 
1468  template <typename... Params>
1469  void WalletLogPrintfToBeContinued(std::string fmt,
1470  Params... parameters) const {
1471  LogPrintfToBeContinued(("%s " + fmt).c_str(), GetDisplayName(),
1472  parameters...);
1473  };
1474 
1476  bool UpgradeWallet(int version, bilingual_str &error);
1477 
1480  std::set<ScriptPubKeyMan *> GetActiveScriptPubKeyMans() const;
1481 
1483  std::set<ScriptPubKeyMan *> GetAllScriptPubKeyMans() const;
1484 
1488  bool internal) const;
1489 
1491  ScriptPubKeyMan *GetScriptPubKeyMan(const CScript &script) const;
1493  ScriptPubKeyMan *GetScriptPubKeyMan(const uint256 &id) const;
1494 
1497  std::set<ScriptPubKeyMan *>
1498  GetScriptPubKeyMans(const CScript &script, SignatureData &sigdata) const;
1499 
1501  std::unique_ptr<SigningProvider>
1502  GetSolvingProvider(const CScript &script) const;
1503  std::unique_ptr<SigningProvider>
1504  GetSolvingProvider(const CScript &script, SignatureData &sigdata) const;
1505 
1510 
1514 
1515  const CKeyingMaterial &GetEncryptionKey() const override;
1516  bool HasEncryptionKeys() const override;
1517 
1521  assert(m_last_block_processed_height >= 0);
1522  return m_last_block_processed_height;
1523  };
1526  assert(m_last_block_processed_height >= 0);
1527  return m_last_block_processed;
1528  }
1530  void SetLastBlockProcessed(int block_height, BlockHash block_hash)
1533  m_last_block_processed_height = block_height;
1534  m_last_block_processed = block_hash;
1535  };
1536 
1539 
1543 
1551  void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
1552 
1560  void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal);
1561 
1564 
1569 
1572  ScriptPubKeyMan *
1574  const FlatSigningProvider &signing_provider,
1575  const std::string &label, bool internal);
1576 };
1577 
1583 void MaybeResendWalletTxs();
1584 
1587 private:
1590 
1591 public:
1593  : m_wallet(w), m_could_reserve(false) {}
1594 
1595  bool reserve() {
1596  assert(!m_could_reserve);
1597  if (m_wallet.fScanningWallet.exchange(true)) {
1598  return false;
1599  }
1600  m_wallet.m_scanning_start = GetTimeMillis();
1601  m_wallet.m_scanning_progress = 0;
1602  m_could_reserve = true;
1603  return true;
1604  }
1605 
1606  bool isReserved() const {
1607  return (m_could_reserve && m_wallet.fScanningWallet);
1608  }
1609 
1611  if (m_could_reserve) {
1612  m_wallet.fScanningWallet = false;
1613  }
1614  }
1615 };
1616 
1617 // Calculate the size of the transaction assuming all signatures are max size
1618 // Use DummySignatureCreator, which inserts 71 byte signatures everywhere.
1619 // NOTE: this requires that all inputs must be in mapWallet (eg the tx should
1620 // be IsAllFromMe).
1621 int64_t CalculateMaximumSignedTxSize(const CTransaction &tx,
1622  const CWallet *wallet,
1623  bool use_max_sig = false)
1625 int64_t CalculateMaximumSignedTxSize(const CTransaction &tx,
1626  const CWallet *wallet,
1627  const std::vector<CTxOut> &txouts,
1628  bool use_max_sig = false);
1629 
1631 bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name);
1632 
1635 bool RemoveWalletSetting(interfaces::Chain &chain,
1636  const std::string &wallet_name);
1637 
1638 #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:67
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:850
CWallet::GetKeyPoolSize
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3718
DatabaseOptions
Definition: db.h:221
CTxIn
An input of a transaction.
Definition: transaction.h:61
interfaces
Definition: dummywallet.cpp:12
HIGH_MAX_TX_FEE
constexpr Amount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
Definition: wallet.h:113
atoi64
int64_t atoi64(const std::string &str)
Definition: strencodings.cpp:469
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:1464
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:620
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:4166
CWallet::ComputeTimeSmart
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
Definition: wallet.cpp:4124
CWallet::ConnectScriptPubKeyManNotifiers
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
Definition: wallet.cpp:4915
crypter.h
ReserveDestination::fInternal
bool fInternal
Whether this is from the internal (change output) keypool.
Definition: wallet.h:174
CWallet::m_external_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
Definition: wallet.h:806
CoinSelectionParams::change_output_size
size_t change_output_size
Definition: wallet.h:655
CWallet::GetActiveScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
Definition: wallet.cpp:4791
CWalletTx::GetBlocksToMaturity
int GetBlocksToMaturity() const
Definition: wallet.cpp:4673
CRecipient::fSubtractFeeFromAmount
bool fSubtractFeeFromAmount
Definition: wallet.h:223
CWalletTx::CONFLICTED
@ CONFLICTED
Definition: wallet.h:394
CWallet::UnlockCoin
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4011
CWallet::FillPSBT
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true) const
Fills out a PSBT with information from the wallet.
Definition: wallet.cpp:2919
CWallet::nMasterKeyMaxID
unsigned int nMasterKeyMaxID
Definition: wallet.h:847
m_wallet
std::shared_ptr< CWallet > m_wallet
Definition: wallet.cpp:462
CAddressBookData::IsChange
bool IsChange() const
Definition: wallet.h:212
CoinSelectionParams::effective_fee
CFeeRate effective_fee
Definition: wallet.h:657
CWalletTx::IsEquivalentTo
bool IsEquivalentTo(const CWalletTx &tx) const
Definition: wallet.cpp:2324
OutputType
OutputType
Definition: outputtype.h:17
ToString
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:69
DUMMY_P2PKH_INPUT_SIZE
static constexpr size_t DUMMY_P2PKH_INPUT_SIZE
Pre-calculated constants for input size estimation.
Definition: wallet.h:115
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:2598
CWallet::GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3845
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:1218
CWallet::GetChainParams
const CChainParams & GetChainParams() const override
Definition: wallet.cpp:390
CWallet::ResendWalletTransactions
void ResendWalletTransactions()
Definition: wallet.cpp:2347
ReserveDestination::~ReserveDestination
~ReserveDestination()
Destructor.
Definition: wallet.h:187
CWalletTx::setConflicted
void setConflicted()
Definition: wallet.h:577
CWalletTx::GetId
TxId GetId() const
Definition: wallet.h:586
CWallet::GetSolvingProvider
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
Definition: wallet.cpp:4857
CWallet::MasterKeyMap
std::map< unsigned int, CMasterKey > MasterKeyMap
Definition: wallet.h:845
CWalletTx::GetCachableAmount
Amount GetCachableAmount(AmountType type, const isminefilter &filter, bool recalculate=false) const
Definition: wallet.cpp:2137
OutputGroup
Definition: coinselection.h:80
CoinSelectionParams::use_bnb
bool use_bnb
Definition: wallet.h:654
HIGH_TX_FEE_PER_KB
constexpr Amount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
Definition: wallet.h:110
WalletRescanReserver::WalletRescanReserver
WalletRescanReserver(CWallet &w)
Definition: wallet.h:1592
CWallet::GetAvailableBalance
Amount GetAvailableBalance(const CCoinControl *coinControl=nullptr) const
Definition: wallet.cpp:2435
CWallet::blockDisconnected
void blockDisconnected(const CBlock &block, int height) override
Definition: wallet.cpp:1367
isminefilter
uint8_t isminefilter
Definition: wallet.h:41
CWallet::SetMinVersion
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr, bool fExplicit=false) override
signify that a particular wallet feature is now used.
Definition: wallet.cpp:532
CWallet::HasWalletSpend
bool HasWalletSpend(const TxId &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:602
CWallet::IsAbortingRescan
bool IsAbortingRescan() const
Definition: wallet.h:974
CWallet::FundTransaction
bool FundTransaction(CMutableTransaction &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl coinControl)
Insert additional inputs into the transaction by calling CreateTransaction();.
Definition: wallet.cpp:2976
CreateWallet
std::shared_ptr< CWallet > CreateWallet(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:282
CWallet::IsFromMe
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
Definition: wallet.cpp:1508
CWallet::NotifyStatusChanged
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: wallet.h:1368
CWallet::ReacceptWalletTransactions
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2058
CWallet::m_scanning_start
std::atomic< int64_t > m_scanning_start
Definition: wallet.h:689
flags
int flags
Definition: bitcoin-tx.cpp:532
CWalletTx::fTimeReceivedIsTxTime
unsigned int fTimeReceivedIsTxTime
Definition: wallet.h:318
CWallet::TxItems
std::multimap< int64_t, CWalletTx * > TxItems
Definition: wallet.h:871
CWallet::GetOldestKeyPoolTime
int64_t GetOldestKeyPoolTime() const
Definition: wallet.cpp:3774
CWalletTx::AVAILABLE_CREDIT
@ AVAILABLE_CREDIT
Definition: wallet.h:346
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:629
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:5019
OutputType::LEGACY
@ LEGACY
CWallet::m_wallet_flags
std::atomic< uint64_t > m_wallet_flags
Definition: wallet.h:763
CWallet::GetLastBlockHeight
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
Definition: wallet.h:1519
CWallet::GetBalance
Balance GetBalance(int min_depth=0, bool avoid_reuse=true) const
Definition: wallet.cpp:2407
CWalletTx::Serialize
void Serialize(Stream &s) const
Definition: wallet.h:415
CWallet::IsWalletFlagSet
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
Definition: wallet.cpp:1630
CWallet::GetDBHandle
WalletDatabase & GetDBHandle()
Get database handle used by this wallet.
Definition: wallet.h:825
CWallet::CanSupportFeature
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature
Definition: wallet.h:902
string.h
CWalletTx::mapValue
mapValue_t mapValue
Key/value map with information about the transaction.
Definition: wallet.h:316
CWallet::LoadDescriptorScriptPubKeyMan
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
Definition: wallet.cpp:4923
CWallet::IsChange
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1460
vCoins
static std::vector< COutput > vCoins
Definition: coinselector_tests.cpp:35
CWallet::WalletLogPrintfToBeContinued
void WalletLogPrintfToBeContinued(std::string fmt, Params... parameters) const
Definition: wallet.h:1469
bilingual_str
Bilingual messages:
Definition: translation.h:17
DEFAULT_WALLET_REJECT_LONG_CHAINS
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS
Default for -walletrejectlongchains.
Definition: wallet.h:104
GetWallet
std::shared_ptr< CWallet > GetWallet(const std::string &name)
Definition: wallet.cpp:153
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:495
FEATURE_BASE
@ FEATURE_BASE
Definition: walletutil.h:17
WALLET_FLAG_MAP
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:135
outputtype.h
CWallet::ScanResult::last_scanned_height
std::optional< int > last_scanned_height
Definition: wallet.h:1077
LogPrintfToBeContinued
#define LogPrintfToBeContinued
These are aliases used to explicitly state that the message should not end with a newline character.
Definition: logging.h:205
CWalletTx::ABANDONED
@ ABANDONED
Definition: wallet.h:394
CWalletTx::IsImmatureCoinBase
bool IsImmatureCoinBase() const
Definition: wallet.cpp:4684
CCoinControl
Coin Control Features.
Definition: coincontrol.h:21
WriteOrderPos
static void WriteOrderPos(const int64_t &nOrderPos, mapValue_t &mapValue)
Definition: wallet.h:238
validationinterface.h
CWallet::GetLastBlockHash
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:1524
CWalletTx::setConfirmed
void setConfirmed()
Definition: wallet.h:585
MakeWalletDatabase
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Definition: wallet.cpp:4222
CWalletTx::Init
void Init()
Definition: wallet.h:368
CWallet::SetMaxVersion
bool SetMaxVersion(int nVersion)
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading...
Definition: wallet.cpp:560
CWalletTx::CWalletTx
CWalletTx(const CWallet *wallet, CTransactionRef arg)
Definition: wallet.h:363
handler.h
CWallet::GetEncryptionKey
const CKeyingMaterial & GetEncryptionKey() const override
Definition: wallet.cpp:4907
CWallet::chain
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:890
rpcwallet.h
CKeyingMaterial
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
Definition: crypter.h:57
ReserveDestination::address
CTxDestination address
The destination.
Definition: wallet.h:172
CWalletTx::setUnconfirmed
void setUnconfirmed()
Definition: wallet.h:581
COutput::nInputBytes
int nInputBytes
Pre-computed estimated size of this output as a fully-signed input in a transaction.
Definition: wallet.h:607
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:47
CWallet::m_scanning_progress
std::atomic< double > m_scanning_progress
Definition: wallet.h:690
CWallet::IsCrypted
bool IsCrypted() const
Definition: wallet.cpp:4750
CWalletTx::AmountType
AmountType
Definition: wallet.h:342
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:264
CWallet::UpdateWalletTxFn
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
Definition: wallet.h:1054
CWallet::FindNonChangeParentOutput
const CTxOut & FindNonChangeParentOutput(const CTransaction &tx, int output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Find non-change parent output.
Definition: wallet.cpp:2648
ReserveDestination::pwallet
const CWallet *const pwallet
The wallet to reserve from.
Definition: wallet.h:164
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:4662
blockhash.h
DEFAULT_TRANSACTION_MAXFEE
constexpr Amount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
Definition: wallet.h:108
CWallet::IsSpentKey
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:927
CWallet::NotifyCanGetAddressesChanged
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
Definition: wallet.h:1362
CWallet::nAccountingEntryNumber
uint64_t nAccountingEntryNumber
Definition: wallet.h:875
CWallet::AbortRescan
void AbortRescan()
Definition: wallet.h:973
CWallet::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:1359
AnnotatedMixin< std::recursive_mutex >
CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:1356
ReserveDestination::nIndex
int64_t nIndex
The index of the address's key in the keypool.
Definition: wallet.h:170
CWallet::IsTrusted
bool IsTrusted(const CWalletTx &wtx, std::set< TxId > &trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2268
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:4176
CWallet::TransactionCanBeAbandoned
bool TransactionCanBeAbandoned(const TxId &txid) const
Return whether transaction can be abandoned.
Definition: wallet.cpp:1152
CWalletTx::isConfirmed
bool isConfirmed() const
Definition: wallet.h:582
CWalletTx::m_confirm
Confirmation m_confirm
Definition: wallet.h:413
WalletDatabase
An instance of this class represents one database.
Definition: db.h:100
WalletRescanReserver::reserve
bool reserve()
Definition: wallet.h:1595
CWallet::GroupOutputs
std::vector< OutputGroup > GroupOutputs(const std::vector< COutput > &outputs, bool single_coin, const size_t max_ancestors) const
Definition: wallet.cpp:4690
CWallet::AddToWallet
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
Definition: wallet.cpp:954
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:22
CWallet::GetBroadcastTransactions
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
Definition: wallet.h:1371
ReserveDestination
A wrapper to reserve an address from a wallet.
Definition: wallet.h:161
CWalletTx::m_is_cache_empty
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
Definition: wallet.h:358
CWalletTx::Unserialize
void Unserialize(Stream &s)
Definition: wallet.h:439
LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:320
CoinEligibilityFilter
Definition: coinselection.h:64
CWallet::blockConnected
void blockConnected(const CBlock &block, int height) override
Definition: wallet.cpp:1352
chain.h
CWalletTx::GetSpendSize
int GetSpendSize(unsigned int out, bool use_max_sig=false) const
Definition: wallet.h:511
CWallet::ScanForWalletTransactions
ScanResult ScanForWalletTransactions(const BlockHash &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:1920
CWallet::SelectCoinsMinConf
bool SelectCoinsMinConf(const Amount nTargetValue, const CoinEligibilityFilter &eligibility_filter, std::vector< OutputGroup > groups, std::set< CInputCoin > &setCoinsRet, Amount &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:2667
CWalletTx::Confirmation::block_height
int block_height
Definition: wallet.h:405
CFeeRate
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
RemoveWallet
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:118
CWallet::GetNewChangeDestination
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
Definition: wallet.cpp:3757
CWallet::UnsetBlankWalletFlag
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
Definition: wallet.cpp:1626
CWallet::IsAllFromMe
bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const
Returns whether all of the inputs match the filter.
Definition: wallet.cpp:1526
SigningResult
SigningResult
Definition: message.h:47
CWalletTx::nChangeCached
Amount nChangeCached
Definition: wallet.h:361
WALLET_FLAG_CAVEATS
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:41
COIN
static constexpr Amount COIN
Definition: amount.h:154
CWalletTx::nTimeSmart
unsigned int nTimeSmart
Stable timestamp that never changes, and reflects the order a transaction was added to the wallet.
Definition: wallet.h:330
CWallet::SignMessage
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
Definition: wallet.cpp:2963
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:194
CWalletTx::IsTrusted
bool IsTrusted() const
Definition: wallet.cpp:2262
scriptpubkeyman.h
CWallet::Balance
Definition: wallet.h:1095
tinyformat.h
CWalletTx::SetTx
void SetTx(CTransactionRef arg)
Definition: wallet.h:482
Amount::zero
static constexpr Amount zero()
Definition: amount.h:42
COutput::fSolvable
bool fSolvable
Whether we know how to spend this output, ignoring the lack of keys.
Definition: wallet.h:613
CWallet::TxSpends
std::multimap< COutPoint, TxId > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
Definition: wallet.h:711
CWallet::GetVersion
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition: wallet.h:1313
prefix
const char * prefix
Definition: rest.cpp:772
CWallet::SetAddressBook
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:3666
WalletRescanReserver::m_wallet
CWallet & m_wallet
Definition: wallet.h:1588
LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: wallet.h:46
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:1453
DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:657
CWallet::MarkDirty
void MarkDirty()
Definition: wallet.cpp:896
CWallet::LoadToWallet
bool LoadToWallet(const TxId &txid, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1048
COutput::GetInputCoin
CInputCoin GetInputCoin() const
Definition: wallet.h:648
CWallet::DelAddressBook
bool DelAddressBook(const CTxDestination &address)
Definition: wallet.cpp:3673
SATOSHI
static constexpr Amount SATOSHI
Definition: amount.h:153
strencodings.h
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:108
CWallet::IsLocked
bool IsLocked() const override
Definition: wallet.cpp:4754
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:56
CWallet::Flush
void Flush()
Flush wallet (bitdb flush)
Definition: wallet.cpp:608
CWalletTx::nTimeReceived
unsigned int nTimeReceived
time received by this node
Definition: wallet.h:320
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
CWallet::CreateTransactionInternal
bool CreateTransactionInternal(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, bool sign)
Definition: wallet.cpp:3113
walletutil.h
NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:58
COutput::ToString
std::string ToString() const
Definition: wallet.cpp:385
CMerkleTx
Legacy class used for deserializing vtxPrev for backwards compatibility.
Definition: wallet.h:259
CWalletTx::isAbandoned
bool isAbandoned() const
Definition: wallet.h:565
CWallet::UpgradeKeyMetadata
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
Definition: wallet.cpp:406
WalletStorage
Definition: scriptpubkeyman.h:34
isminetype
isminetype
IsMine() return codes.
Definition: ismine.h:18
CWalletTx::m_it_wtxOrdered
std::multimap< int64_t, CWalletTx * >::const_iterator m_it_wtxOrdered
Definition: wallet.h:339
coinselection.h
CWalletTx::Confirmation::status
Status status
Definition: wallet.h:404
CWallet::ScanningDuration
int64_t ScanningDuration() const
Definition: wallet.h:976
CWallet::IsLockedCoin
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4021
CWallet::LoadWalletFlags
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
Definition: wallet.cpp:1634
SignatureData
Definition: sign.h:66
CWalletTx::GetDebit
Amount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
Definition: wallet.cpp:2148
CWallet::MarkConflicted
void MarkConflicted(const BlockHash &hashBlock, int conflicting_height, const TxId &txid)
Mark a transaction (and its in-wallet descendants) as conflicting with a particular block.
Definition: wallet.cpp:1227
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:3532
CWalletTx::nOrderPos
int64_t nOrderPos
position in ordered transaction list
Definition: wallet.h:338
CAddressBookData::m_change
bool m_change
Definition: wallet.h:201
CTxOut
An output of a transaction.
Definition: transaction.h:130
cs_main
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:103
CWallet::m_best_block_time
std::atomic< int64_t > m_best_block_time
Definition: wallet.h:705
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:1739
CWallet::fScanningWallet
std::atomic< bool > fScanningWallet
Definition: wallet.h:688
CWallet::ImportPrivKeys
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1715
CWalletTx::fChangeCached
bool fChangeCached
Definition: wallet.h:359
CWallet::m_name
std::string m_name
Wallet name: relative directory name or "" for default wallet.
Definition: wallet.h:779
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:4185
message.h
CWallet::UnsetWalletFlag
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
Definition: wallet.cpp:1612
CWallet::NotifyTransactionChanged
boost::signals2::signal< void(CWallet *wallet, const TxId &txid, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:1352
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:288
CWallet::m_default_address_type
OutputType m_default_address_type
Definition: wallet.h:1221
CWallet::m_spend_zero_conf_change
bool m_spend_zero_conf_change
Definition: wallet.h:1208
COutputEntry::vout
int vout
Definition: wallet.h:249
CWallet::updatedBlockTip
void updatedBlockTip() override
Definition: wallet.cpp:1384
CWallet::SetupDescriptorScriptPubKeyMans
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
Definition: wallet.cpp:4930
CWallet::UnsetWalletFlagWithDB
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
Definition: wallet.cpp:1617
CWalletTx::tx
CTransactionRef tx
Definition: wallet.h:382
WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:47
CAddressBookData
Address book data.
Definition: wallet.h:199
COutputEntry::destination
CTxDestination destination
Definition: wallet.h:247
CWallet::nNextResend
int64_t nNextResend
Definition: wallet.h:701
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)
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error.
Definition: wallet.cpp:4252
MUTABLE_WALLET_FLAGS
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:133
ReadOrderPos
static void ReadOrderPos(int64_t &nOrderPos, mapValue_t &mapValue)
Definition: wallet.h:228
CoinSelectionParams
Definition: wallet.h:653
CWallet::wtxOrdered
TxItems wtxOrdered
Definition: wallet.h:872
coin_selection_params
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(Amount::zero()), 0)
mapValue_t
std::map< std::string, std::string > mapValue_t
Definition: wallet.h:226
CWallet::GetAddressBalances
std::map< CTxDestination, Amount > GetAddressBalances() const
Definition: wallet.cpp:3804
CWalletTx::pwallet
const CWallet *const pwallet
Definition: wallet.h:282
CWallet::DummySignInput
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
Definition: wallet.cpp:1664
CWallet::m_chain_notifications_handler
std::unique_ptr< interfaces::Handler > m_chain_notifications_handler
Registered interfaces::Chain::Notifications handler.
Definition: wallet.h:887
COutputEntry
Definition: wallet.h:246
CWalletTx::isUnconfirmed
bool isUnconfirmed() const
Definition: wallet.h:578
CRecipient::nAmount
Amount nAmount
Definition: wallet.h:222
CAddressBookData::SetLabel
void SetLabel(const std::string &label)
Definition: wallet.h:214
CWallet::LoadWallet
DBErrors LoadWallet(bool &fFirstRunRet)
Definition: wallet.cpp:3577
WalletRescanReserver
RAII object to check and reserve a wallet rescan.
Definition: wallet.h:1586
CWallet::AddActiveScriptPubKeyMan
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:4968
SigHashType
Signature hash type wrapper class.
Definition: sighashtype.h:37
CWalletTx::GetConflicts
std::set< TxId > GetConflicts() const NO_THREAD_SAFETY_ANALYSIS
Definition: wallet.cpp:2126
CWallet::IsHDEnabled
bool IsHDEnabled() const
Definition: wallet.cpp:1580
CWallet::ZapSelectTx
DBErrors ZapSelectTx(std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3607
CWallet::~CWallet
~CWallet()
Definition: wallet.h:854
WalletRescanReserver::m_could_reserve
bool m_could_reserve
Definition: wallet.h:1589
CWallet::fBroadcastTransactions
bool fBroadcastTransactions
Definition: wallet.h:702
CalculateMaximumSignedInputSize
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, bool use_max_sig=false)
Definition: wallet.cpp:1793
DEFAULT_FALLBACK_FEE
static const Amount DEFAULT_FALLBACK_FEE
-fallbackfee default
Definition: wallet.h:83
CWallet::transactionAddedToMempool
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Definition: wallet.cpp:1297
CWallet::m_internal_spk_managers
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
Definition: wallet.h:807
CWallet::SyncTransaction
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
Definition: wallet.cpp:1284
CWallet::GetName
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:843
CWallet::mapMasterKeys
MasterKeyMap mapMasterKeys
Definition: wallet.h:846
CWallet::ReorderTransactions
DBErrors ReorderTransactions()
Definition: wallet.cpp:828
CWallet::fAbortRescan
std::atomic< bool > fAbortRescan
Definition: wallet.h:686
CWallet::UnlockAllCoins
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4016
CWalletTx::vOrderForm
std::vector< std::pair< std::string, std::string > > vOrderForm
Definition: wallet.h:317
uint256
256-bit opaque blob.
Definition: uint256.h:127
CWallet::ScanResult
Definition: wallet.h:1070
TxId
A TxId is the identifier of a transaction.
Definition: txid.h:14
CWallet::DummySignTx
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
Definition: wallet.h:1178
CWallet::NotifyUnload
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:1335
CWalletTx::CONFIRMED
@ CONFIRMED
Definition: wallet.h:394
CWalletTx::Confirmation
Confirmation includes tx status and a triplet of {block height/block hash/tx index in block} at which...
Definition: wallet.h:403
CWallet::UpgradeWallet
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
Definition: wallet.cpp:4591
Amount
Definition: amount.h:19
CWallet::GetDescriptorScriptPubKeyMan
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
Definition: wallet.cpp:5003
CWalletTx::GetTxTime
int64_t GetTxTime() const
Definition: wallet.cpp:1657
CWallet::IsSpent
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
Definition: wallet.cpp:665
CWalletTx::GetAmounts
void GetAmounts(std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter) const
Definition: wallet.cpp:1803
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:430
ReserveDestination::ReserveDestination
ReserveDestination(CWallet *_pwallet, OutputType _type)
Construct a ReserveDestination object.
Definition: wallet.h:179
CWallet::GetLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition: wallet.cpp:4873
CWallet::SetLastBlockProcessed
void SetLastBlockProcessed(int block_height, BlockHash block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
Definition: wallet.h:1530
CWallet::KeypoolCountExternalKeys
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3707
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:3784
COutput::fSpendable
bool fSpendable
Whether we have the private keys to spend this output.
Definition: wallet.h:610
COutput::fSafe
bool fSafe
Whether this output is considered safe to spend.
Definition: wallet.h:627
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:67
CWallet::ListLockedCoins
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4027
CoinSelectionParams::change_spend_size
size_t change_spend_size
Definition: wallet.h:656
COutput::nDepth
int nDepth
Definition: wallet.h:601
CAddressBookData::CAddressBookData
CAddressBookData()
Definition: wallet.h:207
CoinSelectionParams::tx_noinputs_size
size_t tx_noinputs_size
Definition: wallet.h:658
CWallet::AbandonTransaction
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
Definition: wallet.cpp:1168
CWalletTx::InMempool
bool InMempool() const
Definition: wallet.cpp:2258
CInputCoin
Definition: coinselection.h:19
DEFAULT_PAY_TX_FEE
constexpr Amount DEFAULT_PAY_TX_FEE
-paytxfee default
Definition: wallet.h:81
CWallet::SetupLegacyScriptPubKeyMan
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
Definition: wallet.cpp:4892
BlockHash
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
CoinSelectionParams::m_subtract_fee_outputs
bool m_subtract_fee_outputs
Indicate that we are subtracting the fee from outputs.
Definition: wallet.h:660
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:1344
WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition: walletutil.h:55
name
const char * name
Definition: rest.cpp:43
CWallet::EncryptWallet
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:708
CRecipient::scriptPubKey
CScript scriptPubKey
Definition: wallet.h:221
WalletRescanReserver::~WalletRescanReserver
~WalletRescanReserver()
Definition: wallet.h:1610
ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: ismine.h:21
CWallet::GetDatabase
WalletDatabase & GetDatabase() override
Definition: wallet.h:826
system.h
CBlock
Definition: block.h:55
COutput::tx
const CWalletTx * tx
Definition: wallet.h:599
PKHash
Definition: standard.h:106
UnloadWallet
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:199
CWalletTx::Confirmation::nIndex
int nIndex
Definition: wallet.h:407
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:52
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1201
ReserveDestination::type
const OutputType type
Definition: wallet.h:168
CWalletTx::setAbandoned
void setAbandoned()
Definition: wallet.h:568
CWallet::ScanResult::last_scanned_block
BlockHash last_scanned_block
Hash and height of most recent block that was successfully scanned.
Definition: wallet.h:1076
DBErrors
DBErrors
Error statuses for the wallet database.
Definition: walletdb.h:46
CWallet::CreateTransaction
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
Definition: wallet.cpp:3494
CAddressBookData::purpose
std::string purpose
Definition: wallet.h:205
CWalletTx::Confirmation::Confirmation
Confirmation(Status s=UNCONFIRMED, int b=0, BlockHash h=BlockHash(), int i=0)
Definition: wallet.h:408
CWallet::transactionRemovedFromMempool
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Definition: wallet.cpp:1310
DEFAULT_SPEND_ZEROCONF_CHANGE
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
Definition: wallet.h:102
base_blob::IsNull
bool IsNull() const
Definition: uint256.h:30
CWalletTx::GetChange
Amount GetChange() const
Definition: wallet.cpp:2248
LOCKS_EXCLUDED
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:55
MaybeResendWalletTxs
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
Definition: wallet.cpp:2396
ScriptPubKeyMan
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
Definition: scriptpubkeyman.h:174
CWallet::SetAddressBookWithDB
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
Definition: wallet.cpp:3639
CWalletTx::IsCoinBase
bool IsCoinBase() const
Definition: wallet.h:587
CWalletTx::IsInMainChain
bool IsInMainChain() const
Definition: wallet.h:557
CWalletTx::CREDIT
@ CREDIT
Definition: wallet.h:344
CWallet::GetLabelAddresses
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const
Definition: wallet.cpp:3950
CWallet::TopUpKeyPool
bool TopUpKeyPool(unsigned int kpSize=0)
Definition: wallet.cpp:3728
CWallet::IsScanning
bool IsScanning() const
Definition: wallet.h:975
CWallet::postInitProcess
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
Definition: wallet.cpp:4634
translation.h
CWallet::GetWalletTx
const CWalletTx * GetWalletTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:396
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:1096
CAddressBookData::destdata
StringMap destdata
Definition: wallet.h:210
KNOWN_WALLET_FLAGS
static constexpr uint64_t KNOWN_WALLET_FLAGS
Definition: wallet.h:128
CWallet::database
std::unique_ptr< WalletDatabase > database
Internal database handle.
Definition: wallet.h:782
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56
CWallet::BackupWallet
bool BackupWallet(const std::string &strDest) const
Definition: wallet.cpp:4645
CWallet::LockCoin
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4006
CWallet::GetConflicts
std::set< TxId > GetConflicts(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get wallet transactions that conflict with given transaction (spend same outputs)
Definition: wallet.cpp:573
CWalletTx::isConflicted
bool isConflicted() const
Definition: wallet.h:574
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:335
ReserveDestination::GetReservedDestination
bool GetReservedDestination(CTxDestination &pubkey, bool internal)
Reserve an address.
Definition: wallet.cpp:3968
CWallet::m_pay_tx_fee
CFeeRate m_pay_tx_fee
Definition: wallet.h:1207
LOCK
#define LOCK(cs)
Definition: sync.h:241
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:400
interfaces::Chain::Notifications
Chain notifications.
Definition: chain.h:273
DEFAULT_ADDRESS_TYPE
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
Definition: wallet.h:126
CWallet::Lock
bool Lock()
Definition: wallet.cpp:4762
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:678
CWallet::GetCredit
Amount GetCredit(const CTxOut &txout, const isminefilter &filter) const
Definition: wallet.cpp:1450
AddWallet
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:104
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:280
CAddressBookData::m_label
std::string m_label
Definition: wallet.h:202
ReserveDestination::m_spk_man
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from.
Definition: wallet.h:167
CWallet::IsMine
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1436
CWallet::m_spk_managers
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
Definition: wallet.h:812
CWallet::GetAllScriptPubKeyMans
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
Definition: wallet.cpp:4804
CWalletTx::Status
Status
New transactions start as UNCONFIRMED.
Definition: wallet.h:394
CWallet::TransactionChangeType
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend)
Definition: wallet.cpp:3097
CWallet::m_allow_fallback_fee
bool m_allow_fallback_fee
will be false if -fallbackfee=0
Definition: wallet.h:1210
CWallet::m_default_max_tx_fee
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
Definition: wallet.h:1233
DEFAULT_WALLETBROADCAST
static const bool DEFAULT_WALLETBROADCAST
Definition: wallet.h:105
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:508
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:319
DatabaseStatus::SUCCESS
@ SUCCESS
DatabaseStatus
DatabaseStatus
Definition: db.h:229
CWallet::HasEncryptionKeys
bool HasEncryptionKeys() const override
Definition: wallet.cpp:4911
GetWallets
std::vector< std::shared_ptr< CWallet > > GetWallets()
Definition: wallet.cpp:148
CWallet::IsLegacy
bool IsLegacy() const
Determine if we are a legacy wallet.
Definition: wallet.cpp:4993
CWallet::IncOrderPosNext
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
Definition: wallet.cpp:884
ReserveDestination::operator=
ReserveDestination & operator=(const ReserveDestination &)=delete
DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
static const Amount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE
maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled...
Definition: wallet.h:96
CWallet::ScanResult::last_failed_block
BlockHash last_failed_block
Hash of the most recent block that could not be scanned due to read errors or pruning.
Definition: wallet.h:1083
CoinSelectionParams::CoinSelectionParams
CoinSelectionParams(bool use_bnb_, size_t change_output_size_, size_t change_spend_size_, CFeeRate effective_fee_, size_t tx_noinputs_size_)
Definition: wallet.h:662
CWallet::cs_wallet
RecursiveMutex cs_wallet
Definition: wallet.h:819
CWallet::SelectCoins
bool SelectCoins(const std::vector< COutput > &vAvailableCoins, const Amount nTargetValue, std::set< CInputCoin > &setCoinsRet, Amount &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:2730
CWalletTx::GetCredit
Amount GetCredit(const isminefilter &filter) const
Definition: wallet.cpp:2164
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:336
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:1869
CWalletTx::fInMempool
bool fInMempool
Definition: wallet.h:360
CachableAmount::Reset
void Reset()
Definition: ismine.h:38
CWalletTx::MarkDirty
void MarkDirty()
make sure balances are recalculated
Definition: wallet.h:485
CWallet::GetScriptPubKeyMan
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Definition: wallet.cpp:4812
CWallet::AddWalletFlags
bool AddWalletFlags(uint64_t flags)
Overwrite all flags by the given uint64_t.
Definition: wallet.cpp:1645
CWalletTx::operator=
void operator=(CWalletTx const &x)=delete
CWallet::SetSpentKeyState
void SetSpentKeyState(WalletBatch &batch, const TxId &txid, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:903
CWalletTx::IMMATURE_CREDIT
@ IMMATURE_CREDIT
Definition: wallet.h:345
WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:80
CachableAmount
Cachable amount subdivided into watchonly and spendable parts.
Definition: ismine.h:34
HIGH_APS_FEE
constexpr Amount HIGH_APS_FEE
discourage APS fee higher than this amount
Definition: wallet.h:98
COutput::i
int i
Definition: wallet.h:600
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:4190
COutputEntry::amount
Amount amount
Definition: wallet.h:248
CalculateMaximumSignedTxSize
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig=false) EXCLUSIVE_LOCKS_REQUIRED(wallet -> cs_wallet)
Definition: wallet.cpp:1766
walletdb.h
DEFAULT_TRANSACTION_MINFEE_PER_KB
static const Amount DEFAULT_TRANSACTION_MINFEE_PER_KB
-mintxfee default
Definition: wallet.h:85
WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition: walletutil.h:14
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
CWalletTx::DEBIT
@ DEBIT
Definition: wallet.h:343
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:4828
CoinSelectionParams::CoinSelectionParams
CoinSelectionParams()
Definition: wallet.h:668
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
CWalletTx::m_amounts
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
Definition: wallet.h:351
CWallet::GetChange
Amount GetChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1487
CWallet::GetDebit
Amount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
Definition: wallet.cpp:1415
CWallet::m_default_change_type
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
Definition: wallet.h:1228
CWallet::SyncMetaData
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:616
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:1725
CWallet::ChangeWalletPassphrase
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:450
MAX_MONEY
static const Amount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition: amount.h:175
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:100
CWallet::LoadActiveScriptPubKeyMan
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
Definition: wallet.cpp:4979
CWalletTx::GetImmatureWatchOnlyCredit
Amount GetImmatureWatchOnlyCredit(const bool fUseCache=true) const
Definition: wallet.cpp:2239
CWallet::Close
void Close()
Close wallet database.
Definition: wallet.cpp:612
CWallet::ScanningProgress
double ScanningProgress() const
Definition: wallet.h:979
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:4209
CWallet::ImportScripts
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:1705
CWalletTx::Confirmation::hashBlock
BlockHash hashBlock
Definition: wallet.h:406
CMerkleTx::Unserialize
void Unserialize(Stream &s)
Definition: wallet.h:261
COutput
Definition: wallet.h:597
CWallet::SignTransaction
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2872
CWallet::FindAddressBookEntry
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4579
CRecipient
Definition: wallet.h:220
WalletBatch
Access to the wallet database.
Definition: walletdb.h:176
amount.h
CWalletTx::UNCONFIRMED
@ UNCONFIRMED
Definition: wallet.h:394
CWallet::CanGetAddresses
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
Definition: wallet.cpp:1589
WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_KEY_ORIGIN_METADATA
Definition: walletutil.h:51
CWallet::GetKeyBirthTimes
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:4036
WalletRescanReserver::isReserved
bool isReserved() const
Definition: wallet.h:1606
CWalletTx::AMOUNTTYPE_ENUM_ELEMENTS
@ AMOUNTTYPE_ENUM_ELEMENTS
Definition: wallet.h:347
CWalletTx::GetAvailableCredit
Amount GetAvailableCredit(bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) const NO_THREAD_SAFETY_ANALYSIS
Definition: wallet.cpp:2192
CWallet::GetNewDestination
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
Definition: wallet.cpp:3737
CTxDestination
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:132
CWallet::AvailableCoins
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const Amount nMinimumAmount=SATOSHI, const Amount nMaximumAmount=MAX_MONEY, const Amount nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
populate vCoins with vector of available COutputs.
Definition: wallet.cpp:2449
CWallet::HaveChain
bool HaveChain() const
Interface to assert chain access.
Definition: wallet.h:867
CWallet::GUARDED_BY
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet)
CAddressBookData::StringMap
std::map< std::string, std::string > StringMap
Definition: wallet.h:209
CWallet::MarkInputsDirty
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed.
Definition: wallet.cpp:1159
LogPrintf
static void LogPrintf(const char *fmt, const Args &... args)
Definition: logging.h:175
CWallet::SetBroadcastTransactions
void SetBroadcastTransactions(bool broadcast)
Set whether this wallet broadcasts transactions.
Definition: wallet.h:1373
CWallet::m_min_fee
CFeeRate m_min_fee
Definition: wallet.h:1212
AssertLockHeld
AssertLockHeld(g_cs_orphans)
CWallet::Unlock
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
Definition: wallet.cpp:4776
CWalletTx::SubmitMemoryPoolAndRelay
bool SubmitMemoryPoolAndRelay(std::string &err_string, bool relay)
Definition: wallet.cpp:2089
ReserveDestination::ReturnDestination
void ReturnDestination()
Return reserved address.
Definition: wallet.cpp:3998
ReserveDestination::KeepDestination
void KeepDestination()
Keep the address.
Definition: wallet.cpp:3989
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:59
CWallet::GetOrCreateLegacyScriptPubKeyMan
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
Definition: wallet.cpp:4887
CWallet::m_max_aps_fee
Amount m_max_aps_fee
note: this is absolute fee, not fee rate
Definition: wallet.h:1220
CWalletTx::GetImmatureCredit
Amount GetImmatureCredit(bool fUseCache=true) const
Definition: wallet.cpp:2184
CWallet::LoadMinVersion
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.h:987
WALLET_FLAG_DESCRIPTORS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition: walletutil.h:70
FlatSigningProvider
Definition: signingprovider.h:58
CWallet::chainStateFlushed
void chainStateFlushed(const CBlockLocator &loc) override
Definition: wallet.cpp:527
CWallet::m_chain
interfaces::Chain * m_chain
Interface for accessing chain state.
Definition: wallet.h:776
CWallet::AddToSpends
void AddToSpends(const COutPoint &outpoint, const TxId &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:684
WALLET_INCREMENTAL_RELAY_FEE
static const Amount WALLET_INCREMENTAL_RELAY_FEE(5000 *SATOSHI)
minimum recommended increment for BIP 125 replacement txs
CAddressBookData::GetLabel
const std::string & GetLabel() const
Definition: wallet.h:213
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:278
DEFAULT_DISABLE_WALLET
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:106
CWalletTx::IsFromMe
bool IsFromMe(const isminefilter &filter) const
Definition: wallet.h:520
HandleLoadWallet
std::unique_ptr< interfaces::Handler > HandleLoadWallet(LoadWalletFn load_wallet)
Definition: wallet.cpp:164
CWallet::m_unlock_mutex
Mutex m_unlock_mutex
Definition: wallet.h:1022
uint256::ONE
static const uint256 ONE
Definition: uint256.h:133