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