Bitcoin Core  22.0.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 }
Model for list of recently generated payment requests / bitcoin: URIs.
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:179
interfaces::Wallet & wallet() const
Definition: walletmodel.h:144
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
RecentRequestsTableModel * recentRequestsTableModel
Definition: walletmodel.h:180
std::unique_ptr< interfaces::Handler > m_handler_address_book_changed
Definition: walletmodel.h:163
assert(!tx.IsCoinBase())
static bool isWalletEnabled()
void startPollBalance()
Definition: walletmodel.cpp:65
Bilingual messages:
Definition: translation.h:16
bool IsValidDestinationString(const std::string &str, const CChainParams &params)
Definition: key_io.cpp:272
UnlockContext requestUnlock()
std::unique_ptr< interfaces::Handler > m_handler_unload
Definition: walletmodel.h:161
void unsubscribeFromCoreSignals()
std::string str() const
Definition: streams.h:242
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:496
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:60
uint256 m_cached_last_update_tip
Definition: walletmodel.h:188
value_type * data()
Definition: streams.h:264
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
QList< SendCoinsRecipient > getRecipients() const
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:95
std::unique_ptr< interfaces::Handler > m_handler_status_changed
Definition: walletmodel.h:162
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
Definition: key_io.cpp:261
A version of CTransaction with the PSBT format.
Definition: psbt.h:391
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:204
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:600
NodeContext & m_node
AddressTableModel * getAddressTableModel()
Coin Control Features.
Definition: coincontrol.h:23
void updateStatus()
Definition: walletmodel.cpp:81
EncryptionStatus getEncryptionStatus() const
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
std::string EncodeBase64(Span< const unsigned char > input)
uint256 getLastBlockProcessed() const
static void NotifyCanGetAddressesChanged(WalletModel *walletmodel)
void push_back(const T &value)
Definition: prevector.h:437
void setClientModel(ClientModel *client_model)
Definition: walletmodel.cpp:75
size_type size() const
Definition: streams.h:255
bool displayAddress(std::string sAddress)
void updateTransaction()
Collection of wallet balances.
Definition: wallet.h:352
void setClipboard(const QString &str)
Definition: guiutil.cpp:638
static QString formatHtmlWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as HTML string (with unit)
const char * name
Definition: rest.cpp:43
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
static void NotifyAddressBookChanged(WalletModel *walletmodel, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)
static secp256k1_context * ctx
Definition: tests.c:42
void reassignAmounts(int nChangePosRet)
std::unique_ptr< interfaces::Wallet > m_wallet
Definition: walletmodel.h:160
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:386
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl &coinControl)
void refresh(bool pk_hash_only=false)
void encryptionStatusChanged()
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
OptionsModel * optionsModel
Definition: walletmodel.h:176
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:351
QString getWalletName() const
TransactionTableModel * getTransactionTableModel()
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:184
std::optional< bool > m_signal_bip125_rbf
Override the wallet&#39;s m_signal_rbf if set.
Definition: coincontrol.h:45
UI model for the transaction table of a wallet.
Model for Bitcoin network client.
Definition: clientmodel.h:47
Qt model of the address book in the core.
static const int MODEL_UPDATE_DELAY
Definition: guiconstants.h:11
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: walletmodel.h:165
ClientModel * m_client_model
Definition: walletmodel.h:168
bool validateAddress(const QString &address)
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
void updateWatchOnlyFlag(bool fHaveWatchonly)
static void NotifyUnload(WalletModel *walletModel)
256-bit opaque blob.
Definition: uint256.h:124
void requireUnlock()
QTimer * timer
Definition: walletmodel.h:185
bool fForceCheckBalanceChanged
Definition: walletmodel.h:172
std::unique_ptr< interfaces::Handler > m_handler_can_get_addrs_changed
Definition: walletmodel.h:167
RecentRequestsTableModel * getRecentRequestsTableModel()
virtual WalletClient & walletClient()=0
Get wallet client.
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:39
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
interfaces::WalletBalances m_cached_balances
Definition: walletmodel.h:183
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:40
interfaces::Node & m_node
Definition: walletmodel.h:169
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
void message(const QString &title, const QString &message, unsigned int style)
ArgsManager gArgs
Definition: system.cpp:84
TransactionError
Definition: error.h:22
void CopyFrom(UnlockContext &&rhs)
void notifyWatchonlyChanged(bool fHaveWatchonly)
Data model for a walletmodel transaction.
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:256
QString getDisplayName() const
A mutable version of CTransaction.
Definition: transaction.h:344
virtual TransactionError fillPSBT(int sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
AddressTableModel * addressTableModel
Definition: walletmodel.h:178
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
uint256 getBestBlockHash()
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: walletmodel.h:164
bool isMultiwallet()
void timerTimeout()
bool fHaveWatchOnly
Definition: walletmodel.h:171
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
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
bool balanceChanged(const WalletBalances &prev) const
Definition: wallet.h:362
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
void balanceChanged(const interfaces::WalletBalances &balances)
std::unique_ptr< interfaces::Handler > m_handler_watch_only_changed
Definition: walletmodel.h:166
void pollBalanceChanged()
Definition: walletmodel.cpp:90
OptionsModel * getOptionsModel()
void subscribeToCoreSignals()
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:66
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).