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)
6 #include <config/bitcoin-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>
17 #include <qt/recentrequeststablemodel.h>
18 #include <qt/sendcoinsdialog.h>
19 #include <qt/transactiontablemodel.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 
WalletModel(std::unique_ptr<interfaces::Wallet> wallet,ClientModel & client_model,const PlatformStyle * platformStyle,QObject * parent)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();
53     addressTableModel = new AddressTableModel(this);
54     transactionTableModel = new TransactionTableModel(platformStyle, this);
55     recentRequestsTableModel = new RecentRequestsTableModel(this);
56 
57     subscribeToCoreSignals();
58 }
59 
~WalletModel()60 WalletModel::~WalletModel()
61 {
62     unsubscribeFromCoreSignals();
63 }
64 
startPollBalance()65 void WalletModel::startPollBalance()
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);
71     GUIUtil::ExceptionSafeConnect(this, &WalletModel::timerTimeout, this, &WalletModel::pollBalanceChanged);
72     timer->start(MODEL_UPDATE_DELAY);
73 }
74 
setClientModel(ClientModel * client_model)75 void WalletModel::setClientModel(ClientModel* client_model)
76 {
77     m_client_model = client_model;
78     if (!m_client_model) timer->stop();
79 }
80 
updateStatus()81 void WalletModel::updateStatus()
82 {
83     EncryptionStatus newEncryptionStatus = getEncryptionStatus();
84 
85     if(cachedEncryptionStatus != newEncryptionStatus) {
86         Q_EMIT encryptionStatusChanged();
87     }
88 }
89 
pollBalanceChanged()90 void WalletModel::pollBalanceChanged()
91 {
92     // Avoid recomputing wallet balances unless a TransactionChanged or
93     // BlockTip notification was received.
94     if (!fForceCheckBalanceChanged && m_cached_last_update_tip == getLastBlockProcessed()) return;
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 
106     if (fForceCheckBalanceChanged || block_hash != m_cached_last_update_tip) {
107         fForceCheckBalanceChanged = false;
108 
109         // Balance and number of transactions might have changed
110         m_cached_last_update_tip = block_hash;
111 
112         checkBalanceChanged(new_balances);
113         if(transactionTableModel)
114             transactionTableModel->updateConfirmations();
115     }
116 }
117 
checkBalanceChanged(const interfaces::WalletBalances & new_balances)118 void WalletModel::checkBalanceChanged(const interfaces::WalletBalances& new_balances)
119 {
120     if(new_balances.balanceChanged(m_cached_balances)) {
121         m_cached_balances = new_balances;
122         Q_EMIT balanceChanged(new_balances);
123     }
124 }
125 
updateTransaction()126 void WalletModel::updateTransaction()
127 {
128     // Balance and number of transactions might have changed
129     fForceCheckBalanceChanged = true;
130 }
131 
updateAddressBook(const QString & address,const QString & label,bool isMine,const QString & purpose,int status)132 void WalletModel::updateAddressBook(const QString &address, const QString &label,
133         bool isMine, const QString &purpose, int status)
134 {
135     if(addressTableModel)
136         addressTableModel->updateEntry(address, label, isMine, purpose, status);
137 }
138 
updateWatchOnlyFlag(bool fHaveWatchonly)139 void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
140 {
141     fHaveWatchOnly = fHaveWatchonly;
142     Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
143 }
144 
validateAddress(const QString & address)145 bool WalletModel::validateAddress(const QString &address)
146 {
147     return IsValidDestinationString(address.toStdString());
148 }
149 
prepareTransaction(WalletModelTransaction & transaction,const CCoinControl & coinControl)150 WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl& coinControl)
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;
204         bilingual_str error;
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             {
216                 return SendCoinsReturn(AmountWithFeeExceedsBalance);
217             }
218             Q_EMIT message(tr("Send Coins"), QString::fromStdString(error.translated),
219                 CClientUIInterface::MSG_ERROR);
220             return TransactionCreationFailed;
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 
sendCoins(WalletModelTransaction & transaction)234 WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &transaction)
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 
249         CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
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 
getOptionsModel()284 OptionsModel *WalletModel::getOptionsModel()
285 {
286     return optionsModel;
287 }
288 
getAddressTableModel()289 AddressTableModel *WalletModel::getAddressTableModel()
290 {
291     return addressTableModel;
292 }
293 
getTransactionTableModel()294 TransactionTableModel *WalletModel::getTransactionTableModel()
295 {
296     return transactionTableModel;
297 }
298 
getRecentRequestsTableModel()299 RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel()
300 {
301     return recentRequestsTableModel;
302 }
303 
getEncryptionStatus() const304 WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
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 
setWalletEncrypted(const SecureString & passphrase)320 bool WalletModel::setWalletEncrypted(const SecureString& passphrase)
321 {
322     return m_wallet->encryptWallet(passphrase);
323 }
324 
setWalletLocked(bool locked,const SecureString & passPhrase)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 
changePassphrase(const SecureString & oldPass,const SecureString & newPass)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
NotifyUnload(WalletModel * walletModel)346 static void NotifyUnload(WalletModel* walletModel)
347 {
348     qDebug() << "NotifyUnload";
349     bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
350     assert(invoked);
351 }
352 
NotifyKeyStoreStatusChanged(WalletModel * walletmodel)353 static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
354 {
355     qDebug() << "NotifyKeyStoreStatusChanged";
356     bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
357     assert(invoked);
358 }
359 
NotifyAddressBookChanged(WalletModel * walletmodel,const CTxDestination & address,const std::string & label,bool isMine,const std::string & purpose,ChangeType status)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 
NotifyTransactionChanged(WalletModel * walletmodel,const uint256 & hash,ChangeType status)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 
ShowProgress(WalletModel * walletmodel,const std::string & title,int nProgress)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 
NotifyWatchonlyChanged(WalletModel * walletmodel,bool fHaveWatchonly)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 
NotifyCanGetAddressesChanged(WalletModel * walletmodel)402 static void NotifyCanGetAddressesChanged(WalletModel* walletmodel)
403 {
404     bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
405     assert(invoked);
406 }
407 
subscribeToCoreSignals()408 void WalletModel::subscribeToCoreSignals()
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 
unsubscribeFromCoreSignals()420 void WalletModel::unsubscribeFromCoreSignals()
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
requestUnlock()433 WalletModel::UnlockContext WalletModel::requestUnlock()
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 
UnlockContext(WalletModel * _wallet,bool _valid,bool _relock)447 WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
448         wallet(_wallet),
449         valid(_valid),
450         relock(_relock)
451 {
452 }
453 
~UnlockContext()454 WalletModel::UnlockContext::~UnlockContext()
455 {
456     if(valid && relock)
457     {
458         wallet->setWalletLocked(true);
459     }
460 }
461 
CopyFrom(UnlockContext && rhs)462 void WalletModel::UnlockContext::CopyFrom(UnlockContext&& rhs)
463 {
464     // Transfer context; old object no longer relocks wallet
465     *this = rhs;
466     rhs.relock = false;
467 }
468 
bumpFee(uint256 hash,uint256 & new_hash)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;
476     CMutableTransaction mtx;
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 
518     WalletModel::UnlockContext ctx(requestUnlock());
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
534         CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
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 
displayAddress(std::string sAddress)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 
isWalletEnabled()567 bool WalletModel::isWalletEnabled()
568 {
569    return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
570 }
571 
getWalletName() const572 QString WalletModel::getWalletName() const
573 {
574     return QString::fromStdString(m_wallet->getWalletName());
575 }
576 
getDisplayName() const577 QString WalletModel::getDisplayName() const
578 {
579     const QString name = getWalletName();
580     return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
581 }
582 
isMultiwallet()583 bool WalletModel::isMultiwallet()
584 {
585     return m_node.walletClient().getWallets().size() > 1;
586 }
587 
refresh(bool pk_hash_only)588 void WalletModel::refresh(bool pk_hash_only)
589 {
590     addressTableModel = new AddressTableModel(this, pk_hash_only);
591 }
592 
getLastBlockProcessed() const593 uint256 WalletModel::getLastBlockProcessed() const
594 {
595     return m_client_model ? m_client_model->getBestBlockHash() : uint256{};
596 }
597