Bitcoin ABC  0.22.12
P2P Digital Currency
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 <chainparams.h>
9 #include <config.h>
10 #include <consensus/validation.h>
11 #include <interfaces/chain.h>
12 #include <interfaces/handler.h>
13 #include <policy/fees.h>
14 #include <primitives/transaction.h>
15 #include <rpc/server.h>
16 #include <script/standard.h>
18 #include <sync.h>
19 #include <util/check.h>
20 #include <util/ref.h>
21 #include <util/system.h>
22 #include <util/ui_change_type.h>
23 #include <wallet/context.h>
24 #include <wallet/fees.h>
25 #include <wallet/ismine.h>
26 #include <wallet/load.h>
27 #include <wallet/rpcdump.h>
28 #include <wallet/wallet.h>
29 
30 namespace interfaces {
31 namespace {
32 
34  WalletTx MakeWalletTx(CWallet &wallet, const CWalletTx &wtx) {
35  WalletTx result;
36  result.tx = wtx.tx;
37  result.txin_is_mine.reserve(wtx.tx->vin.size());
38  for (const auto &txin : wtx.tx->vin) {
39  result.txin_is_mine.emplace_back(wallet.IsMine(txin));
40  }
41  result.txout_is_mine.reserve(wtx.tx->vout.size());
42  result.txout_address.reserve(wtx.tx->vout.size());
43  result.txout_address_is_mine.reserve(wtx.tx->vout.size());
44  for (const auto &txout : wtx.tx->vout) {
45  result.txout_is_mine.emplace_back(wallet.IsMine(txout));
46  result.txout_address.emplace_back();
47  result.txout_address_is_mine.emplace_back(
48  ExtractDestination(txout.scriptPubKey,
49  result.txout_address.back())
50  ? wallet.IsMine(result.txout_address.back())
51  : ISMINE_NO);
52  }
53  result.credit = wtx.GetCredit(ISMINE_ALL);
54  result.debit = wtx.GetDebit(ISMINE_ALL);
55  result.change = wtx.GetChange();
56  result.time = wtx.GetTxTime();
57  result.value_map = wtx.mapValue;
58  result.is_coinbase = wtx.IsCoinBase();
59  return result;
60  }
61 
63  WalletTxStatus MakeWalletTxStatus(CWallet &wallet, const CWalletTx &wtx) {
64  WalletTxStatus result;
65  result.block_height = wtx.m_confirm.block_height > 0
67  : std::numeric_limits<int>::max();
68  result.blocks_to_maturity = wtx.GetBlocksToMaturity();
69  result.depth_in_main_chain = wtx.GetDepthInMainChain();
70  result.time_received = wtx.nTimeReceived;
71  result.lock_time = wtx.tx->nLockTime;
72  TxValidationState state;
73  result.is_final =
75  state);
76  result.is_trusted = wtx.IsTrusted();
77  result.is_abandoned = wtx.isAbandoned();
78  result.is_coinbase = wtx.IsCoinBase();
79  result.is_in_main_chain = wtx.IsInMainChain();
80  return result;
81  }
82 
84  WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, int n,
85  int depth)
87  WalletTxOut result;
88  result.txout = wtx.tx->vout[n];
89  result.time = wtx.GetTxTime();
90  result.depth_in_main_chain = depth;
91  result.is_spent = wallet.IsSpent(COutPoint(wtx.GetId(), n));
92  return result;
93  }
94 
95  class WalletImpl : public Wallet {
96  public:
97  explicit WalletImpl(const std::shared_ptr<CWallet> &wallet)
98  : m_wallet(wallet) {}
99 
100  bool encryptWallet(const SecureString &wallet_passphrase) override {
101  return m_wallet->EncryptWallet(wallet_passphrase);
102  }
103  bool isCrypted() override { return m_wallet->IsCrypted(); }
104  bool lock() override { return m_wallet->Lock(); }
105  bool unlock(const SecureString &wallet_passphrase) override {
106  return m_wallet->Unlock(wallet_passphrase);
107  }
108  bool isLocked() override { return m_wallet->IsLocked(); }
109  bool changeWalletPassphrase(
110  const SecureString &old_wallet_passphrase,
111  const SecureString &new_wallet_passphrase) override {
112  return m_wallet->ChangeWalletPassphrase(old_wallet_passphrase,
113  new_wallet_passphrase);
114  }
115  void abortRescan() override { m_wallet->AbortRescan(); }
116  bool backupWallet(const std::string &filename) override {
117  return m_wallet->BackupWallet(filename);
118  }
119  std::string getWalletName() override { return m_wallet->GetName(); }
120  std::set<CTxDestination>
121  getLabelAddresses(const std::string &label) override {
122  return m_wallet->GetLabelAddresses(label);
123  };
124  bool getNewDestination(const OutputType type, const std::string label,
125  CTxDestination &dest) override {
126  LOCK(m_wallet->cs_wallet);
127  std::string error;
128  return m_wallet->GetNewDestination(type, label, dest, error);
129  }
130  const CChainParams &getChainParams() override {
131  return m_wallet->GetChainParams();
132  }
133  bool getPubKey(const CScript &script, const CKeyID &address,
134  CPubKey &pub_key) override {
135  std::unique_ptr<SigningProvider> provider =
136  m_wallet->GetSolvingProvider(script);
137  if (provider) {
138  return provider->GetPubKey(address, pub_key);
139  }
140  return false;
141  }
142  SigningResult signMessage(const std::string &message,
143  const PKHash &pkhash,
144  std::string &str_sig) override {
145  return m_wallet->SignMessage(message, pkhash, str_sig);
146  }
147  bool isSpendable(const CTxDestination &dest) override {
148  return m_wallet->IsMine(dest) & ISMINE_SPENDABLE;
149  }
150  bool haveWatchOnly() override {
151  auto spk_man = m_wallet->GetLegacyScriptPubKeyMan();
152  if (spk_man) {
153  return spk_man->HaveWatchOnly();
154  }
155  return false;
156  };
157  bool setAddressBook(const CTxDestination &dest, const std::string &name,
158  const std::string &purpose) override {
159  return m_wallet->SetAddressBook(dest, name, purpose);
160  }
161  bool delAddressBook(const CTxDestination &dest) override {
162  return m_wallet->DelAddressBook(dest);
163  }
164  bool getAddress(const CTxDestination &dest, std::string *name,
165  isminetype *is_mine, std::string *purpose) override {
166  LOCK(m_wallet->cs_wallet);
167  auto it = m_wallet->m_address_book.find(dest);
168  if (it == m_wallet->m_address_book.end() || it->second.IsChange()) {
169  return false;
170  }
171  if (name) {
172  *name = it->second.GetLabel();
173  }
174  if (is_mine) {
175  *is_mine = m_wallet->IsMine(dest);
176  }
177  if (purpose) {
178  *purpose = it->second.purpose;
179  }
180  return true;
181  }
182  std::vector<WalletAddress> getAddresses() override {
183  LOCK(m_wallet->cs_wallet);
184  std::vector<WalletAddress> result;
185  for (const auto &item : m_wallet->m_address_book) {
186  if (item.second.IsChange()) {
187  continue;
188  }
189  result.emplace_back(item.first, m_wallet->IsMine(item.first),
190  item.second.GetLabel(),
191  item.second.purpose);
192  }
193  return result;
194  }
195  bool addDestData(const CTxDestination &dest, const std::string &key,
196  const std::string &value) override {
197  LOCK(m_wallet->cs_wallet);
198  WalletBatch batch{m_wallet->GetDatabase()};
199  return m_wallet->AddDestData(batch, dest, key, value);
200  }
201  bool eraseDestData(const CTxDestination &dest,
202  const std::string &key) override {
203  LOCK(m_wallet->cs_wallet);
204  WalletBatch batch{m_wallet->GetDatabase()};
205  return m_wallet->EraseDestData(batch, dest, key);
206  }
207  std::vector<std::string>
208  getDestValues(const std::string &prefix) override {
209  LOCK(m_wallet->cs_wallet);
210  return m_wallet->GetDestValues(prefix);
211  }
212  void lockCoin(const COutPoint &output) override {
213  LOCK(m_wallet->cs_wallet);
214  return m_wallet->LockCoin(output);
215  }
216  void unlockCoin(const COutPoint &output) override {
217  LOCK(m_wallet->cs_wallet);
218  return m_wallet->UnlockCoin(output);
219  }
220  bool isLockedCoin(const COutPoint &output) override {
221  LOCK(m_wallet->cs_wallet);
222  return m_wallet->IsLockedCoin(output);
223  }
224  void listLockedCoins(std::vector<COutPoint> &outputs) override {
225  LOCK(m_wallet->cs_wallet);
226  return m_wallet->ListLockedCoins(outputs);
227  }
229  createTransaction(const std::vector<CRecipient> &recipients,
230  const CCoinControl &coin_control, bool sign,
231  int &change_pos, Amount &fee,
232  bilingual_str &fail_reason) override {
233  LOCK(m_wallet->cs_wallet);
234  CTransactionRef tx;
235  if (!m_wallet->CreateTransaction(recipients, tx, fee, change_pos,
236  fail_reason, coin_control, sign)) {
237  return {};
238  }
239  return tx;
240  }
241  void commitTransaction(CTransactionRef tx, WalletValueMap value_map,
242  WalletOrderForm order_form) override {
243  LOCK(m_wallet->cs_wallet);
244  m_wallet->CommitTransaction(std::move(tx), std::move(value_map),
245  std::move(order_form));
246  }
247  bool transactionCanBeAbandoned(const TxId &txid) override {
248  return m_wallet->TransactionCanBeAbandoned(txid);
249  }
250  bool abandonTransaction(const TxId &txid) override {
251  LOCK(m_wallet->cs_wallet);
252  return m_wallet->AbandonTransaction(txid);
253  }
254  CTransactionRef getTx(const TxId &txid) override {
255  LOCK(m_wallet->cs_wallet);
256  auto mi = m_wallet->mapWallet.find(txid);
257  if (mi != m_wallet->mapWallet.end()) {
258  return mi->second.tx;
259  }
260  return {};
261  }
262  WalletTx getWalletTx(const TxId &txid) override {
263  LOCK(m_wallet->cs_wallet);
264  auto mi = m_wallet->mapWallet.find(txid);
265  if (mi != m_wallet->mapWallet.end()) {
266  return MakeWalletTx(*m_wallet, mi->second);
267  }
268  return {};
269  }
270  std::vector<WalletTx> getWalletTxs() override {
271  LOCK(m_wallet->cs_wallet);
272  std::vector<WalletTx> result;
273  result.reserve(m_wallet->mapWallet.size());
274  for (const auto &entry : m_wallet->mapWallet) {
275  result.emplace_back(MakeWalletTx(*m_wallet, entry.second));
276  }
277  return result;
278  }
279  bool tryGetTxStatus(const TxId &txid,
280  interfaces::WalletTxStatus &tx_status,
281  int &num_blocks, int64_t &block_time) override {
282  TRY_LOCK(m_wallet->cs_wallet, locked_wallet);
283  if (!locked_wallet) {
284  return false;
285  }
286  auto mi = m_wallet->mapWallet.find(txid);
287  if (mi == m_wallet->mapWallet.end()) {
288  return false;
289  }
290  num_blocks = m_wallet->GetLastBlockHeight();
291  block_time = -1;
292  CHECK_NONFATAL(m_wallet->chain().findBlock(
293  m_wallet->GetLastBlockHash(), FoundBlock().time(block_time)));
294  tx_status = MakeWalletTxStatus(*m_wallet, mi->second);
295  return true;
296  }
297  WalletTx getWalletTxDetails(const TxId &txid, WalletTxStatus &tx_status,
298  WalletOrderForm &order_form,
299  bool &in_mempool,
300  int &num_blocks) override {
301  LOCK(m_wallet->cs_wallet);
302  auto mi = m_wallet->mapWallet.find(txid);
303  if (mi != m_wallet->mapWallet.end()) {
304  num_blocks = m_wallet->GetLastBlockHeight();
305  in_mempool = mi->second.InMempool();
306  order_form = mi->second.vOrderForm;
307  tx_status = MakeWalletTxStatus(*m_wallet, mi->second);
308  return MakeWalletTx(*m_wallet, mi->second);
309  }
310  return {};
311  }
312  TransactionError fillPSBT(SigHashType sighash_type, bool sign,
313  bool bip32derivs,
315  bool &complete) const override {
316  return m_wallet->FillPSBT(psbtx, complete, sighash_type, sign,
317  bip32derivs);
318  }
319  WalletBalances getBalances() override {
320  const auto bal = m_wallet->GetBalance();
321  WalletBalances result;
322  result.balance = bal.m_mine_trusted;
323  result.unconfirmed_balance = bal.m_mine_untrusted_pending;
324  result.immature_balance = bal.m_mine_immature;
325  result.have_watch_only = haveWatchOnly();
326  if (result.have_watch_only) {
327  result.watch_only_balance = bal.m_watchonly_trusted;
328  result.unconfirmed_watch_only_balance =
329  bal.m_watchonly_untrusted_pending;
330  result.immature_watch_only_balance = bal.m_watchonly_immature;
331  }
332  return result;
333  }
334  bool tryGetBalances(WalletBalances &balances, int &num_blocks,
335  bool force, int cached_num_blocks) override {
336  TRY_LOCK(m_wallet->cs_wallet, locked_wallet);
337  if (!locked_wallet) {
338  return false;
339  }
340  num_blocks = m_wallet->GetLastBlockHeight();
341  if (!force && num_blocks == cached_num_blocks) {
342  return false;
343  }
344  balances = getBalances();
345  return true;
346  }
347  Amount getBalance() override {
348  return m_wallet->GetBalance().m_mine_trusted;
349  }
350  Amount getAvailableBalance(const CCoinControl &coin_control) override {
351  return m_wallet->GetAvailableBalance(&coin_control);
352  }
353  isminetype txinIsMine(const CTxIn &txin) override {
354  LOCK(m_wallet->cs_wallet);
355  return m_wallet->IsMine(txin);
356  }
357  isminetype txoutIsMine(const CTxOut &txout) override {
358  LOCK(m_wallet->cs_wallet);
359  return m_wallet->IsMine(txout);
360  }
361  Amount getDebit(const CTxIn &txin, isminefilter filter) override {
362  LOCK(m_wallet->cs_wallet);
363  return m_wallet->GetDebit(txin, filter);
364  }
365  Amount getCredit(const CTxOut &txout, isminefilter filter) override {
366  LOCK(m_wallet->cs_wallet);
367  return m_wallet->GetCredit(txout, filter);
368  }
369  CoinsList listCoins() override {
370  LOCK(m_wallet->cs_wallet);
371  CoinsList result;
372  for (const auto &entry : m_wallet->ListCoins()) {
373  auto &group = result[entry.first];
374  for (const auto &coin : entry.second) {
375  group.emplace_back(COutPoint(coin.tx->GetId(), coin.i),
376  MakeWalletTxOut(*m_wallet, *coin.tx,
377  coin.i, coin.nDepth));
378  }
379  }
380  return result;
381  }
382  std::vector<WalletTxOut>
383  getCoins(const std::vector<COutPoint> &outputs) override {
384  LOCK(m_wallet->cs_wallet);
385  std::vector<WalletTxOut> result;
386  result.reserve(outputs.size());
387  for (const auto &output : outputs) {
388  result.emplace_back();
389  auto it = m_wallet->mapWallet.find(output.GetTxId());
390  if (it != m_wallet->mapWallet.end()) {
391  int depth = it->second.GetDepthInMainChain();
392  if (depth >= 0) {
393  result.back() = MakeWalletTxOut(*m_wallet, it->second,
394  output.GetN(), depth);
395  }
396  }
397  }
398  return result;
399  }
400  bool hdEnabled() override { return m_wallet->IsHDEnabled(); }
401  OutputType getDefaultAddressType() override {
402  return m_wallet->m_default_address_type;
403  }
404  bool canGetAddresses() const override {
405  return m_wallet->CanGetAddresses();
406  }
407  bool privateKeysDisabled() override {
408  return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
409  }
410  OutputType getDefaultChangeType() override {
411  return m_wallet->m_default_change_type;
412  }
413  Amount getDefaultMaxTxFee() override {
414  return m_wallet->m_default_max_tx_fee;
415  }
416  void remove() override { RemoveWallet(m_wallet); }
417  bool isLegacy() override { return m_wallet->IsLegacy(); }
418  std::unique_ptr<Handler> handleUnload(UnloadFn fn) override {
419  return MakeHandler(m_wallet->NotifyUnload.connect(fn));
420  }
421  std::unique_ptr<Handler>
422  handleShowProgress(ShowProgressFn fn) override {
423  return MakeHandler(m_wallet->ShowProgress.connect(fn));
424  }
425  std::unique_ptr<Handler>
426  handleStatusChanged(StatusChangedFn fn) override {
427  return MakeHandler(m_wallet->NotifyStatusChanged.connect(
428  [fn](CWallet *) { fn(); }));
429  }
430  std::unique_ptr<Handler>
431  handleAddressBookChanged(AddressBookChangedFn fn) override {
432  return MakeHandler(m_wallet->NotifyAddressBookChanged.connect(
433  [fn](CWallet *, const CTxDestination &address,
434  const std::string &label, bool is_mine,
435  const std::string &purpose, ChangeType status) {
436  fn(address, label, is_mine, purpose, status);
437  }));
438  }
439  std::unique_ptr<Handler>
440  handleTransactionChanged(TransactionChangedFn fn) override {
441  return MakeHandler(m_wallet->NotifyTransactionChanged.connect(
442  [fn](CWallet *, const TxId &txid, ChangeType status) {
443  fn(txid, status);
444  }));
445  }
446  std::unique_ptr<Handler>
447  handleWatchOnlyChanged(WatchOnlyChangedFn fn) override {
448  return MakeHandler(m_wallet->NotifyWatchonlyChanged.connect(fn));
449  }
450  std::unique_ptr<Handler>
451  handleCanGetAddressesChanged(CanGetAddressesChangedFn fn) override {
452  return MakeHandler(
453  m_wallet->NotifyCanGetAddressesChanged.connect(fn));
454  }
455  Amount getRequiredFee(unsigned int tx_bytes) override {
456  return GetRequiredFee(*m_wallet, tx_bytes);
457  }
458  Amount getMinimumFee(unsigned int tx_bytes,
459  const CCoinControl &coin_control) override {
460  return GetMinimumFee(*m_wallet, tx_bytes, coin_control);
461  }
462  CWallet *wallet() override { return m_wallet.get(); }
463 
464  std::shared_ptr<CWallet> m_wallet;
465  };
466 
467  class WalletClientImpl : public ChainClient {
468  public:
469  WalletClientImpl(Chain &chain, ArgsManager &args,
470  std::vector<std::string> wallet_filenames)
471  : m_wallet_filenames(std::move(wallet_filenames)) {
472  m_context.chain = &chain;
473  m_context.args = &args;
474  }
475 
476  void registerRpcs(const Span<const CRPCCommand> &commands) {
477  for (const CRPCCommand &command : commands) {
478  m_rpc_commands.emplace_back(
479  command.category, command.name,
480  [this, &command](Config &config,
481  const JSONRPCRequest &request,
482  UniValue &result, bool last_handler) {
483  return command.actor(config, {request, m_context},
484  result, last_handler);
485  },
486  command.argNames, command.unique_id);
487  m_rpc_handlers.emplace_back(
489  }
490  }
491 
492  void registerRpcs() override {
493  registerRpcs(GetWalletRPCCommands());
494  registerRpcs(GetWalletDumpRPCCommands());
495  }
496  bool verify(const CChainParams &chainParams) override {
497  return VerifyWallets(chainParams, *m_context.chain,
499  }
500  bool load(const CChainParams &chainParams) override {
501  return LoadWallets(chainParams, *m_context.chain,
503  }
504  void start(CScheduler &scheduler) override {
505  return StartWallets(scheduler, *Assert(m_context.args));
506  }
507  void flush() override { return FlushWallets(); }
508  void stop() override { return StopWallets(); }
509  void setMockTime(int64_t time) override { return SetMockTime(time); }
510  std::vector<std::unique_ptr<Wallet>> getWallets() override {
511  std::vector<std::unique_ptr<Wallet>> wallets;
512  for (const auto &wallet : GetWallets()) {
513  wallets.emplace_back(MakeWallet(wallet));
514  }
515  return wallets;
516  }
517  ~WalletClientImpl() override { UnloadWallets(); }
518 
520  const std::vector<std::string> m_wallet_filenames;
521  std::vector<std::unique_ptr<Handler>> m_rpc_handlers;
522  std::list<CRPCCommand> m_rpc_commands;
523  };
524 
525 } // namespace
526 
527 std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet> &wallet) {
528  return wallet ? std::make_unique<WalletImpl>(wallet) : nullptr;
529 }
530 
531 std::unique_ptr<ChainClient>
533  std::vector<std::string> wallet_filenames) {
534  return std::make_unique<WalletClientImpl>(chain, args,
535  std::move(wallet_filenames));
536 }
537 
538 } // namespace interfaces
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:338
uint32_t GetN() const
Definition: transaction.h:44
ArgsManager * args
Definition: context.h:25
std::shared_ptr< CWallet > m_wallet
Definition: wallet.cpp:464
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:152
#define TRY_LOCK(cs, name)
Definition: sync.h:236
Bilingual messages:
Definition: translation.h:17
SigningResult
Definition: message.h:47
const char * prefix
Definition: rest.cpp:754
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
Definition: check.h:34
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:56
Definition: amount.h:17
bool IsInMainChain() const
Definition: wallet.h:564
const TxId & GetTxId() const
Definition: transaction.h:43
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:47
std::vector< std::shared_ptr< CWallet > > GetWallets()
Definition: wallet.cpp:82
A version of CTransaction with the PSBT format.
Definition: psbt.h:335
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
Definition: handler.cpp:48
bool IsCoinBase() const
Definition: wallet.h:594
std::map< std::string, std::string > WalletValueMap
Definition: wallet.h:53
Amount 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:13
const std::vector< std::string > m_wallet_filenames
Definition: wallet.cpp:520
isminetype IsMine(const CTxDestination &dest) const
Definition: wallet.cpp:1304
OutputType
Definition: outputtype.h:17
Coin Control Features.
Definition: coincontrol.h:19
Access to the wallet database.
Definition: walletdb.h:183
mapValue_t mapValue
Key/value map with information about the transaction.
Definition: wallet.h:316
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:897
void StopWallets()
Stop all wallets. Wallets will be flushed first.
Definition: load.cpp:131
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: time.cpp:50
Definition: config.h:19
bool LoadWallets(const CChainParams &chainParams, interfaces::Chain &chain, const std::vector< std::string > &wallet_files)
Load wallet databases.
Definition: load.cpp:78
Confirmation m_confirm
Definition: wallet.h:414
Amount GetCredit(const isminefilter &filter) const
Definition: wallet.cpp:2011
An input of a transaction.
Definition: transaction.h:67
#define LOCK(cs)
Definition: sync.h:230
const char * name
Definition: rest.cpp:43
An encapsulated public key.
Definition: pubkey.h:31
int GetBlocksToMaturity() const
Definition: wallet.cpp:4634
virtual std::unique_ptr< Handler > handleRpc(const CRPCCommand &command)=0
Register handler for RPC.
uint8_t isminefilter
Definition: wallet.h:38
bool IsTrusted() const
Definition: wallet.cpp:2109
isminetype
IsMine() return codes.
Definition: ismine.h:18
An output of a transaction.
Definition: transaction.h:141
Span< const CRPCCommand > GetWalletDumpRPCCommands()
Definition: rpcdump.cpp:2316
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
bool VerifyWallets(const CChainParams &chainParams, interfaces::Chain &chain, const std::vector< std::string > &wallet_files)
Responsible for reading and validating the -wallet arguments and verifying the wallet database...
Definition: load.cpp:16
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
Return implementation of Wallet interface.
Definition: dummywallet.cpp:84
void FlushWallets()
Flush all wallets in preparation for shutdown.
Definition: load.cpp:125
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:280
Amount GetChange() const
Definition: wallet.cpp:2095
virtual bool contextualCheckTransactionForCurrentBlock(const CTransaction &tx, TxValidationState &state)=0
Check if transaction will be final given chain height current time.
Span< const CRPCCommand > GetWalletRPCCommands()
Definition: rpcwallet.cpp:5032
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56
Amount GetMinimumFee(const CWallet &wallet, unsigned int nTxBytes, const CCoinControl &coin_control)
Estimate the minimum fee considering user set parameters and the required fee.
Definition: fees.cpp:17
interfaces::Chain * chain
Definition: context.h:24
int64_t GetTxTime() const
Definition: wallet.cpp:1514
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:105
Amount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
Definition: wallet.cpp:1995
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:429
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
Definition: wallet.cpp:567
A TxId is the identifier of a transaction.
Definition: txid.h:14
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:22
static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest)
Definition: server.cpp:198
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:4623
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet)
Definition: wallet.cpp:63
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:679
TransactionError
Definition: error.h:22
std::vector< std::pair< std::string, std::string > > WalletOrderForm
Definition: wallet.h:52
std::list< CRPCCommand > m_rpc_commands
Definition: wallet.cpp:522
RecursiveMutex cs_wallet
Definition: wallet.h:823
WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets.
Definition: context.h:23
unsigned int nTimeReceived
time received by this node
Definition: wallet.h:320
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:17
bool isAbandoned() const
Definition: wallet.h:572
void UnloadWallets()
Close all wallets.
Definition: load.cpp:137
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
std::unique_ptr< ChainClient > MakeWalletClient(Chain &chain, ArgsManager &args, std::vector< std::string > wallet_filenames)
Return implementation of ChainClient interface for a wallet client.
Definition: wallet.cpp:532
TxId GetId() const
Definition: wallet.h:593
bool error(const char *fmt, const Args &... args)
Definition: system.h:47
Updated transaction status.
Definition: wallet.h:355
WalletContext m_context
Definition: wallet.cpp:519
std::vector< std::unique_ptr< Handler > > m_rpc_handlers
Definition: wallet.cpp:521
CTransactionRef tx
Definition: wallet.h:383
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:87
#define Assert(val)
Identity function.
Definition: check.h:57
void StartWallets(CScheduler &scheduler, const ArgsManager &args)
Complete startup of wallets.
Definition: load.cpp:103
Signature hash type wrapper class.
Definition: sighashtype.h:37