BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
wallet.cpp
Go to the documentation of this file.
1 // Copyright (c) 2018 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <interfaces/wallet.h>
6 
7 #include <amount.h>
8 #include <chain.h>
9 #include <consensus/validation.h>
10 #include <interfaces/handler.h>
11 #include <net.h>
12 #include <policy/feerate.h>
13 #include <policy/fees.h>
14 #include <policy/policy.h>
15 #include <primitives/transaction.h>
16 #include <script/ismine.h>
17 #include <script/standard.h>
19 #include <sync.h>
20 #include <timedata.h>
21 #include <ui_interface.h>
22 #include <uint256.h>
23 #include <validation.h>
24 #include <wallet/feebumper.h>
25 #include <wallet/fees.h>
26 #include <wallet/wallet.h>
27 
28 namespace interfaces {
29 namespace {
30 
31 class PendingWalletTxImpl : public PendingWalletTx
32 {
33 public:
34  explicit PendingWalletTxImpl(CWallet& wallet) : m_wallet(wallet), m_key(&wallet) {}
35 
36  const CTransaction& get() override { return *m_tx; }
37 
38  int64_t getVirtualSize() override { return GetVirtualTransactionSize(*m_tx); }
39 
40  bool commit(WalletValueMap value_map,
41  WalletOrderForm order_form,
42  std::string& reject_reason) override
43  {
45  CValidationState state;
46  if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), std::move(order_form), m_key, g_connman.get(), state)) {
47  reject_reason = state.GetRejectReason();
48  return false;
49  }
50  return true;
51  }
52 
56 };
57 
59 static WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
60 {
61  WalletTx result;
62  result.tx = wtx.tx;
63  result.txin_is_mine.reserve(wtx.tx->vin.size());
64  for (const auto& txin : wtx.tx->vin) {
65  result.txin_is_mine.emplace_back(wallet.IsMine(txin));
66  }
67  result.txout_is_mine.reserve(wtx.tx->vout.size());
68  result.txout_address.reserve(wtx.tx->vout.size());
69  result.txout_address_is_mine.reserve(wtx.tx->vout.size());
70  for (const auto& txout : wtx.tx->vout) {
71  result.txout_is_mine.emplace_back(wallet.IsMine(txout));
72  result.txout_address.emplace_back();
73  result.txout_address_is_mine.emplace_back(ExtractDestination(txout.scriptPubKey, result.txout_address.back()) ?
74  IsMine(wallet, result.txout_address.back()) :
75  ISMINE_NO);
76  }
77  result.credit = wtx.GetCredit(ISMINE_ALL);
78  result.debit = wtx.GetDebit(ISMINE_ALL);
79  result.change = wtx.GetChange();
80  result.time = wtx.GetTxTime();
81  result.value_map = wtx.mapValue;
82  result.is_coinbase = wtx.IsCoinBase();
83  return result;
84 }
85 
87 static WalletTxStatus MakeWalletTxStatus(const CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
88 {
89  WalletTxStatus result;
90  auto mi = ::mapBlockIndex.find(wtx.hashBlock);
91  CBlockIndex* block = mi != ::mapBlockIndex.end() ? mi->second : nullptr;
92  result.block_height = (block ? block->nHeight : std::numeric_limits<int>::max());
93  result.blocks_to_maturity = wtx.GetBlocksToMaturity();
94  result.depth_in_main_chain = wtx.GetDepthInMainChain();
95  result.time_received = wtx.nTimeReceived;
96  result.lock_time = wtx.tx->nLockTime;
97  result.is_final = CheckFinalTx(*wtx.tx);
98  result.is_trusted = wtx.IsTrusted();
99  result.is_abandoned = wtx.isAbandoned();
100  result.is_coinbase = wtx.IsCoinBase();
101  result.is_in_main_chain = wtx.IsInMainChain();
102  return result;
103 }
104 
106 static WalletTxOut MakeWalletTxOut(CWallet& wallet, const CWalletTx& wtx, int n, int depth) EXCLUSIVE_LOCKS_REQUIRED(cs_main, wallet.cs_wallet)
107 {
108  WalletTxOut result;
109  result.txout = wtx.tx->vout[n];
110  result.time = wtx.GetTxTime();
111  result.depth_in_main_chain = depth;
112  result.is_spent = wallet.IsSpent(wtx.GetHash(), n);
113  return result;
114 }
115 
116 class WalletImpl : public Wallet
117 {
118 public:
119  explicit WalletImpl(const std::shared_ptr<CWallet>& wallet) : m_shared_wallet(wallet), m_wallet(*wallet.get()) {}
120 
121  bool encryptWallet(const SecureString& wallet_passphrase) override
122  {
123  return m_wallet.EncryptWallet(wallet_passphrase);
124  }
125  bool isCrypted() override { return m_wallet.IsCrypted(); }
126  bool lock() override { return m_wallet.Lock(); }
127  bool unlock(const SecureString& wallet_passphrase) override { return m_wallet.Unlock(wallet_passphrase); }
128  bool isLocked() override { return m_wallet.IsLocked(); }
129  bool changeWalletPassphrase(const SecureString& old_wallet_passphrase,
130  const SecureString& new_wallet_passphrase) override
131  {
132  return m_wallet.ChangeWalletPassphrase(old_wallet_passphrase, new_wallet_passphrase);
133  }
134  void abortRescan() override { m_wallet.AbortRescan(); }
135  bool backupWallet(const std::string& filename) override { return m_wallet.BackupWallet(filename); }
136  std::string getWalletName() override { return m_wallet.GetName(); }
137  bool getKeyFromPool(bool internal, CPubKey& pub_key) override
138  {
139  return m_wallet.GetKeyFromPool(pub_key, internal);
140  }
141  bool getPubKey(const CKeyID& address, CPubKey& pub_key) override { return m_wallet.GetPubKey(address, pub_key); }
142  bool getPrivKey(const CKeyID& address, CKey& key) override { return m_wallet.GetKey(address, key); }
143  bool isSpendable(const CTxDestination& dest) override { return IsMine(m_wallet, dest) & ISMINE_SPENDABLE; }
144  bool haveWatchOnly() override { return m_wallet.HaveWatchOnly(); };
145  bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::string& purpose) override
146  {
147  return m_wallet.SetAddressBook(dest, name, purpose);
148  }
149  bool delAddressBook(const CTxDestination& dest) override
150  {
151  return m_wallet.DelAddressBook(dest);
152  }
153  bool getAddress(const CTxDestination& dest,
154  std::string* name,
155  isminetype* is_mine,
156  std::string* purpose) override
157  {
159  auto it = m_wallet.mapAddressBook.find(dest);
160  if (it == m_wallet.mapAddressBook.end()) {
161  return false;
162  }
163  if (name) {
164  *name = it->second.name;
165  }
166  if (is_mine) {
167  *is_mine = IsMine(m_wallet, dest);
168  }
169  if (purpose) {
170  *purpose = it->second.purpose;
171  }
172  return true;
173  }
174  std::vector<WalletAddress> getAddresses() override
175  {
177  std::vector<WalletAddress> result;
178  for (const auto& item : m_wallet.mapAddressBook) {
179  result.emplace_back(item.first, IsMine(m_wallet, item.first), item.second.name, item.second.purpose);
180  }
181  return result;
182  }
183  void learnRelatedScripts(const CPubKey& key, OutputType type) override { m_wallet.LearnRelatedScripts(key, type); }
184  bool addDestData(const CTxDestination& dest, const std::string& key, const std::string& value) override
185  {
187  return m_wallet.AddDestData(dest, key, value);
188  }
189  bool eraseDestData(const CTxDestination& dest, const std::string& key) override
190  {
192  return m_wallet.EraseDestData(dest, key);
193  }
194  std::vector<std::string> getDestValues(const std::string& prefix) override
195  {
196  return m_wallet.GetDestValues(prefix);
197  }
198  void lockCoin(const COutPoint& output) override
199  {
201  return m_wallet.LockCoin(output);
202  }
203  void unlockCoin(const COutPoint& output) override
204  {
206  return m_wallet.UnlockCoin(output);
207  }
208  bool isLockedCoin(const COutPoint& output) override
209  {
211  return m_wallet.IsLockedCoin(output.hash, output.n);
212  }
213  void listLockedCoins(std::vector<COutPoint>& outputs) override
214  {
216  return m_wallet.ListLockedCoins(outputs);
217  }
218  std::unique_ptr<PendingWalletTx> createTransaction(const std::vector<CRecipient>& recipients,
219  const CCoinControl& coin_control,
220  bool sign,
221  int& change_pos,
222  CAmount& fee,
223  std::string& fail_reason) override
224  {
226  auto pending = MakeUnique<PendingWalletTxImpl>(m_wallet);
227  if (!m_wallet.CreateTransaction(recipients, pending->m_tx, pending->m_key, fee, change_pos,
228  fail_reason, coin_control, sign)) {
229  return {};
230  }
231  return std::move(pending);
232  }
233  bool transactionCanBeAbandoned(const uint256& txid) override { return m_wallet.TransactionCanBeAbandoned(txid); }
234  bool abandonTransaction(const uint256& txid) override
235  {
237  return m_wallet.AbandonTransaction(txid);
238  }
239  bool transactionCanBeBumped(const uint256& txid) override
240  {
242  }
243  bool createBumpTransaction(const uint256& txid,
244  const CCoinControl& coin_control,
245  CAmount total_fee,
246  std::vector<std::string>& errors,
247  CAmount& old_fee,
248  CAmount& new_fee,
249  CMutableTransaction& mtx) override
250  {
251  return feebumper::CreateTransaction(&m_wallet, txid, coin_control, total_fee, errors, old_fee, new_fee, mtx) ==
253  }
254  bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(&m_wallet, mtx); }
255  bool commitBumpTransaction(const uint256& txid,
256  CMutableTransaction&& mtx,
257  std::vector<std::string>& errors,
258  uint256& bumped_txid) override
259  {
260  return feebumper::CommitTransaction(&m_wallet, txid, std::move(mtx), errors, bumped_txid) ==
262  }
263  CTransactionRef getTx(const uint256& txid) override
264  {
266  auto mi = m_wallet.mapWallet.find(txid);
267  if (mi != m_wallet.mapWallet.end()) {
268  return mi->second.tx;
269  }
270  return {};
271  }
272  WalletTx getWalletTx(const uint256& txid) override
273  {
275  auto mi = m_wallet.mapWallet.find(txid);
276  if (mi != m_wallet.mapWallet.end()) {
277  return MakeWalletTx(m_wallet, mi->second);
278  }
279  return {};
280  }
281  std::vector<WalletTx> getWalletTxs() override
282  {
284  std::vector<WalletTx> result;
285  result.reserve(m_wallet.mapWallet.size());
286  for (const auto& entry : m_wallet.mapWallet) {
287  result.emplace_back(MakeWalletTx(m_wallet, entry.second));
288  }
289  return result;
290  }
291  bool tryGetTxStatus(const uint256& txid,
292  interfaces::WalletTxStatus& tx_status,
293  int& num_blocks,
294  int64_t& adjusted_time) override
295  {
296  TRY_LOCK(::cs_main, locked_chain);
297  if (!locked_chain) {
298  return false;
299  }
300  TRY_LOCK(m_wallet.cs_wallet, locked_wallet);
301  if (!locked_wallet) {
302  return false;
303  }
304  auto mi = m_wallet.mapWallet.find(txid);
305  if (mi == m_wallet.mapWallet.end()) {
306  return false;
307  }
308  num_blocks = ::chainActive.Height();
309  adjusted_time = GetAdjustedTime();
310  tx_status = MakeWalletTxStatus(mi->second);
311  return true;
312  }
313  WalletTx getWalletTxDetails(const uint256& txid,
314  WalletTxStatus& tx_status,
315  WalletOrderForm& order_form,
316  bool& in_mempool,
317  int& num_blocks,
318  int64_t& adjusted_time) override
319  {
321  auto mi = m_wallet.mapWallet.find(txid);
322  if (mi != m_wallet.mapWallet.end()) {
323  num_blocks = ::chainActive.Height();
324  adjusted_time = GetAdjustedTime();
325  in_mempool = mi->second.InMempool();
326  order_form = mi->second.vOrderForm;
327  tx_status = MakeWalletTxStatus(mi->second);
328  return MakeWalletTx(m_wallet, mi->second);
329  }
330  return {};
331  }
332  WalletBalances getBalances() override
333  {
334  WalletBalances result;
335  result.balance = m_wallet.GetBalance();
336  result.unconfirmed_balance = m_wallet.GetUnconfirmedBalance();
337  result.immature_balance = m_wallet.GetImmatureBalance();
338  result.have_watch_only = m_wallet.HaveWatchOnly();
339  if (result.have_watch_only) {
340  result.watch_only_balance = m_wallet.GetBalance(ISMINE_WATCH_ONLY);
341  result.unconfirmed_watch_only_balance = m_wallet.GetUnconfirmedWatchOnlyBalance();
342  result.immature_watch_only_balance = m_wallet.GetImmatureWatchOnlyBalance();
343  }
344  return result;
345  }
346  bool tryGetBalances(WalletBalances& balances, int& num_blocks) override
347  {
348  TRY_LOCK(cs_main, locked_chain);
349  if (!locked_chain) return false;
350  TRY_LOCK(m_wallet.cs_wallet, locked_wallet);
351  if (!locked_wallet) {
352  return false;
353  }
354  balances = getBalances();
355  num_blocks = ::chainActive.Height();
356  return true;
357  }
358  CAmount getBalance() override { return m_wallet.GetBalance(); }
359  CAmount getAvailableBalance(const CCoinControl& coin_control) override
360  {
361  return m_wallet.GetAvailableBalance(&coin_control);
362  }
363  isminetype txinIsMine(const CTxIn& txin) override
364  {
366  return m_wallet.IsMine(txin);
367  }
368  isminetype txoutIsMine(const CTxOut& txout) override
369  {
371  return m_wallet.IsMine(txout);
372  }
373  CAmount getDebit(const CTxIn& txin, isminefilter filter) override
374  {
376  return m_wallet.GetDebit(txin, filter);
377  }
378  CAmount getCredit(const CTxOut& txout, isminefilter filter) override
379  {
381  return m_wallet.GetCredit(txout, filter);
382  }
383  CoinsList listCoins() override
384  {
386  CoinsList result;
387  for (const auto& entry : m_wallet.ListCoins()) {
388  auto& group = result[entry.first];
389  for (const auto& coin : entry.second) {
390  group.emplace_back(
391  COutPoint(coin.tx->GetHash(), coin.i), MakeWalletTxOut(m_wallet, *coin.tx, coin.i, coin.nDepth));
392  }
393  }
394  return result;
395  }
396  std::vector<WalletTxOut> getCoins(const std::vector<COutPoint>& outputs) override
397  {
399  std::vector<WalletTxOut> result;
400  result.reserve(outputs.size());
401  for (const auto& output : outputs) {
402  result.emplace_back();
403  auto it = m_wallet.mapWallet.find(output.hash);
404  if (it != m_wallet.mapWallet.end()) {
405  int depth = it->second.GetDepthInMainChain();
406  if (depth >= 0) {
407  result.back() = MakeWalletTxOut(m_wallet, it->second, output.n, depth);
408  }
409  }
410  }
411  return result;
412  }
413  CAmount getRequiredFee(unsigned int tx_bytes) override { return GetRequiredFee(m_wallet, tx_bytes); }
414  CAmount getMinimumFee(unsigned int tx_bytes,
415  const CCoinControl& coin_control,
416  int* returned_target,
417  FeeReason* reason) override
418  {
419  FeeCalculation fee_calc;
420  CAmount result;
421  result = GetMinimumFee(m_wallet, tx_bytes, coin_control, ::mempool, ::feeEstimator, &fee_calc);
422  if (returned_target) *returned_target = fee_calc.returnedTarget;
423  if (reason) *reason = fee_calc.reason;
424  return result;
425  }
426  unsigned int getConfirmTarget() override { return m_wallet.m_confirm_target; }
427  bool hdEnabled() override { return m_wallet.IsHDEnabled(); }
428  bool IsWalletFlagSet(uint64_t flag) override { return m_wallet.IsWalletFlagSet(flag); }
429  OutputType getDefaultAddressType() override { return m_wallet.m_default_address_type; }
430  OutputType getDefaultChangeType() override { return m_wallet.m_default_change_type; }
431  std::unique_ptr<Handler> handleUnload(UnloadFn fn) override
432  {
433  return MakeHandler(m_wallet.NotifyUnload.connect(fn));
434  }
435  std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) override
436  {
437  return MakeHandler(m_wallet.ShowProgress.connect(fn));
438  }
439  std::unique_ptr<Handler> handleStatusChanged(StatusChangedFn fn) override
440  {
441  return MakeHandler(m_wallet.NotifyStatusChanged.connect([fn](CCryptoKeyStore*) { fn(); }));
442  }
443  std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) override
444  {
446  [fn](CWallet*, const CTxDestination& address, const std::string& label, bool is_mine,
447  const std::string& purpose, ChangeType status) { fn(address, label, is_mine, purpose, status); }));
448  }
449  std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override
450  {
452  [fn](CWallet*, const uint256& txid, ChangeType status) { fn(txid, status); }));
453  }
454  std::unique_ptr<Handler> handleWatchOnlyChanged(WatchOnlyChangedFn fn) override
455  {
456  return MakeHandler(m_wallet.NotifyWatchonlyChanged.connect(fn));
457  }
458 
459  std::shared_ptr<CWallet> m_shared_wallet;
460  CWallet& m_wallet;
461 };
462 
463 } // namespace
464 
465 std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return MakeUnique<WalletImpl>(wallet); }
466 
467 } // namespace interfaces
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
Compute the virtual transaction size (weight reinterpreted as bytes).
Definition: policy.cpp:246
CTxMemPool mempool
CAmount GetMinimumFee(const CWallet &wallet, unsigned int nTxBytes, const CCoinControl &coin_control, const CTxMemPool &pool, const CBlockPolicyEstimator &estimator, FeeCalculation *feeCalc)
Estimate the minimum fee considering user set parameters and the required fee.
Definition: fees.cpp:22
CReserveKey m_key
Definition: wallet.cpp:55
Result CreateTransaction(const CWallet *wallet, const uint256 &txid, const CCoinControl &coin_control, CAmount total_fee, std::vector< std::string > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)
Create bumpfee transaction.
Definition: feebumper.cpp:76
OutputType m_default_change_type
Definition: wallet.h:932
CAmount GetImmatureBalance() const
Definition: wallet.cpp:2054
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:155
int returnedTarget
Definition: fees.h:85
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3612
#define TRY_LOCK(cs, name)
Definition: sync.h:185
CAmount GetAvailableBalance(const CCoinControl *coinControl=nullptr) const
Definition: wallet.cpp:2136
std::map< CTxDestination, CAddressBookData > mapAddressBook
Definition: wallet.h:763
std::vector< std::string > GetDestValues(const std::string &prefix) const
Get all destination values matching a prefix.
Definition: wallet.cpp:3792
bool IsCrypted() const
Definition: crypter.h:144
BlockMap & mapBlockIndex
Definition: validation.cpp:218
CTransactionRef m_tx
Definition: wallet.cpp:53
const char * prefix
Definition: rest.cpp:581
int Height() const
Return the maximal height in the chain.
Definition: chain.h:476
FeeReason reason
Definition: fees.h:83
bool CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm, CReserveKey &reservekey, CConnman *connman, CValidationState &state)
Call after CreateTransaction unless you want to abort.
Definition: wallet.cpp:2958
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:56
uint8_t isminefilter
used for bitflags of isminetype
Definition: ismine.h:25
bool IsWalletFlagSet(uint64_t flag)
check if a certain wallet flag is set
Definition: wallet.cpp:1431
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
Definition: handler.cpp:27
std::map< std::string, std::string > WalletValueMap
Definition: wallet.h:43
CAmount GetUnconfirmedWatchOnlyBalance() const
Definition: wallet.cpp:2068
Keystore which keeps the private keys encrypted.
Definition: crypter.h:115
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:640
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:402
OutputType
Definition: outputtype.h:15
Coin Control Features.
Definition: coincontrol.h:16
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
Definition: crypter.cpp:278
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
boost::signals2::signal< void()> NotifyUnload
Wallet is about to be unloaded.
Definition: wallet.h:1025
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:1041
CBlockPolicyEstimator feeEstimator
Definition: validation.cpp:244
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:3092
boost::signals2::signal< void(CCryptoKeyStore *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: crypter.h:159
#define LOCK2(cs1, cs2)
Definition: sync.h:182
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3624
isminefilter filter
Definition: rpcwallet.cpp:1011
bool DelAddressBook(const CTxDestination &address)
Definition: wallet.cpp:3110
bool SignTransaction(CWallet *wallet, CMutableTransaction &mtx)
Sign the new transaction,.
Definition: feebumper.cpp:214
bool CheckFinalTx(const CTransaction &tx, int flags)
Transaction validation functions.
Definition: validation.cpp:315
CAmount GetBalance(const isminefilter &filter=ISMINE_SPENDABLE, const int min_depth=0) const
Definition: wallet.cpp:2022
CCriticalSection cs_main
Definition: validation.cpp:216
bool AbandonTransaction(const uint256 &hashTx)
Definition: wallet.cpp:1024
ChangeType
General change type (added, updated, removed).
Definition: ui_interface.h:23
isminetype
IsMine() return codes.
Definition: ismine.h:17
An input of a transaction.
Definition: transaction.h:61
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:123
OutputType m_default_address_type
Definition: wallet.h:931
bool IsHDEnabled() const
Definition: wallet.cpp:1418
#define LOCK(cs)
Definition: sync.h:181
const char * name
Definition: rest.cpp:37
bool IsLocked() const
Definition: crypter.cpp:155
An encapsulated public key.
Definition: pubkey.h:30
bool TransactionCanBeAbandoned(const uint256 &hashTx) const
Return whether transaction can be abandoned.
Definition: wallet.cpp:1007
std::string GetRejectReason() const
Definition: validation.h:88
uint32_t n
Definition: transaction.h:22
CAmount GetUnconfirmedBalance() const
Definition: wallet.cpp:2039
std::map< CTxDestination, std::vector< COutput > > ListCoins() const EXCLUSIVE_LOCKS_REQUIRED(cs_main
Return list of available coins and locked coins grouped by non-change output address.
Definition: wallet.cpp:2260
CAmount GetImmatureWatchOnlyBalance() const
Definition: wallet.cpp:2083
bool EraseDestData(const CTxDestination &dest, const std::string &key)
Erases a destination data tuple in the store and on disk.
Definition: wallet.cpp:3764
bool GetKey(const CKeyID &address, CKey &keyOut) const override
Definition: crypter.cpp:261
An output of a transaction.
Definition: transaction.h:131
FeeReason
Definition: fees.h:36
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:18
CCriticalSection cs_wallet
Definition: wallet.h:709
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
Return implementation of Wallet interface.
Definition: dummywallet.cpp:56
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:295
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3632
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:3606
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, 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:2561
bool TransactionCanBeBumped(const CWallet *wallet, const uint256 &txid)
Return whether transaction can be bumped.
Definition: feebumper.cpp:65
Capture information about block/transaction validation.
Definition: validation.h:26
256-bit opaque blob.
Definition: uint256.h:122
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
unsigned int m_confirm_target
Definition: wallet.h:919
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:1034
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:1235
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:431
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Definition: wallet.h:729
A key allocated from the key pool.
Definition: wallet.h:1145
Result CommitTransaction(CWallet *wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< std::string > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
Definition: feebumper.cpp:219
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
int64_t GetAdjustedTime()
Definition: timedata.cpp:35
CWallet & m_wallet
Definition: wallet.cpp:54
isminetype IsMine(const CKeyStore &keystore, const CScript &scriptPubKey)
Definition: ismine.cpp:175
A reference to a CKey: the Hash360 of its serialized public key.
Definition: pubkey.h:20
void LearnRelatedScripts(const CPubKey &key, OutputType)
Explicitly make the wallet learn the related scripts for outputs to the given key.
Definition: wallet.cpp:4274
std::shared_ptr< CWallet > m_shared_wallet
Definition: wallet.cpp:459
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:599
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:74
void AbortRescan()
Definition: wallet.h:808
std::vector< std::pair< std::string, std::string > > WalletOrderForm
Definition: wallet.h:42
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:1044
bool GetKeyFromPool(CPubKey &key, bool internal=false)
Definition: wallet.cpp:3337
A mutable version of CTransaction.
Definition: transaction.h:360
CAmount GetRequiredFee(const CWallet &wallet, unsigned int nTxBytes)
Return the minimum required absolute fee for this size based on the required fee rate.
Definition: fees.cpp:16
An encapsulated private key.
Definition: key.h:27
bool HaveWatchOnly(const CScript &dest) const override
Definition: keystore.cpp:165
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:264
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:183
bool AddDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
Adds a destination data tuple to the store, and saves it to disk.
Definition: wallet.cpp:3755
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
Definition: wallet.cpp:1256
isminetype IsMine(const CTxIn &txin) const
Definition: wallet.cpp:1218
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:219
bool BackupWallet(const std::string &strDest)
Definition: wallet.cpp:4196
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:1047
Updated transaction status.
Definition: wallet.h:346
bool Unlock(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:411
uint256 hash
Definition: transaction.h:21