Bitcoin Core  21.99.0
P2P Digital Currency
walletmodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 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 #if defined(HAVE_CONFIG_H)
7 #endif
8 
9 #include <qt/walletmodel.h>
10 
11 #include <qt/addresstablemodel.h>
12 #include <qt/clientmodel.h>
13 #include <qt/guiconstants.h>
14 #include <qt/guiutil.h>
15 #include <qt/optionsmodel.h>
16 #include <qt/paymentserver.h>
18 #include <qt/sendcoinsdialog.h>
20 
21 #include <interfaces/handler.h>
22 #include <interfaces/node.h>
23 #include <key_io.h>
24 #include <node/ui_interface.h>
25 #include <psbt.h>
26 #include <util/system.h> // for GetBoolArg
27 #include <util/translation.h>
28 #include <wallet/coincontrol.h>
29 #include <wallet/wallet.h> // for CRecipient
30 
31 #include <stdint.h>
32 #include <functional>
33 
34 #include <QDebug>
35 #include <QMessageBox>
36 #include <QSet>
37 #include <QTimer>
38 
39 
40 WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, ClientModel& client_model, const PlatformStyle *platformStyle, QObject *parent) :
41  QObject(parent),
42  m_wallet(std::move(wallet)),
43  m_client_model(&client_model),
44  m_node(client_model.node()),
45  optionsModel(client_model.getOptionsModel()),
46  addressTableModel(nullptr),
47  transactionTableModel(nullptr),
48  recentRequestsTableModel(nullptr),
49  cachedEncryptionStatus(Unencrypted),
50  timer(new QTimer(this))
51 {
52  fHaveWatchOnly = m_wallet->haveWatchOnly();
54  transactionTableModel = new TransactionTableModel(platformStyle, this);
56 
58 }
59 
61 {
63 }
64 
66 {
67  // This timer will be fired repeatedly to update the balance
68  connect(timer, &QTimer::timeout, this, &WalletModel::pollBalanceChanged);
69  timer->start(MODEL_UPDATE_DELAY);
70 }
71 
73 {
74  m_client_model = client_model;
75  if (!m_client_model) timer->stop();
76 }
77 
79 {
80  EncryptionStatus newEncryptionStatus = getEncryptionStatus();
81 
82  if(cachedEncryptionStatus != newEncryptionStatus) {
83  Q_EMIT encryptionStatusChanged();
84  }
85 }
86 
88 {
89  // Avoid recomputing wallet balances unless a TransactionChanged or
90  // BlockTip notification was received.
92 
93  // Try to get balances and return early if locks can't be acquired. This
94  // avoids the GUI from getting stuck on periodical polls if the core is
95  // holding the locks for a longer time - for example, during a wallet
96  // rescan.
97  interfaces::WalletBalances new_balances;
98  uint256 block_hash;
99  if (!m_wallet->tryGetBalances(new_balances, block_hash)) {
100  return;
101  }
102 
105 
106  // Balance and number of transactions might have changed
107  m_cached_last_update_tip = block_hash;
108 
109  checkBalanceChanged(new_balances);
112  }
113 }
114 
116 {
117  if(new_balances.balanceChanged(m_cached_balances)) {
118  m_cached_balances = new_balances;
119  Q_EMIT balanceChanged(new_balances);
120  }
121 }
122 
124 {
125  // Balance and number of transactions might have changed
127 }
128 
129 void WalletModel::updateAddressBook(const QString &address, const QString &label,
130  bool isMine, const QString &purpose, int status)
131 {
133  addressTableModel->updateEntry(address, label, isMine, purpose, status);
134 }
135 
136 void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
137 {
138  fHaveWatchOnly = fHaveWatchonly;
139  Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
140 }
141 
142 bool WalletModel::validateAddress(const QString &address)
143 {
144  return IsValidDestinationString(address.toStdString());
145 }
146 
148 {
149  CAmount total = 0;
150  bool fSubtractFeeFromAmount = false;
151  QList<SendCoinsRecipient> recipients = transaction.getRecipients();
152  std::vector<CRecipient> vecSend;
153 
154  if(recipients.empty())
155  {
156  return OK;
157  }
158 
159  QSet<QString> setAddress; // Used to detect duplicates
160  int nAddresses = 0;
161 
162  // Pre-check input data for validity
163  for (const SendCoinsRecipient &rcp : recipients)
164  {
165  if (rcp.fSubtractFeeFromAmount)
166  fSubtractFeeFromAmount = true;
167  { // User-entered bitcoin address / amount:
168  if(!validateAddress(rcp.address))
169  {
170  return InvalidAddress;
171  }
172  if(rcp.amount <= 0)
173  {
174  return InvalidAmount;
175  }
176  setAddress.insert(rcp.address);
177  ++nAddresses;
178 
179  CScript scriptPubKey = GetScriptForDestination(DecodeDestination(rcp.address.toStdString()));
180  CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
181  vecSend.push_back(recipient);
182 
183  total += rcp.amount;
184  }
185  }
186  if(setAddress.size() != nAddresses)
187  {
188  return DuplicateAddress;
189  }
190 
191  CAmount nBalance = m_wallet->getAvailableBalance(coinControl);
192 
193  if(total > nBalance)
194  {
195  return AmountExceedsBalance;
196  }
197 
198  {
199  CAmount nFeeRequired = 0;
200  int nChangePosRet = -1;
202 
203  auto& newTx = transaction.getWtx();
204  newTx = m_wallet->createTransaction(vecSend, coinControl, !wallet().privateKeysDisabled() /* sign */, nChangePosRet, nFeeRequired, error);
205  transaction.setTransactionFee(nFeeRequired);
206  if (fSubtractFeeFromAmount && newTx)
207  transaction.reassignAmounts(nChangePosRet);
208 
209  if(!newTx)
210  {
211  if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
212  {
214  }
215  Q_EMIT message(tr("Send Coins"), QString::fromStdString(error.translated),
218  }
219 
220  // Reject absurdly high fee. (This can never happen because the
221  // wallet never creates transactions with fee greater than
222  // m_default_max_tx_fee. This merely a belt-and-suspenders check).
223  if (nFeeRequired > m_wallet->getDefaultMaxTxFee()) {
224  return AbsurdFee;
225  }
226  }
227 
228  return SendCoinsReturn(OK);
229 }
230 
232 {
233  QByteArray transaction_array; /* store serialized transaction */
234 
235  {
236  std::vector<std::pair<std::string, std::string>> vOrderForm;
237  for (const SendCoinsRecipient &rcp : transaction.getRecipients())
238  {
239  if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
240  vOrderForm.emplace_back("Message", rcp.message.toStdString());
241  }
242 
243  auto& newTx = transaction.getWtx();
244  wallet().commitTransaction(newTx, {} /* mapValue */, std::move(vOrderForm));
245 
247  ssTx << *newTx;
248  transaction_array.append((const char*)&(ssTx[0]), ssTx.size());
249  }
250 
251  // Add addresses / update labels that we've sent to the address book,
252  // and emit coinsSent signal for each recipient
253  for (const SendCoinsRecipient &rcp : transaction.getRecipients())
254  {
255  {
256  std::string strAddress = rcp.address.toStdString();
257  CTxDestination dest = DecodeDestination(strAddress);
258  std::string strLabel = rcp.label.toStdString();
259  {
260  // Check if we have a new address or an updated label
261  std::string name;
262  if (!m_wallet->getAddress(
263  dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
264  {
265  m_wallet->setAddressBook(dest, strLabel, "send");
266  }
267  else if (name != strLabel)
268  {
269  m_wallet->setAddressBook(dest, strLabel, ""); // "" means don't change purpose
270  }
271  }
272  }
273  Q_EMIT coinsSent(this, rcp, transaction_array);
274  }
275 
276  checkBalanceChanged(m_wallet->getBalances()); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
277 
278  return SendCoinsReturn(OK);
279 }
280 
282 {
283  return optionsModel;
284 }
285 
287 {
288  return addressTableModel;
289 }
290 
292 {
293  return transactionTableModel;
294 }
295 
297 {
299 }
300 
302 {
303  if(!m_wallet->isCrypted())
304  {
305  return Unencrypted;
306  }
307  else if(m_wallet->isLocked())
308  {
309  return Locked;
310  }
311  else
312  {
313  return Unlocked;
314  }
315 }
316 
318 {
319  return m_wallet->encryptWallet(passphrase);
320 }
321 
322 bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
323 {
324  if(locked)
325  {
326  // Lock
327  return m_wallet->lock();
328  }
329  else
330  {
331  // Unlock
332  return m_wallet->unlock(passPhrase);
333  }
334 }
335 
336 bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
337 {
338  m_wallet->lock(); // Make sure wallet is locked before attempting pass change
339  return m_wallet->changeWalletPassphrase(oldPass, newPass);
340 }
341 
342 // Handlers for core signals
343 static void NotifyUnload(WalletModel* walletModel)
344 {
345  qDebug() << "NotifyUnload";
346  bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
347  assert(invoked);
348 }
349 
350 static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
351 {
352  qDebug() << "NotifyKeyStoreStatusChanged";
353  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
354  assert(invoked);
355 }
356 
357 static void NotifyAddressBookChanged(WalletModel *walletmodel,
358  const CTxDestination &address, const std::string &label, bool isMine,
359  const std::string &purpose, ChangeType status)
360 {
361  QString strAddress = QString::fromStdString(EncodeDestination(address));
362  QString strLabel = QString::fromStdString(label);
363  QString strPurpose = QString::fromStdString(purpose);
364 
365  qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
366  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
367  Q_ARG(QString, strAddress),
368  Q_ARG(QString, strLabel),
369  Q_ARG(bool, isMine),
370  Q_ARG(QString, strPurpose),
371  Q_ARG(int, status));
372  assert(invoked);
373 }
374 
375 static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
376 {
377  Q_UNUSED(hash);
378  Q_UNUSED(status);
379  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
380  assert(invoked);
381 }
382 
383 static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
384 {
385  // emits signal "showProgress"
386  bool invoked = QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
387  Q_ARG(QString, QString::fromStdString(title)),
388  Q_ARG(int, nProgress));
389  assert(invoked);
390 }
391 
392 static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
393 {
394  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
395  Q_ARG(bool, fHaveWatchonly));
396  assert(invoked);
397 }
398 
399 static void NotifyCanGetAddressesChanged(WalletModel* walletmodel)
400 {
401  bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
402  assert(invoked);
403 }
404 
406 {
407  // Connect signals to wallet
408  m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this));
409  m_handler_status_changed = m_wallet->handleStatusChanged(std::bind(&NotifyKeyStoreStatusChanged, this));
410  m_handler_address_book_changed = m_wallet->handleAddressBookChanged(std::bind(NotifyAddressBookChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
411  m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
412  m_handler_show_progress = m_wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
413  m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged(std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1));
414  m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged(std::bind(NotifyCanGetAddressesChanged, this));
415 }
416 
418 {
419  // Disconnect signals from wallet
420  m_handler_unload->disconnect();
421  m_handler_status_changed->disconnect();
422  m_handler_address_book_changed->disconnect();
423  m_handler_transaction_changed->disconnect();
424  m_handler_show_progress->disconnect();
425  m_handler_watch_only_changed->disconnect();
426  m_handler_can_get_addrs_changed->disconnect();
427 }
428 
429 // WalletModel::UnlockContext implementation
431 {
432  bool was_locked = getEncryptionStatus() == Locked;
433  if(was_locked)
434  {
435  // Request UI to unlock wallet
436  Q_EMIT requireUnlock();
437  }
438  // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
439  bool valid = getEncryptionStatus() != Locked;
440 
441  return UnlockContext(this, valid, was_locked);
442 }
443 
444 WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
445  wallet(_wallet),
446  valid(_valid),
447  relock(_relock)
448 {
449 }
450 
452 {
453  if(valid && relock)
454  {
455  wallet->setWalletLocked(true);
456  }
457 }
458 
460 {
461  // Transfer context; old object no longer relocks wallet
462  *this = rhs;
463  rhs.relock = false;
464 }
465 
466 void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
467 {
468  vReceiveRequests = m_wallet->getDestValues("rr"); // receive request
469 }
470 
471 bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
472 {
473  CTxDestination dest = DecodeDestination(sAddress);
474 
475  std::stringstream ss;
476  ss << nId;
477  std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
478 
479  if (sRequest.empty())
480  return m_wallet->eraseDestData(dest, key);
481  else
482  return m_wallet->addDestData(dest, key, sRequest);
483 }
484 
485 bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
486 {
487  CCoinControl coin_control;
488  coin_control.m_signal_bip125_rbf = true;
489  std::vector<bilingual_str> errors;
490  CAmount old_fee;
491  CAmount new_fee;
493  if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) {
494  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
495  (errors.size() ? QString::fromStdString(errors[0].translated) : "") +")");
496  return false;
497  }
498 
499  const bool create_psbt = m_wallet->privateKeysDisabled();
500 
501  // allow a user based fee verification
502  QString questionString = create_psbt ? tr("Do you want to draft a transaction with fee increase?") : tr("Do you want to increase the fee?");
503  questionString.append("<br />");
504  questionString.append("<table style=\"text-align: left;\">");
505  questionString.append("<tr><td>");
506  questionString.append(tr("Current fee:"));
507  questionString.append("</td><td>");
508  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee));
509  questionString.append("</td></tr><tr><td>");
510  questionString.append(tr("Increase:"));
511  questionString.append("</td><td>");
512  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee));
513  questionString.append("</td></tr><tr><td>");
514  questionString.append(tr("New fee:"));
515  questionString.append("</td><td>");
516  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee));
517  questionString.append("</td></tr></table>");
518 
519  // Display warning in the "Confirm fee bump" window if the "Coin Control Features" option is enabled
520  if (getOptionsModel()->getCoinControlFeatures()) {
521  questionString.append("<br><br>");
522  questionString.append(tr("Warning: This may pay the additional fee by reducing change outputs or adding inputs, when necessary. It may add a new change output if one does not already exist. These changes may potentially leak privacy."));
523  }
524 
525  SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), questionString);
526  confirmationDialog.exec();
527  QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
528 
529  // cancel sign&broadcast if user doesn't want to bump the fee
530  if (retval != QMessageBox::Yes) {
531  return false;
532  }
533 
535  if(!ctx.isValid())
536  {
537  return false;
538  }
539 
540  // Short-circuit if we are returning a bumped transaction PSBT to clipboard
541  if (create_psbt) {
542  PartiallySignedTransaction psbtx(mtx);
543  bool complete = false;
544  const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
545  if (err != TransactionError::OK || complete) {
546  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
547  return false;
548  }
549  // Serialize the PSBT
551  ssTx << psbtx;
552  GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
553  Q_EMIT message(tr("PSBT copied"), "Copied to clipboard", CClientUIInterface::MSG_INFORMATION);
554  return true;
555  }
556 
557  // sign bumped transaction
558  if (!m_wallet->signBumpTransaction(mtx)) {
559  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));
560  return false;
561  }
562  // commit the bumped transaction
563  if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
564  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
565  QString::fromStdString(errors[0].translated)+")");
566  return false;
567  }
568  return true;
569 }
570 
572 {
573  return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
574 }
575 
577 {
578  return QString::fromStdString(m_wallet->getWalletName());
579 }
580 
582 {
583  const QString name = getWalletName();
584  return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
585 }
586 
588 {
589  return m_node.walletClient().getWallets().size() > 1;
590 }
591 
592 void WalletModel::refresh(bool pk_hash_only)
593 {
594  addressTableModel = new AddressTableModel(this, pk_hash_only);
595 }
596 
598 {
600 }
WalletModel::changePassphrase
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
Definition: walletmodel.cpp:336
WalletModel::recentRequestsTableModel
RecentRequestsTableModel * recentRequestsTableModel
Definition: walletmodel.h:182
WalletModel::updateStatus
void updateStatus()
Definition: walletmodel.cpp:78
CClientUIInterface::MSG_INFORMATION
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:66
WalletModel::getOptionsModel
OptionsModel * getOptionsModel()
Definition: walletmodel.cpp:281
WalletModel::refresh
void refresh(bool pk_hash_only=false)
Definition: walletmodel.cpp:592
CCoinControl::m_signal_bip125_rbf
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
Definition: coincontrol.h:43
transactiontablemodel.h
WalletModel::bumpFee
bool bumpFee(uint256 hash, uint256 &new_hash)
Definition: walletmodel.cpp:485
ArgsManager::GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:515
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:281
WalletModel::getLastBlockProcessed
uint256 getLastBlockProcessed() const
Definition: walletmodel.cpp:597
SendConfirmationDialog
Definition: sendcoinsdialog.h:113
WalletModel::EncryptionStatus
EncryptionStatus
Definition: walletmodel.h:72
wallet.h
WalletModel::transactionTableModel
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:181
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
WalletModel::m_handler_status_changed
std::unique_ptr< interfaces::Handler > m_handler_status_changed
Definition: walletmodel.h:164
WalletModel::m_handler_show_progress
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: walletmodel.h:167
key_io.h
WalletModel::TransactionCreationFailed
@ TransactionCreationFailed
Definition: walletmodel.h:67
sendcoinsdialog.h
walletmodel.h
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:307
AddressTableModel
Qt model of the address book in the core.
Definition: addresstablemodel.h:23
bilingual_str
Bilingual messages:
Definition: translation.h:16
WalletModel::isWalletEnabled
static bool isWalletEnabled()
Definition: walletmodel.cpp:571
WalletModel::getAddressTableModel
AddressTableModel * getAddressTableModel()
Definition: walletmodel.cpp:286
WalletModel::DuplicateAddress
@ DuplicateAddress
Definition: walletmodel.h:66
CCoinControl
Coin Control Features.
Definition: coincontrol.h:23
WalletModel::sendCoins
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
Definition: walletmodel.cpp:231
WalletModel::AmountWithFeeExceedsBalance
@ AmountWithFeeExceedsBalance
Definition: walletmodel.h:65
WalletModel::Unlocked
@ Unlocked
Definition: walletmodel.h:76
handler.h
WalletModel::AbsurdFee
@ AbsurdFee
Definition: walletmodel.h:68
WalletModel::m_handler_watch_only_changed
std::unique_ptr< interfaces::Handler > m_handler_watch_only_changed
Definition: walletmodel.h:168
WalletModel::m_handler_transaction_changed
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: walletmodel.h:166
WalletModel::isMultiwallet
bool isMultiwallet()
Definition: walletmodel.cpp:587
WalletModel::m_wallet
std::unique_ptr< interfaces::Wallet > m_wallet
Definition: walletmodel.h:162
interfaces::WalletBalances::balanceChanged
bool balanceChanged(const WalletBalances &prev) const
Definition: wallet.h:359
BitcoinUnits::formatHtmlWithUnit
static QString formatHtmlWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as HTML string (with unit)
Definition: bitcoinunits.cpp:153
WalletModel::getTransactionTableModel
TransactionTableModel * getTransactionTableModel()
Definition: walletmodel.cpp:291
wallet
Definition: interfaces.cpp:48
WalletModel::~WalletModel
~WalletModel()
Definition: walletmodel.cpp:60
WalletModel::m_cached_last_update_tip
uint256 m_cached_last_update_tip
Definition: walletmodel.h:190
EncodeBase64
std::string EncodeBase64(Span< const unsigned char > input)
Definition: strencodings.cpp:131
bitcoin-config.h
WalletModel::requestUnlock
UnlockContext requestUnlock()
Definition: walletmodel.cpp:430
WalletModel::prepareTransaction
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl &coinControl)
Definition: walletmodel.cpp:147
WalletModel::setClientModel
void setClientModel(ClientModel *client_model)
Definition: walletmodel.cpp:72
GUIUtil::setClipboard
void setClipboard(const QString &str)
Definition: guiutil.cpp:629
NotifyCanGetAddressesChanged
static void NotifyCanGetAddressesChanged(WalletModel *walletmodel)
Definition: walletmodel.cpp:399
interfaces::WalletClient::getWallets
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
WalletModel::m_handler_can_get_addrs_changed
std::unique_ptr< interfaces::Handler > m_handler_can_get_addrs_changed
Definition: walletmodel.h:169
WalletModel::addressTableModel
AddressTableModel * addressTableModel
Definition: walletmodel.h:180
SendCoinsRecipient
Definition: sendcoinsrecipient.h:19
OptionsModel
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:39
TransactionError
TransactionError
Definition: error.h:22
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:60
WalletModel::wallet
interfaces::Wallet & wallet() const
Definition: walletmodel.h:146
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
prevector::push_back
void push_back(const T &value)
Definition: prevector.h:437
interfaces::WalletBalances
Collection of wallet balances.
Definition: wallet.h:349
WalletModel::AmountExceedsBalance
@ AmountExceedsBalance
Definition: walletmodel.h:64
NotifyAddressBookChanged
static void NotifyAddressBookChanged(WalletModel *walletmodel, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)
Definition: walletmodel.cpp:357
WalletModel::m_handler_address_book_changed
std::unique_ptr< interfaces::Handler > m_handler_address_book_changed
Definition: walletmodel.h:165
WalletModel::encryptionStatusChanged
void encryptionStatusChanged()
WalletModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: walletmodel.cpp:417
interfaces::Wallet::commitTransaction
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
WalletModel::m_cached_balances
interfaces::WalletBalances m_cached_balances
Definition: walletmodel.h:185
WalletModel::validateAddress
bool validateAddress(const QString &address)
Definition: walletmodel.cpp:142
WalletModel::updateWatchOnlyFlag
void updateWatchOnlyFlag(bool fHaveWatchonly)
Definition: walletmodel.cpp:136
WalletModel::saveReceiveRequest
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
Definition: walletmodel.cpp:471
WalletModel::message
void message(const QString &title, const QString &message, unsigned int style)
WalletModelTransaction::setTransactionFee
void setTransactionFee(const CAmount &newFee)
Definition: walletmodeltransaction.cpp:39
node.h
RecentRequestsTableModel
Model for list of recently generated payment requests / bitcoin: URIs.
Definition: recentrequeststablemodel.h:50
recentrequeststablemodel.h
WalletModel::setWalletEncrypted
bool setWalletEncrypted(const SecureString &passphrase)
Definition: walletmodel.cpp:317
interfaces::Node::walletClient
virtual WalletClient & walletClient()=0
Get wallet client.
WalletModel::getEncryptionStatus
EncryptionStatus getEncryptionStatus() const
Definition: walletmodel.cpp:301
WalletModel::Unencrypted
@ Unencrypted
Definition: walletmodel.h:74
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
WalletModel::loadReceiveRequests
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
Definition: walletmodel.cpp:466
guiutil.h
WalletModel::getWalletName
QString getWalletName() const
Definition: walletmodel.cpp:576
WalletModel::coinsSent
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
m_node
NodeContext & m_node
Definition: interfaces.cpp:710
interfaces::Wallet::fillPSBT
virtual TransactionError fillPSBT(int sighash_type, bool sign, bool bip32derivs, PartiallySignedTransaction &psbtx, bool &complete, size_t *n_signed)=0
Fill PSBT.
uint256
256-bit opaque blob.
Definition: uint256.h:124
WalletModel::checkBalanceChanged
void checkBalanceChanged(const interfaces::WalletBalances &new_balances)
Definition: walletmodel.cpp:115
WalletModel::getRecentRequestsTableModel
RecentRequestsTableModel * getRecentRequestsTableModel()
Definition: walletmodel.cpp:296
DecodeDestination
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
Definition: key_io.cpp:246
WalletModel::Locked
@ Locked
Definition: walletmodel.h:75
WalletModelTransaction::getRecipients
QList< SendCoinsRecipient > getRecipients() const
Definition: walletmodeltransaction.cpp:19
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
CDataStream::size
size_type size() const
Definition: streams.h:255
NotifyKeyStoreStatusChanged
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
Definition: walletmodel.cpp:350
name
const char * name
Definition: rest.cpp:42
ui_interface.h
system.h
CClientUIInterface::MSG_ERROR
@ MSG_ERROR
Definition: ui_interface.h:68
ClientModel
Model for Bitcoin network client.
Definition: clientmodel.h:46
SIGHASH_ALL
@ SIGHASH_ALL
Definition: interpreter.h:26
WalletModel::m_handler_unload
std::unique_ptr< interfaces::Handler > m_handler_unload
Definition: walletmodel.h:163
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:26
WalletModel::OK
@ OK
Definition: walletmodel.h:61
guiconstants.h
WalletModel::optionsModel
OptionsModel * optionsModel
Definition: walletmodel.h:178
WalletModel::updateTransaction
void updateTransaction()
Definition: walletmodel.cpp:123
SendConfirmationDialog::exec
int exec() override
Definition: sendcoinsdialog.cpp:983
WalletModel::UnlockContext
Definition: walletmodel.h:114
translation.h
WalletModel::InvalidAmount
@ InvalidAmount
Definition: walletmodel.h:62
WalletModel::UnlockContext::UnlockContext
UnlockContext(WalletModel *wallet, bool valid, bool relock)
Definition: walletmodel.cpp:444
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:391
gArgs
ArgsManager gArgs
Definition: system.cpp:79
NotifyTransactionChanged
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
Definition: walletmodel.cpp:375
WalletModel::timer
QTimer * timer
Definition: walletmodel.h:187
WalletModel::InvalidAddress
@ InvalidAddress
Definition: walletmodel.h:63
WalletModel::fForceCheckBalanceChanged
bool fForceCheckBalanceChanged
Definition: walletmodel.h:174
WalletModel::fHaveWatchOnly
bool fHaveWatchOnly
Definition: walletmodel.h:173
TransactionError::OK
@ OK
No error.
NotifyUnload
static void NotifyUnload(WalletModel *walletModel)
Definition: walletmodel.cpp:343
WalletModel::requireUnlock
void requireUnlock()
m_wallet
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:499
WalletModel::SendCoinsReturn
Definition: walletmodel.h:90
WalletModel::m_client_model
ClientModel * m_client_model
Definition: walletmodel.h:170
WalletModel::updateAddressBook
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Definition: walletmodel.cpp:129
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:212
node
Definition: interfaces.cpp:64
IsValidDestinationString
bool IsValidDestinationString(const std::string &str, const CChainParams &params)
Definition: key_io.cpp:257
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:204
WalletModel::m_node
interfaces::Node & m_node
Definition: walletmodel.h:171
SER_NETWORK
@ SER_NETWORK
Definition: serialize.h:166
WalletModel::subscribeToCoreSignals
void subscribeToCoreSignals()
Definition: walletmodel.cpp:405
WalletModel::startPollBalance
void startPollBalance()
Definition: walletmodel.cpp:65
optionsmodel.h
ShowProgress
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
Definition: walletmodel.cpp:383
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:50
AddressTableModel::updateEntry
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Definition: addresstablemodel.cpp:336
WalletModel::getDisplayName
QString getDisplayName() const
Definition: walletmodel.cpp:581
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:344
NotifyWatchonlyChanged
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
Definition: walletmodel.cpp:392
WalletModel::WalletModel
WalletModel(std::unique_ptr< interfaces::Wallet > wallet, ClientModel &client_model, const PlatformStyle *platformStyle, QObject *parent=nullptr)
Definition: walletmodel.cpp:40
coincontrol.h
WalletModel::UnlockContext::CopyFrom
void CopyFrom(UnlockContext &&rhs)
Definition: walletmodel.cpp:459
WalletModel::balanceChanged
void balanceChanged(const interfaces::WalletBalances &balances)
PlatformStyle
Definition: platformstyle.h:13
CDataStream::str
std::string str() const
Definition: streams.h:242
ClientModel::getBestBlockHash
uint256 getBestBlockHash()
Definition: clientmodel.cpp:122
WalletModel::pollBalanceChanged
void pollBalanceChanged()
Definition: walletmodel.cpp:87
CRecipient
Definition: wallet.h:211
assert
assert(std::addressof(::ChainstateActive().CoinsTip())==std::addressof(coins_cache))
addresstablemodel.h
WalletModelTransaction::getWtx
CTransactionRef & getWtx()
Definition: walletmodeltransaction.cpp:24
WalletModelTransaction
Data model for a walletmodel transaction.
Definition: walletmodeltransaction.h:22
WalletModel::notifyWatchonlyChanged
void notifyWatchonlyChanged(bool fHaveWatchonly)
WalletModel::cachedEncryptionStatus
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:186
WalletModel::setWalletLocked
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
Definition: walletmodel.cpp:322
EncodeDestination
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:241
clientmodel.h
ctx
static secp256k1_context * ctx
Definition: tests.c:36
WalletModel::UnlockContext::~UnlockContext
~UnlockContext()
Definition: walletmodel.cpp:451
WalletModelTransaction::reassignAmounts
void reassignAmounts(int nChangePosRet)
Definition: walletmodeltransaction.cpp:44
MODEL_UPDATE_DELAY
static const int MODEL_UPDATE_DELAY
Definition: guiconstants.h:11
PROTOCOL_VERSION
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:12
DEFAULT_DISABLE_WALLET
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:93
paymentserver.h