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