1 // Copyright (c) 2011-2019 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/guiconstants.h>
13 #include <qt/optionsmodel.h>
14 #include <qt/paymentserver.h>
15 #include <qt/recentrequeststablemodel.h>
16 #include <qt/sendcoinsdialog.h>
17 #include <qt/transactiontablemodel.h>
18 
19 #include <interfaces/handler.h>
20 #include <interfaces/node.h>
21 #include <key_io.h>
22 #include <ui_interface.h>
23 #include <util/system.h> // for GetBoolArg
24 #include <wallet/coincontrol.h>
25 #include <wallet/wallet.h>
26 
27 #include <stdint.h>
28 
29 #include <QDebug>
30 #include <QMessageBox>
31 #include <QSet>
32 #include <QTimer>
33 
34 
WalletModel(std::unique_ptr<interfaces::Wallet> wallet,interfaces::Node & node,const PlatformStyle * platformStyle,OptionsModel * _optionsModel,QObject * parent)35 WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, interfaces::Node& node, const PlatformStyle *platformStyle, OptionsModel *_optionsModel, QObject *parent) :
36     QObject(parent), m_wallet(std::move(wallet)), m_node(node), optionsModel(_optionsModel), addressTableModel(nullptr),
37     transactionTableModel(nullptr),
38     recentRequestsTableModel(nullptr),
39     cachedEncryptionStatus(Unencrypted),
40     cachedNumBlocks(0)
41 {
42     fHaveWatchOnly = m_wallet->haveWatchOnly();
43     addressTableModel = new AddressTableModel(this);
44     transactionTableModel = new TransactionTableModel(platformStyle, this);
45     recentRequestsTableModel = new RecentRequestsTableModel(this);
46 
47     // This timer will be fired repeatedly to update the balance
48     pollTimer = new QTimer(this);
49     connect(pollTimer, &QTimer::timeout, this, &WalletModel::pollBalanceChanged);
50     pollTimer->start(MODEL_UPDATE_DELAY);
51 
52     subscribeToCoreSignals();
53 }
54 
~WalletModel()55 WalletModel::~WalletModel()
56 {
57     unsubscribeFromCoreSignals();
58 }
59 
updateStatus()60 void WalletModel::updateStatus()
61 {
62     EncryptionStatus newEncryptionStatus = getEncryptionStatus();
63 
64     if(cachedEncryptionStatus != newEncryptionStatus) {
65         Q_EMIT encryptionStatusChanged();
66     }
67 }
68 
pollBalanceChanged()69 void WalletModel::pollBalanceChanged()
70 {
71     // Try to get balances and return early if locks can't be acquired. This
72     // avoids the GUI from getting stuck on periodical polls if the core is
73     // holding the locks for a longer time - for example, during a wallet
74     // rescan.
75     interfaces::WalletBalances new_balances;
76     int numBlocks = -1;
77     if (!m_wallet->tryGetBalances(new_balances, numBlocks)) {
78         return;
79     }
80 
81     if(fForceCheckBalanceChanged || m_node.getNumBlocks() != cachedNumBlocks)
82     {
83         fForceCheckBalanceChanged = false;
84 
85         // Balance and number of transactions might have changed
86         cachedNumBlocks = m_node.getNumBlocks();
87 
88         checkBalanceChanged(new_balances);
89         if(transactionTableModel)
90             transactionTableModel->updateConfirmations();
91     }
92 }
93 
checkBalanceChanged(const interfaces::WalletBalances & new_balances)94 void WalletModel::checkBalanceChanged(const interfaces::WalletBalances& new_balances)
95 {
96     if(new_balances.balanceChanged(m_cached_balances)) {
97         m_cached_balances = new_balances;
98         Q_EMIT balanceChanged(new_balances);
99     }
100 }
101 
updateTransaction()102 void WalletModel::updateTransaction()
103 {
104     // Balance and number of transactions might have changed
105     fForceCheckBalanceChanged = true;
106 }
107 
updateAddressBook(const QString & address,const QString & label,bool isMine,const QString & purpose,int status)108 void WalletModel::updateAddressBook(const QString &address, const QString &label,
109         bool isMine, const QString &purpose, int status)
110 {
111     if(addressTableModel)
112         addressTableModel->updateEntry(address, label, isMine, purpose, status);
113 }
114 
updateWatchOnlyFlag(bool fHaveWatchonly)115 void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
116 {
117     fHaveWatchOnly = fHaveWatchonly;
118     Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
119 }
120 
validateAddress(const QString & address)121 bool WalletModel::validateAddress(const QString &address)
122 {
123     return IsValidDestinationString(address.toStdString());
124 }
125 
prepareTransaction(WalletModelTransaction & transaction,const CCoinControl & coinControl)126 WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl& coinControl)
127 {
128     CAmount total = 0;
129     bool fSubtractFeeFromAmount = false;
130     QList<SendCoinsRecipient> recipients = transaction.getRecipients();
131     std::vector<CRecipient> vecSend;
132 
133     if(recipients.empty())
134     {
135         return OK;
136     }
137 
138     QSet<QString> setAddress; // Used to detect duplicates
139     int nAddresses = 0;
140 
141     // Pre-check input data for validity
142     for (const SendCoinsRecipient &rcp : recipients)
143     {
144         if (rcp.fSubtractFeeFromAmount)
145             fSubtractFeeFromAmount = true;
146 
147 #ifdef ENABLE_BIP70
148         if (rcp.paymentRequest.IsInitialized())
149         {   // PaymentRequest...
150             CAmount subtotal = 0;
151             const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
152             for (int i = 0; i < details.outputs_size(); i++)
153             {
154                 const payments::Output& out = details.outputs(i);
155                 if (out.amount() <= 0) continue;
156                 subtotal += out.amount();
157                 const unsigned char* scriptStr = (const unsigned char*)out.script().data();
158                 CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
159                 CAmount nAmount = out.amount();
160                 CRecipient recipient = {scriptPubKey, nAmount, rcp.fSubtractFeeFromAmount};
161                 vecSend.push_back(recipient);
162             }
163             if (subtotal <= 0)
164             {
165                 return InvalidAmount;
166             }
167             total += subtotal;
168         }
169         else
170 #endif
171         {   // User-entered bitcoin address / amount:
172             if(!validateAddress(rcp.address))
173             {
174                 return InvalidAddress;
175             }
176             if(rcp.amount <= 0)
177             {
178                 return InvalidAmount;
179             }
180             setAddress.insert(rcp.address);
181             ++nAddresses;
182 
183             CScript scriptPubKey = GetScriptForDestination(DecodeDestination(rcp.address.toStdString()));
184             CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
185             vecSend.push_back(recipient);
186 
187             total += rcp.amount;
188         }
189     }
190     if(setAddress.size() != nAddresses)
191     {
192         return DuplicateAddress;
193     }
194 
195     CAmount nBalance = m_wallet->getAvailableBalance(coinControl);
196 
197     if(total > nBalance)
198     {
199         return AmountExceedsBalance;
200     }
201 
202     {
203         CAmount nFeeRequired = 0;
204         int nChangePosRet = -1;
205         std::string strFailReason;
206 
207         auto& newTx = transaction.getWtx();
208         newTx = m_wallet->createTransaction(vecSend, coinControl, true /* sign */, nChangePosRet, nFeeRequired, strFailReason);
209         transaction.setTransactionFee(nFeeRequired);
210         if (fSubtractFeeFromAmount && newTx)
211             transaction.reassignAmounts(nChangePosRet);
212 
213         if(!newTx)
214         {
215             if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
216             {
217                 return SendCoinsReturn(AmountWithFeeExceedsBalance);
218             }
219             Q_EMIT message(tr("Send Coins"), QString::fromStdString(strFailReason),
220                          CClientUIInterface::MSG_ERROR);
221             return TransactionCreationFailed;
222         }
223 
224         // reject absurdly high fee. (This can never happen because the
225         // wallet caps the fee at maxTxFee. This merely serves as a
226         // belt-and-suspenders check)
227         if (nFeeRequired > m_node.getMaxTxFee())
228             return AbsurdFee;
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 #ifdef ENABLE_BIP70
243             if (rcp.paymentRequest.IsInitialized())
244             {
245                 // Make sure any payment requests involved are still valid.
246                 if (PaymentServer::verifyExpired(rcp.paymentRequest.getDetails())) {
247                     return PaymentRequestExpired;
248                 }
249 
250                 // Store PaymentRequests in wtx.vOrderForm in wallet.
251                 std::string value;
252                 rcp.paymentRequest.SerializeToString(&value);
253                 vOrderForm.emplace_back("PaymentRequest", std::move(value));
254             }
255             else
256 #endif
257             if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
258                 vOrderForm.emplace_back("Message", rcp.message.toStdString());
259         }
260 
261         auto& newTx = transaction.getWtx();
262         std::string rejectReason;
263         if (!newTx->commit({} /* mapValue */, std::move(vOrderForm), rejectReason))
264             return SendCoinsReturn(TransactionCommitFailed, QString::fromStdString(rejectReason));
265 
266         CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
267         ssTx << newTx->get();
268         transaction_array.append(&(ssTx[0]), ssTx.size());
269     }
270 
271     // Add addresses / update labels that we've sent to the address book,
272     // and emit coinsSent signal for each recipient
273     for (const SendCoinsRecipient &rcp : transaction.getRecipients())
274     {
275         // Don't touch the address book when we have a payment request
276 #ifdef ENABLE_BIP70
277         if (!rcp.paymentRequest.IsInitialized())
278 #endif
279         {
280             std::string strAddress = rcp.address.toStdString();
281             CTxDestination dest = DecodeDestination(strAddress);
282             std::string strLabel = rcp.label.toStdString();
283             {
284                 // Check if we have a new address or an updated label
285                 std::string name;
286                 if (!m_wallet->getAddress(
287                      dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
288                 {
289                     m_wallet->setAddressBook(dest, strLabel, "send");
290                 }
291                 else if (name != strLabel)
292                 {
293                     m_wallet->setAddressBook(dest, strLabel, ""); // "" means don't change purpose
294                 }
295             }
296         }
297         Q_EMIT coinsSent(this, rcp, transaction_array);
298     }
299 
300     checkBalanceChanged(m_wallet->getBalances()); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
301 
302     return SendCoinsReturn(OK);
303 }
304 
getOptionsModel()305 OptionsModel *WalletModel::getOptionsModel()
306 {
307     return optionsModel;
308 }
309 
getAddressTableModel()310 AddressTableModel *WalletModel::getAddressTableModel()
311 {
312     return addressTableModel;
313 }
314 
getTransactionTableModel()315 TransactionTableModel *WalletModel::getTransactionTableModel()
316 {
317     return transactionTableModel;
318 }
319 
getRecentRequestsTableModel()320 RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel()
321 {
322     return recentRequestsTableModel;
323 }
324 
getEncryptionStatus() const325 WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
326 {
327     if(!m_wallet->isCrypted())
328     {
329         return Unencrypted;
330     }
331     else if(m_wallet->isLocked())
332     {
333         return Locked;
334     }
335     else
336     {
337         return Unlocked;
338     }
339 }
340 
setWalletEncrypted(bool encrypted,const SecureString & passphrase)341 bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
342 {
343     if(encrypted)
344     {
345         // Encrypt
346         return m_wallet->encryptWallet(passphrase);
347     }
348     else
349     {
350         // Decrypt -- TODO; not supported yet
351         return false;
352     }
353 }
354 
setWalletLocked(bool locked,const SecureString & passPhrase)355 bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
356 {
357     if(locked)
358     {
359         // Lock
360         return m_wallet->lock();
361     }
362     else
363     {
364         // Unlock
365         return m_wallet->unlock(passPhrase);
366     }
367 }
368 
changePassphrase(const SecureString & oldPass,const SecureString & newPass)369 bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
370 {
371     m_wallet->lock(); // Make sure wallet is locked before attempting pass change
372     return m_wallet->changeWalletPassphrase(oldPass, newPass);
373 }
374 
375 // Handlers for core signals
NotifyUnload(WalletModel * walletModel)376 static void NotifyUnload(WalletModel* walletModel)
377 {
378     qDebug() << "NotifyUnload";
379     bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
380     assert(invoked);
381 }
382 
NotifyKeyStoreStatusChanged(WalletModel * walletmodel)383 static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
384 {
385     qDebug() << "NotifyKeyStoreStatusChanged";
386     bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
387     assert(invoked);
388 }
389 
NotifyAddressBookChanged(WalletModel * walletmodel,const CTxDestination & address,const std::string & label,bool isMine,const std::string & purpose,ChangeType status)390 static void NotifyAddressBookChanged(WalletModel *walletmodel,
391         const CTxDestination &address, const std::string &label, bool isMine,
392         const std::string &purpose, ChangeType status)
393 {
394     QString strAddress = QString::fromStdString(EncodeDestination(address));
395     QString strLabel = QString::fromStdString(label);
396     QString strPurpose = QString::fromStdString(purpose);
397 
398     qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
399     bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
400                               Q_ARG(QString, strAddress),
401                               Q_ARG(QString, strLabel),
402                               Q_ARG(bool, isMine),
403                               Q_ARG(QString, strPurpose),
404                               Q_ARG(int, status));
405     assert(invoked);
406 }
407 
NotifyTransactionChanged(WalletModel * walletmodel,const uint256 & hash,ChangeType status)408 static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
409 {
410     Q_UNUSED(hash);
411     Q_UNUSED(status);
412     bool invoked = QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
413     assert(invoked);
414 }
415 
ShowProgress(WalletModel * walletmodel,const std::string & title,int nProgress)416 static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
417 {
418     // emits signal "showProgress"
419     bool invoked = QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
420                               Q_ARG(QString, QString::fromStdString(title)),
421                               Q_ARG(int, nProgress));
422     assert(invoked);
423 }
424 
NotifyWatchonlyChanged(WalletModel * walletmodel,bool fHaveWatchonly)425 static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
426 {
427     bool invoked = QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
428                               Q_ARG(bool, fHaveWatchonly));
429     assert(invoked);
430 }
431 
NotifyCanGetAddressesChanged(WalletModel * walletmodel)432 static void NotifyCanGetAddressesChanged(WalletModel* walletmodel)
433 {
434     bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
435     assert(invoked);
436 }
437 
subscribeToCoreSignals()438 void WalletModel::subscribeToCoreSignals()
439 {
440     // Connect signals to wallet
441     m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this));
442     m_handler_status_changed = m_wallet->handleStatusChanged(std::bind(&NotifyKeyStoreStatusChanged, this));
443     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));
444     m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
445     m_handler_show_progress = m_wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
446     m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged(std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1));
447     m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged(boost::bind(NotifyCanGetAddressesChanged, this));
448 }
449 
unsubscribeFromCoreSignals()450 void WalletModel::unsubscribeFromCoreSignals()
451 {
452     // Disconnect signals from wallet
453     m_handler_unload->disconnect();
454     m_handler_status_changed->disconnect();
455     m_handler_address_book_changed->disconnect();
456     m_handler_transaction_changed->disconnect();
457     m_handler_show_progress->disconnect();
458     m_handler_watch_only_changed->disconnect();
459     m_handler_can_get_addrs_changed->disconnect();
460 }
461 
462 // WalletModel::UnlockContext implementation
requestUnlock()463 WalletModel::UnlockContext WalletModel::requestUnlock()
464 {
465     bool was_locked = getEncryptionStatus() == Locked;
466     if(was_locked)
467     {
468         // Request UI to unlock wallet
469         Q_EMIT requireUnlock();
470     }
471     // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
472     bool valid = getEncryptionStatus() != Locked;
473 
474     return UnlockContext(this, valid, was_locked);
475 }
476 
UnlockContext(WalletModel * _wallet,bool _valid,bool _relock)477 WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
478         wallet(_wallet),
479         valid(_valid),
480         relock(_relock)
481 {
482 }
483 
~UnlockContext()484 WalletModel::UnlockContext::~UnlockContext()
485 {
486     if(valid && relock)
487     {
488         wallet->setWalletLocked(true);
489     }
490 }
491 
CopyFrom(const UnlockContext & rhs)492 void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs)
493 {
494     // Transfer context; old object no longer relocks wallet
495     *this = rhs;
496     rhs.relock = false;
497 }
498 
loadReceiveRequests(std::vector<std::string> & vReceiveRequests)499 void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
500 {
501     vReceiveRequests = m_wallet->getDestValues("rr"); // receive request
502 }
503 
saveReceiveRequest(const std::string & sAddress,const int64_t nId,const std::string & sRequest)504 bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
505 {
506     CTxDestination dest = DecodeDestination(sAddress);
507 
508     std::stringstream ss;
509     ss << nId;
510     std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
511 
512     if (sRequest.empty())
513         return m_wallet->eraseDestData(dest, key);
514     else
515         return m_wallet->addDestData(dest, key, sRequest);
516 }
517 
bumpFee(uint256 hash,uint256 & new_hash)518 bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
519 {
520     CCoinControl coin_control;
521     coin_control.m_signal_bip125_rbf = true;
522     std::vector<std::string> errors;
523     CAmount old_fee;
524     CAmount new_fee;
525     CMutableTransaction mtx;
526     if (!m_wallet->createBumpTransaction(hash, coin_control, 0 /* totalFee */, errors, old_fee, new_fee, mtx)) {
527         QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
528             (errors.size() ? QString::fromStdString(errors[0]) : "") +")");
529          return false;
530     }
531 
532     // allow a user based fee verification
533     QString questionString = tr("Do you want to increase the fee?");
534     questionString.append("<br />");
535     questionString.append("<table style=\"text-align: left;\">");
536     questionString.append("<tr><td>");
537     questionString.append(tr("Current fee:"));
538     questionString.append("</td><td>");
539     questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee));
540     questionString.append("</td></tr><tr><td>");
541     questionString.append(tr("Increase:"));
542     questionString.append("</td><td>");
543     questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee));
544     questionString.append("</td></tr><tr><td>");
545     questionString.append(tr("New fee:"));
546     questionString.append("</td><td>");
547     questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee));
548     questionString.append("</td></tr></table>");
549     SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), questionString);
550     confirmationDialog.exec();
551     QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
552 
553     // cancel sign&broadcast if user doesn't want to bump the fee
554     if (retval != QMessageBox::Yes) {
555         return false;
556     }
557 
558     WalletModel::UnlockContext ctx(requestUnlock());
559     if(!ctx.isValid())
560     {
561         return false;
562     }
563 
564     // sign bumped transaction
565     if (!m_wallet->signBumpTransaction(mtx)) {
566         QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));
567         return false;
568     }
569     // commit the bumped transaction
570     if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
571         QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
572             QString::fromStdString(errors[0])+")");
573          return false;
574     }
575     return true;
576 }
577 
isWalletEnabled()578 bool WalletModel::isWalletEnabled()
579 {
580    return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
581 }
582 
privateKeysDisabled() const583 bool WalletModel::privateKeysDisabled() const
584 {
585     return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
586 }
587 
canGetAddresses() const588 bool WalletModel::canGetAddresses() const
589 {
590     return m_wallet->canGetAddresses();
591 }
592 
getWalletName() const593 QString WalletModel::getWalletName() const
594 {
595     return QString::fromStdString(m_wallet->getWalletName());
596 }
597 
getDisplayName() const598 QString WalletModel::getDisplayName() const
599 {
600     const QString name = getWalletName();
601     return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
602 }
603 
isMultiwallet()604 bool WalletModel::isMultiwallet()
605 {
606     return m_node.getWallets().size() > 1;
607 }
608