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