Bitcoin Core  21.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 
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 
317 {
318  return m_wallet->encryptWallet(passphrase);
319 }
320 
321 bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
322 {
323  if(locked)
324  {
325  // Lock
326  return m_wallet->lock();
327  }
328  else
329  {
330  // Unlock
331  return m_wallet->unlock(passPhrase);
332  }
333 }
334 
335 bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
336 {
337  m_wallet->lock(); // Make sure wallet is locked before attempting pass change
338  return m_wallet->changeWalletPassphrase(oldPass, newPass);
339 }
340 
341 // Handlers for core signals
342 static void NotifyUnload(WalletModel* walletModel)
343 {
344  qDebug() << "NotifyUnload";
345  bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
346  assert(invoked);
347 }
348 
349 static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
350 {
351  qDebug() << "NotifyKeyStoreStatusChanged";
352  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
353  assert(invoked);
354 }
355 
356 static void NotifyAddressBookChanged(WalletModel *walletmodel,
357  const CTxDestination &address, const std::string &label, bool isMine,
358  const std::string &purpose, ChangeType status)
359 {
360  QString strAddress = QString::fromStdString(EncodeDestination(address));
361  QString strLabel = QString::fromStdString(label);
362  QString strPurpose = QString::fromStdString(purpose);
363 
364  qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
365  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
366  Q_ARG(QString, strAddress),
367  Q_ARG(QString, strLabel),
368  Q_ARG(bool, isMine),
369  Q_ARG(QString, strPurpose),
370  Q_ARG(int, status));
371  assert(invoked);
372 }
373 
374 static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
375 {
376  Q_UNUSED(hash);
377  Q_UNUSED(status);
378  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
379  assert(invoked);
380 }
381 
382 static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
383 {
384  // emits signal "showProgress"
385  bool invoked = QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
386  Q_ARG(QString, QString::fromStdString(title)),
387  Q_ARG(int, nProgress));
388  assert(invoked);
389 }
390 
391 static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
392 {
393  bool invoked = QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
394  Q_ARG(bool, fHaveWatchonly));
395  assert(invoked);
396 }
397 
398 static void NotifyCanGetAddressesChanged(WalletModel* walletmodel)
399 {
400  bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
401  assert(invoked);
402 }
403 
405 {
406  // Connect signals to wallet
407  m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this));
408  m_handler_status_changed = m_wallet->handleStatusChanged(std::bind(&NotifyKeyStoreStatusChanged, this));
409  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));
410  m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
411  m_handler_show_progress = m_wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
412  m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged(std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1));
413  m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged(std::bind(NotifyCanGetAddressesChanged, this));
414 }
415 
417 {
418  // Disconnect signals from wallet
419  m_handler_unload->disconnect();
420  m_handler_status_changed->disconnect();
421  m_handler_address_book_changed->disconnect();
422  m_handler_transaction_changed->disconnect();
423  m_handler_show_progress->disconnect();
424  m_handler_watch_only_changed->disconnect();
425  m_handler_can_get_addrs_changed->disconnect();
426 }
427 
428 // WalletModel::UnlockContext implementation
430 {
431  bool was_locked = getEncryptionStatus() == Locked;
432  if(was_locked)
433  {
434  // Request UI to unlock wallet
435  Q_EMIT requireUnlock();
436  }
437  // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
438  bool valid = getEncryptionStatus() != Locked;
439 
440  return UnlockContext(this, valid, was_locked);
441 }
442 
443 WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
444  wallet(_wallet),
445  valid(_valid),
446  relock(_relock)
447 {
448 }
449 
451 {
452  if(valid && relock)
453  {
454  wallet->setWalletLocked(true);
455  }
456 }
457 
459 {
460  // Transfer context; old object no longer relocks wallet
461  *this = rhs;
462  rhs.relock = false;
463 }
464 
465 void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
466 {
467  vReceiveRequests = m_wallet->getDestValues("rr"); // receive request
468 }
469 
470 bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
471 {
472  CTxDestination dest = DecodeDestination(sAddress);
473 
474  std::stringstream ss;
475  ss << nId;
476  std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
477 
478  if (sRequest.empty())
479  return m_wallet->eraseDestData(dest, key);
480  else
481  return m_wallet->addDestData(dest, key, sRequest);
482 }
483 
484 bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
485 {
486  CCoinControl coin_control;
487  coin_control.m_signal_bip125_rbf = true;
488  std::vector<bilingual_str> errors;
489  CAmount old_fee;
490  CAmount new_fee;
492  if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) {
493  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
494  (errors.size() ? QString::fromStdString(errors[0].translated) : "") +")");
495  return false;
496  }
497 
498  const bool create_psbt = m_wallet->privateKeysDisabled();
499 
500  // allow a user based fee verification
501  QString questionString = create_psbt ? tr("Do you want to draft a transaction with fee increase?") : tr("Do you want to increase the fee?");
502  questionString.append("<br />");
503  questionString.append("<table style=\"text-align: left;\">");
504  questionString.append("<tr><td>");
505  questionString.append(tr("Current fee:"));
506  questionString.append("</td><td>");
507  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee));
508  questionString.append("</td></tr><tr><td>");
509  questionString.append(tr("Increase:"));
510  questionString.append("</td><td>");
511  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee));
512  questionString.append("</td></tr><tr><td>");
513  questionString.append(tr("New fee:"));
514  questionString.append("</td><td>");
515  questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee));
516  questionString.append("</td></tr></table>");
517  SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), questionString);
518  confirmationDialog.exec();
519  QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
520 
521  // cancel sign&broadcast if user doesn't want to bump the fee
522  if (retval != QMessageBox::Yes) {
523  return false;
524  }
525 
527  if(!ctx.isValid())
528  {
529  return false;
530  }
531 
532  // Short-circuit if we are returning a bumped transaction PSBT to clipboard
533  if (create_psbt) {
534  PartiallySignedTransaction psbtx(mtx);
535  bool complete = false;
536  const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
537  if (err != TransactionError::OK || complete) {
538  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
539  return false;
540  }
541  // Serialize the PSBT
543  ssTx << psbtx;
544  GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
545  Q_EMIT message(tr("PSBT copied"), "Copied to clipboard", CClientUIInterface::MSG_INFORMATION);
546  return true;
547  }
548 
549  // sign bumped transaction
550  if (!m_wallet->signBumpTransaction(mtx)) {
551  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));
552  return false;
553  }
554  // commit the bumped transaction
555  if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
556  QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
557  QString::fromStdString(errors[0].translated)+")");
558  return false;
559  }
560  return true;
561 }
562 
564 {
565  return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
566 }
567 
569 {
570  return QString::fromStdString(m_wallet->getWalletName());
571 }
572 
574 {
575  const QString name = getWalletName();
576  return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
577 }
578 
580 {
581  return m_node.walletClient().getWallets().size() > 1;
582 }
583 
584 void WalletModel::refresh(bool pk_hash_only)
585 {
586  addressTableModel = new AddressTableModel(this, pk_hash_only);
587 }
588 
590 {
592 }
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
Model for list of recently generated payment requests / bitcoin: URIs.
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:181
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
assert(!tx.IsCoinBase())
NodeContext & m_node
Definition: interfaces.cpp:660
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:216
UnlockContext requestUnlock()
std::unique_ptr< interfaces::Handler > m_handler_unload
Definition: walletmodel.h:163
void unsubscribeFromCoreSignals()
std::string str() const
Definition: streams.h:280
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:499
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:91
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:202
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:479
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:212
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
std::string EncodeBase64(Span< const unsigned char > input)
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:293
void updateTransaction()
Collection of wallet balances.
Definition: wallet.h:349
void setClipboard(const QString &str)
Definition: guiutil.cpp:736
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::unique_ptr< interfaces::Wallet > m_wallet
Definition: walletmodel.h:162
bool setWalletEncrypted(const SecureString &passphrase)
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:300
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:124
CTxDestination DecodeDestination(const std::string &str)
Definition: key_io.cpp:211
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()
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: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
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:206
QString getDisplayName() const
A mutable version of CTransaction.
Definition: transaction.h:344
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)
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:359
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:52
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
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).