Bitcoin Core  26.1.0
P2P Digital Currency
walletmodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 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 <common/args.h> // for GetBoolArg
22 #include <interfaces/handler.h>
23 #include <interfaces/node.h>
24 #include <key_io.h>
25 #include <node/interface_ui.h>
26 #include <psbt.h>
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  timer(new QTimer(this))
50 {
51  fHaveWatchOnly = m_wallet->haveWatchOnly();
53  transactionTableModel = new TransactionTableModel(platformStyle, this);
55 
57 }
58 
60 {
62 }
63 
65 {
66  // Update the cached balance right away, so every view can make use of it,
67  // so them don't need to waste resources recalculating it.
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  return m_cached_balances;
132 }
133 
135 {
136  // Balance and number of transactions might have changed
138 }
139 
140 void WalletModel::updateAddressBook(const QString &address, const QString &label,
141  bool isMine, wallet::AddressPurpose purpose, int status)
142 {
144  addressTableModel->updateEntry(address, label, isMine, purpose, status);
145 }
146 
147 void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
148 {
149  fHaveWatchOnly = fHaveWatchonly;
150  Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
151 }
152 
153 bool WalletModel::validateAddress(const QString& address) const
154 {
155  return IsValidDestinationString(address.toStdString());
156 }
157 
159 {
160  CAmount total = 0;
161  bool fSubtractFeeFromAmount = false;
162  QList<SendCoinsRecipient> recipients = transaction.getRecipients();
163  std::vector<CRecipient> vecSend;
164 
165  if(recipients.empty())
166  {
167  return OK;
168  }
169 
170  QSet<QString> setAddress; // Used to detect duplicates
171  int nAddresses = 0;
172 
173  // Pre-check input data for validity
174  for (const SendCoinsRecipient &rcp : recipients)
175  {
176  if (rcp.fSubtractFeeFromAmount)
177  fSubtractFeeFromAmount = true;
178  { // User-entered bitcoin address / amount:
179  if(!validateAddress(rcp.address))
180  {
181  return InvalidAddress;
182  }
183  if(rcp.amount <= 0)
184  {
185  return InvalidAmount;
186  }
187  setAddress.insert(rcp.address);
188  ++nAddresses;
189 
190  CRecipient recipient{DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount};
191  vecSend.push_back(recipient);
192 
193  total += rcp.amount;
194  }
195  }
196  if(setAddress.size() != nAddresses)
197  {
198  return DuplicateAddress;
199  }
200 
201  // If no coin was manually selected, use the cached balance
202  // Future: can merge this call with 'createTransaction'.
203  CAmount nBalance = getAvailableBalance(&coinControl);
204 
205  if(total > nBalance)
206  {
207  return AmountExceedsBalance;
208  }
209 
210  try {
211  CAmount nFeeRequired = 0;
212  int nChangePosRet = -1;
213 
214  auto& newTx = transaction.getWtx();
215  const auto& res = m_wallet->createTransaction(vecSend, coinControl, /*sign=*/!wallet().privateKeysDisabled(), nChangePosRet, nFeeRequired);
216  newTx = res ? *res : nullptr;
217  transaction.setTransactionFee(nFeeRequired);
218  if (fSubtractFeeFromAmount && newTx)
219  transaction.reassignAmounts(nChangePosRet);
220 
221  if(!newTx)
222  {
223  if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
224  {
226  }
227  Q_EMIT message(tr("Send Coins"), QString::fromStdString(util::ErrorString(res).translated),
230  }
231 
232  // Reject absurdly high fee. (This can never happen because the
233  // wallet never creates transactions with fee greater than
234  // m_default_max_tx_fee. This merely a belt-and-suspenders check).
235  if (nFeeRequired > m_wallet->getDefaultMaxTxFee()) {
236  return AbsurdFee;
237  }
238  } catch (const std::runtime_error& err) {
239  // Something unexpected happened, instruct user to report this bug.
240  Q_EMIT message(tr("Send Coins"), QString::fromStdString(err.what()),
243  }
244 
245  return SendCoinsReturn(OK);
246 }
247 
249 {
250  QByteArray transaction_array; /* store serialized transaction */
251 
252  {
253  std::vector<std::pair<std::string, std::string>> vOrderForm;
254  for (const SendCoinsRecipient &rcp : transaction.getRecipients())
255  {
256  if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
257  vOrderForm.emplace_back("Message", rcp.message.toStdString());
258  }
259 
260  auto& newTx = transaction.getWtx();
261  wallet().commitTransaction(newTx, /*value_map=*/{}, std::move(vOrderForm));
262 
264  ssTx << *newTx;
265  transaction_array.append((const char*)ssTx.data(), ssTx.size());
266  }
267 
268  // Add addresses / update labels that we've sent to the address book,
269  // and emit coinsSent signal for each recipient
270  for (const SendCoinsRecipient &rcp : transaction.getRecipients())
271  {
272  {
273  std::string strAddress = rcp.address.toStdString();
274  CTxDestination dest = DecodeDestination(strAddress);
275  std::string strLabel = rcp.label.toStdString();
276  {
277  // Check if we have a new address or an updated label
278  std::string name;
279  if (!m_wallet->getAddress(
280  dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
281  {
282  m_wallet->setAddressBook(dest, strLabel, wallet::AddressPurpose::SEND);
283  }
284  else if (name != strLabel)
285  {
286  m_wallet->setAddressBook(dest, strLabel, {}); // {} means don't change purpose
287  }
288  }
289  }
290  Q_EMIT coinsSent(this, rcp, transaction_array);
291  }
292 
293  checkBalanceChanged(m_wallet->getBalances()); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
294 }
295 
297 {
298  return optionsModel;
299 }
300 
302 {
303  return addressTableModel;
304 }
305 
307 {
308  return transactionTableModel;
309 }
310 
312 {
314 }
315 
317 {
318  if(!m_wallet->isCrypted())
319  {
320  // A previous bug allowed for watchonly wallets to be encrypted (encryption keys set, but nothing is actually encrypted).
321  // To avoid misrepresenting the encryption status of such wallets, we only return NoKeys for watchonly wallets that are unencrypted.
322  if (m_wallet->privateKeysDisabled()) {
323  return NoKeys;
324  }
325  return Unencrypted;
326  }
327  else if(m_wallet->isLocked())
328  {
329  return Locked;
330  }
331  else
332  {
333  return Unlocked;
334  }
335 }
336 
338 {
339  return m_wallet->encryptWallet(passphrase);
340 }
341 
342 bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
343 {
344  if(locked)
345  {
346  // Lock
347  return m_wallet->lock();
348  }
349  else
350  {
351  // Unlock
352  return m_wallet->unlock(passPhrase);
353  }
354 }
355 
356 bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
357 {
358  m_wallet->lock(); // Make sure wallet is locked before attempting pass change
359  return m_wallet->changeWalletPassphrase(oldPass, newPass);
360 }
361 
362 // Handlers for core signals
363 static void NotifyUnload(WalletModel* walletModel)
364 {
365  qDebug() << "NotifyUnload";
366  bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
367  assert(invoked);
368 }
369 
370 static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
371 {
372  qDebug() << "NotifyKeyStoreStatusChanged";
373  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
374  assert(invoked);
375 }
376 
377 static void NotifyAddressBookChanged(WalletModel *walletmodel,
378  const CTxDestination &address, const std::string &label, bool isMine,
379  wallet::AddressPurpose purpose, ChangeType status)
380 {
381  QString strAddress = QString::fromStdString(EncodeDestination(address));
382  QString strLabel = QString::fromStdString(label);
383 
384  qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + QString::number(static_cast<uint8_t>(purpose)) + " status=" + QString::number(status);
385  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook",
386  Q_ARG(QString, strAddress),
387  Q_ARG(QString, strLabel),
388  Q_ARG(bool, isMine),
389  Q_ARG(wallet::AddressPurpose, purpose),
390  Q_ARG(int, status));
391  assert(invoked);
392 }
393 
394 static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
395 {
396  Q_UNUSED(hash);
397  Q_UNUSED(status);
398  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
399  assert(invoked);
400 }
401 
402 static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
403 {
404  // emits signal "showProgress"
405  bool invoked = QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
406  Q_ARG(QString, QString::fromStdString(title)),
407  Q_ARG(int, nProgress));
408  assert(invoked);
409 }
410 
411 static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
412 {
413  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
414  Q_ARG(bool, fHaveWatchonly));
415  assert(invoked);
416 }
417 
418 static void NotifyCanGetAddressesChanged(WalletModel* walletmodel)
419 {
420  bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
421  assert(invoked);
422 }
423 
425 {
426  // Connect signals to wallet
427  m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this));
428  m_handler_status_changed = m_wallet->handleStatusChanged(std::bind(&NotifyKeyStoreStatusChanged, this));
429  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));
430  m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
431  m_handler_show_progress = m_wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
432  m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged(std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1));
433  m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged(std::bind(NotifyCanGetAddressesChanged, this));
434 }
435 
437 {
438  // Disconnect signals from wallet
439  m_handler_unload->disconnect();
440  m_handler_status_changed->disconnect();
441  m_handler_address_book_changed->disconnect();
442  m_handler_transaction_changed->disconnect();
443  m_handler_show_progress->disconnect();
444  m_handler_watch_only_changed->disconnect();
445  m_handler_can_get_addrs_changed->disconnect();
446 }
447 
448 // WalletModel::UnlockContext implementation
450 {
451  bool was_locked = getEncryptionStatus() == Locked;
452  if(was_locked)
453  {
454  // Request UI to unlock wallet
455  Q_EMIT requireUnlock();
456  }
457  // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
458  bool valid = getEncryptionStatus() != Locked;
459 
460  return UnlockContext(this, valid, was_locked);
461 }
462 
463 WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
464  wallet(_wallet),
465  valid(_valid),
466  relock(_relock)
467 {
468 }
469 
471 {
472  if(valid && relock)
473  {
474  wallet->setWalletLocked(true);
475  }
476 }
477 
478 bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
479 {
480  CCoinControl coin_control;
481  coin_control.m_signal_bip125_rbf = true;
482  std::vector<bilingual_str> errors;
483  CAmount old_fee;
484  CAmount new_fee;
486  if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) {
487  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
488  (errors.size() ? QString::fromStdString(errors[0].translated) : "") +")");
489  return false;
490  }
491 
492  // allow a user based fee verification
493  /*: Asks a user if they would like to manually increase the fee of a transaction that has already been created. */
494  QString questionString = tr("Do you want to increase the fee?");
495  questionString.append("<br />");
496  questionString.append("<table style=\"text-align: left;\">");
497  questionString.append("<tr><td>");
498  questionString.append(tr("Current fee:"));
499  questionString.append("</td><td>");
500  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee));
501  questionString.append("</td></tr><tr><td>");
502  questionString.append(tr("Increase:"));
503  questionString.append("</td><td>");
504  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee));
505  questionString.append("</td></tr><tr><td>");
506  questionString.append(tr("New fee:"));
507  questionString.append("</td><td>");
508  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee));
509  questionString.append("</td></tr></table>");
510 
511  // Display warning in the "Confirm fee bump" window if the "Coin Control Features" option is enabled
512  if (getOptionsModel()->getCoinControlFeatures()) {
513  questionString.append("<br><br>");
514  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."));
515  }
516 
517  const bool enable_send{!wallet().privateKeysDisabled() || wallet().hasExternalSigner()};
518  const bool always_show_unsigned{getOptionsModel()->getEnablePSBTControls()};
519  auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, enable_send, always_show_unsigned, nullptr);
520  confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
521  // TODO: Replace QDialog::exec() with safer QDialog::show().
522  const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());
523 
524  // cancel sign&broadcast if user doesn't want to bump the fee
525  if (retval != QMessageBox::Yes && retval != QMessageBox::Save) {
526  return false;
527  }
528 
530  if(!ctx.isValid())
531  {
532  return false;
533  }
534 
535  // Short-circuit if we are returning a bumped transaction PSBT to clipboard
536  if (retval == QMessageBox::Save) {
537  // "Create Unsigned" clicked
538  PartiallySignedTransaction psbtx(mtx);
539  bool complete = false;
540  const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, /*sign=*/false, /*bip32derivs=*/true, nullptr, psbtx, complete);
541  if (err != TransactionError::OK || complete) {
542  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
543  return false;
544  }
545  // Serialize the PSBT
547  ssTx << psbtx;
548  GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
549  Q_EMIT message(tr("PSBT copied"), tr("Copied to clipboard", "Fee-bump PSBT saved"), CClientUIInterface::MSG_INFORMATION);
550  return true;
551  }
552 
553  assert(!m_wallet->privateKeysDisabled() || wallet().hasExternalSigner());
554 
555  // sign bumped transaction
556  if (!m_wallet->signBumpTransaction(mtx)) {
557  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));
558  return false;
559  }
560  // commit the bumped transaction
561  if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
562  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
563  QString::fromStdString(errors[0].translated)+")");
564  return false;
565  }
566  return true;
567 }
568 
569 bool WalletModel::displayAddress(std::string sAddress) const
570 {
571  CTxDestination dest = DecodeDestination(sAddress);
572  bool res = false;
573  try {
574  res = m_wallet->displayAddress(dest);
575  } catch (const std::runtime_error& e) {
576  QMessageBox::critical(nullptr, tr("Can't display address"), e.what());
577  }
578  return res;
579 }
580 
582 {
583  return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
584 }
585 
587 {
588  return QString::fromStdString(m_wallet->getWalletName());
589 }
590 
592 {
593  const QString name = getWalletName();
594  return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
595 }
596 
598 {
599  return m_node.walletLoader().getWallets().size() > 1;
600 }
601 
602 void WalletModel::refresh(bool pk_hash_only)
603 {
604  addressTableModel = new AddressTableModel(this, pk_hash_only);
605 }
606 
608 {
610 }
611 
613 {
614  // No selected coins, return the cached balance
615  if (!control || !control->HasSelected()) {
616  const interfaces::WalletBalances& balances = getCachedBalance();
617  CAmount available_balance = balances.balance;
618  // if wallet private keys are disabled, this is a watch-only wallet
619  // so, let's include the watch-only balance.
620  if (balances.have_watch_only && m_wallet->privateKeysDisabled()) {
621  available_balance += balances.watch_only_balance;
622  }
623  return available_balance;
624  }
625  // Fetch balance from the wallet, taking into account the selected coins
626  return wallet().getAvailableBalance(*control);
627 }
virtual bool privateKeysDisabled()=0
Model for list of recently generated payment requests / bitcoin: URIs.
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:182
Predefined combinations for certain default usage cases.
Definition: interface_ui.h:65
OptionsModel * getOptionsModel() const
interfaces::Wallet & wallet() const
Definition: walletmodel.h:142
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
RecentRequestsTableModel * recentRequestsTableModel
Definition: walletmodel.h:183
std::unique_ptr< interfaces::Handler > m_handler_address_book_changed
Definition: walletmodel.h:166
assert(!tx.IsCoinBase())
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const wallet::CCoinControl &coinControl)
static bool isWalletEnabled()
void startPollBalance()
Definition: walletmodel.cpp:64
bool IsValidDestinationString(const std::string &str, const CChainParams &params)
Definition: key_io.cpp:303
node::NodeContext m_node
Definition: bitcoin-gui.cpp:37
UnlockContext requestUnlock()
std::unique_ptr< interfaces::Handler > m_handler_unload
Definition: walletmodel.h:164
void unsubscribeFromCoreSignals()
static void NotifyAddressBookChanged(WalletModel *walletmodel, const CTxDestination &address, const std::string &label, bool isMine, wallet::AddressPurpose purpose, ChangeType status)
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:561
interfaces::WalletBalances getCachedBalance() const
TransactionTableModel * getTransactionTableModel() const
#define SEND_CONFIRM_DELAY
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:58
uint256 m_cached_last_update_tip
Definition: walletmodel.h:191
static constexpr auto MODEL_UPDATE_DELAY
Definition: guiconstants.h:14
std::string EncodeBase64(Span< const unsigned char > input)
QList< SendCoinsRecipient > getRecipients() const
bool validateAddress(const QString &address) const
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:135
std::unique_ptr< interfaces::Handler > m_handler_status_changed
Definition: walletmodel.h:165
A version of CTransaction with the PSBT format.
Definition: psbt.h:946
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: args.cpp:506
bool HasSelected() const
Returns true if there are pre-selected inputs.
Definition: coincontrol.cpp:15
void updateStatus()
Definition: walletmodel.cpp:84
value_type * data()
Definition: streams.h:234
EncryptionStatus getEncryptionStatus() const
virtual bool hasExternalSigner()=0
void setTransactionFee(const CAmount &newFee)
bool bumpFee(uint256 hash, uint256 &new_hash)
UnlockContext(WalletModel *wallet, bool valid, bool relock)
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
AddressPurpose
Address purpose field that has been been stored with wallet sending and receiving addresses since BIP...
Definition: types.h:60
uint256 getBestBlockHash() EXCLUSIVE_LOCKS_REQUIRED(!m_cached_tip_mutex)
uint256 getLastBlockProcessed() const
static void NotifyCanGetAddressesChanged(WalletModel *walletmodel)
RecentRequestsTableModel * getRecentRequestsTableModel() const
void setClientModel(ClientModel *client_model)
Definition: walletmodel.cpp:78
void updateTransaction()
Collection of wallet balances.
Definition: wallet.h:371
void setClipboard(const QString &str)
Definition: guiutil.cpp:656
const char * name
Definition: rest.cpp:45
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
void reassignAmounts(int nChangePosRet)
std::unique_ptr< interfaces::Wallet > m_wallet
Definition: walletmodel.h:163
bool setWalletEncrypted(const SecureString &passphrase)
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.html#connect-3), that guaranties that all exceptions are handled within the slot.
Definition: guiutil.h:391
void refresh(bool pk_hash_only=false)
void encryptionStatusChanged()
OptionsModel * optionsModel
Definition: walletmodel.h:179
QString getWalletName() const
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:187
bool getEnablePSBTControls() const
Definition: optionsmodel.h:99
UI model for the transaction table of a wallet.
Model for Bitcoin network client.
Definition: clientmodel.h:53
bool isMultiwallet() const
Qt model of the address book in the core.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: walletmodel.h:168
void updateEntry(const QString &address, const QString &label, bool isMine, wallet::AddressPurpose purpose, int status)
Definition: init.h:25
ArgsManager gArgs
Definition: args.cpp:42
virtual CAmount getAvailableBalance(const wallet::CCoinControl &coin_control)=0
Get available balance.
size_type size() const
Definition: streams.h:227
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
Definition: addresstype.h:129
ClientModel * m_client_model
Definition: walletmodel.h:171
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
void updateWatchOnlyFlag(bool fHaveWatchonly)
std::string str() const
Definition: streams.h:214
static void NotifyUnload(WalletModel *walletModel)
256-bit opaque blob.
Definition: uint256.h:106
QTimer * timer
Definition: walletmodel.h:188
bool fForceCheckBalanceChanged
Definition: walletmodel.h:175
std::unique_ptr< interfaces::Handler > m_handler_can_get_addrs_changed
Definition: walletmodel.h:170
void updateAddressBook(const QString &address, const QString &label, bool isMine, wallet::AddressPurpose purpose, int status)
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:40
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
virtual WalletLoader & walletLoader()=0
Get wallet loader.
interfaces::WalletBalances m_cached_balances
Definition: walletmodel.h:186
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:12
WalletModel(std::unique_ptr< interfaces::Wallet > wallet, ClientModel &client_model, const PlatformStyle *platformStyle, QObject *parent=nullptr)
Definition: walletmodel.cpp:43
interfaces::Node & m_node
Definition: walletmodel.h:172
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
void message(const QString &title, const QString &message, unsigned int style)
TransactionError
Definition: error.h:22
void notifyWatchonlyChanged(bool fHaveWatchonly)
Data model for a walletmodel transaction.
bilingual_str ErrorString(const Result< T > &result)
Definition: result.h:81
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:287
QString getDisplayName() const
A mutable version of CTransaction.
Definition: transaction.h:379
virtual TransactionError fillPSBT(int sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
AddressTableModel * getAddressTableModel() const
AddressTableModel * addressTableModel
Definition: walletmodel.h:181
CAmount getAvailableBalance(const wallet::CCoinControl *control)
static QString formatHtmlWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as HTML string (with unit)
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
void sendCoins(WalletModelTransaction &transaction)
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: walletmodel.h:167
bool fHaveWatchOnly
Definition: walletmodel.h:174
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
void checkBalanceChanged(const interfaces::WalletBalances &new_balances)
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
Definition: key_io.cpp:292
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
std::optional< bool > m_signal_bip125_rbf
Override the wallet&#39;s m_signal_rbf if set.
Definition: coincontrol.h:49
bool balanceChanged(const WalletBalances &prev) const
Definition: wallet.h:381
void balanceChanged(const interfaces::WalletBalances &balances)
Coin Control Features.
Definition: coincontrol.h:28
std::unique_ptr< interfaces::Handler > m_handler_watch_only_changed
Definition: walletmodel.h:169
void pollBalanceChanged()
Definition: walletmodel.cpp:93
void subscribeToCoreSignals()
bool displayAddress(std::string sAddress) const