Bitcoin Core 29.99.0
P2P Digital Currency
walletmodel.cpp
Go to the documentation of this file.
1// Copyright (c) 2011-present 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#include <qt/walletmodel.h>
6
8#include <qt/clientmodel.h>
9#include <qt/guiconstants.h>
10#include <qt/guiutil.h>
11#include <qt/optionsmodel.h>
12#include <qt/paymentserver.h>
14#include <qt/sendcoinsdialog.h>
16
17#include <common/args.h>
18#include <interfaces/handler.h>
19#include <interfaces/node.h>
20#include <key_io.h>
21#include <node/interface_ui.h>
22#include <node/types.h>
23#include <psbt.h>
24#include <util/translation.h>
25#include <wallet/coincontrol.h>
26#include <wallet/wallet.h>
27
28#include <cstdint>
29#include <functional>
30#include <memory>
31#include <vector>
32
33#include <QDebug>
34#include <QMessageBox>
35#include <QSet>
36#include <QTimer>
37
41
42WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, ClientModel& client_model, const PlatformStyle *platformStyle, QObject *parent) :
43 QObject(parent),
44 m_wallet(std::move(wallet)),
45 m_client_model(&client_model),
46 m_node(client_model.node()),
47 optionsModel(client_model.getOptionsModel()),
48 timer(new QTimer(this))
49{
51 transactionTableModel = new TransactionTableModel(platformStyle, this);
53
55}
56
58{
60}
61
63{
64 // Update the cached balance right away, so every view can make use of it,
65 // so them don't need to waste resources recalculating it.
67
68 // This timer will be fired repeatedly to update the balance
69 // Since the QTimer::timeout is a private signal, it cannot be used
70 // in the GUIUtil::ExceptionSafeConnect directly.
71 connect(timer, &QTimer::timeout, this, &WalletModel::timerTimeout);
74}
75
77{
78 m_client_model = client_model;
79 if (!m_client_model) timer->stop();
80}
81
83{
84 EncryptionStatus newEncryptionStatus = getEncryptionStatus();
85
86 if(cachedEncryptionStatus != newEncryptionStatus) {
88 }
89}
90
92{
93 // Avoid recomputing wallet balances unless a TransactionChanged or
94 // BlockTip notification was received.
96
97 // Try to get balances and return early if locks can't be acquired. This
98 // avoids the GUI from getting stuck on periodical polls if the core is
99 // holding the locks for a longer time - for example, during a wallet
100 // rescan.
101 interfaces::WalletBalances new_balances;
102 uint256 block_hash;
103 if (!m_wallet->tryGetBalances(new_balances, block_hash)) {
104 return;
105 }
106
109
110 // Balance and number of transactions might have changed
111 m_cached_last_update_tip = block_hash;
112
113 checkBalanceChanged(new_balances);
116 }
117}
118
120{
121 if (new_balances.balanceChanged(m_cached_balances)) {
122 m_cached_balances = new_balances;
123 Q_EMIT balanceChanged(new_balances);
124 }
125}
126
128{
129 return m_cached_balances;
130}
131
133{
134 // Balance and number of transactions might have changed
136}
137
138void WalletModel::updateAddressBook(const QString &address, const QString &label,
139 bool isMine, wallet::AddressPurpose purpose, int status)
140{
142 addressTableModel->updateEntry(address, label, isMine, purpose, status);
143}
144
145bool WalletModel::validateAddress(const QString& address) const
146{
147 return IsValidDestinationString(address.toStdString());
148}
149
151{
152 CAmount total = 0;
153 bool fSubtractFeeFromAmount = false;
154 QList<SendCoinsRecipient> recipients = transaction.getRecipients();
155 std::vector<CRecipient> vecSend;
156
157 if(recipients.empty())
158 {
159 return OK;
160 }
161
162 QSet<QString> setAddress; // Used to detect duplicates
163 int nAddresses = 0;
164
165 // Pre-check input data for validity
166 for (const SendCoinsRecipient &rcp : recipients)
167 {
168 if (rcp.fSubtractFeeFromAmount)
169 fSubtractFeeFromAmount = true;
170 { // User-entered bitcoin address / amount:
171 if(!validateAddress(rcp.address))
172 {
173 return InvalidAddress;
174 }
175 if(rcp.amount <= 0)
176 {
177 return InvalidAmount;
178 }
179 setAddress.insert(rcp.address);
180 ++nAddresses;
181
182 CRecipient recipient{DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount};
183 vecSend.push_back(recipient);
184
185 total += rcp.amount;
186 }
187 }
188 if(setAddress.size() != nAddresses)
189 {
190 return DuplicateAddress;
191 }
192
193 // If no coin was manually selected, use the cached balance
194 // Future: can merge this call with 'createTransaction'.
195 CAmount nBalance = getAvailableBalance(&coinControl);
196
197 if(total > nBalance)
198 {
200 }
201
202 try {
203 CAmount nFeeRequired = 0;
204 int nChangePosRet = -1;
205
206 auto& newTx = transaction.getWtx();
207 const auto& res = m_wallet->createTransaction(vecSend, coinControl, /*sign=*/!wallet().privateKeysDisabled(), nChangePosRet, nFeeRequired);
208 newTx = res ? *res : nullptr;
209 transaction.setTransactionFee(nFeeRequired);
210 if (fSubtractFeeFromAmount && newTx)
211 transaction.reassignAmounts(nChangePosRet);
212
213 if(!newTx)
214 {
215 if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
216 {
218 }
219 Q_EMIT message(tr("Send Coins"), QString::fromStdString(util::ErrorString(res).translated),
222 }
223
224 // Reject absurdly high fee. (This can never happen because the
225 // wallet never creates transactions with fee greater than
226 // m_default_max_tx_fee. This merely a belt-and-suspenders check).
227 if (nFeeRequired > m_wallet->getDefaultMaxTxFee()) {
228 return AbsurdFee;
229 }
230 } catch (const std::runtime_error& err) {
231 // Something unexpected happened, instruct user to report this bug.
232 Q_EMIT message(tr("Send Coins"), QString::fromStdString(err.what()),
235 }
236
237 return SendCoinsReturn(OK);
238}
239
241{
242 QByteArray transaction_array; /* store serialized transaction */
243
244 {
245 std::vector<std::pair<std::string, std::string>> vOrderForm;
246 for (const SendCoinsRecipient &rcp : transaction.getRecipients())
247 {
248 if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
249 vOrderForm.emplace_back("Message", rcp.message.toStdString());
250 }
251
252 auto& newTx = transaction.getWtx();
253 wallet().commitTransaction(newTx, /*value_map=*/{}, std::move(vOrderForm));
254
255 DataStream ssTx;
256 ssTx << TX_WITH_WITNESS(*newTx);
257 transaction_array.append((const char*)ssTx.data(), ssTx.size());
258 }
259
260 // Add addresses / update labels that we've sent to the address book,
261 // and emit coinsSent signal for each recipient
262 for (const SendCoinsRecipient &rcp : transaction.getRecipients())
263 {
264 {
265 std::string strAddress = rcp.address.toStdString();
266 CTxDestination dest = DecodeDestination(strAddress);
267 std::string strLabel = rcp.label.toStdString();
268 {
269 // Check if we have a new address or an updated label
270 std::string name;
271 if (!m_wallet->getAddress(
272 dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
273 {
274 m_wallet->setAddressBook(dest, strLabel, wallet::AddressPurpose::SEND);
275 }
276 else if (name != strLabel)
277 {
278 m_wallet->setAddressBook(dest, strLabel, {}); // {} means don't change purpose
279 }
280 }
281 }
282 Q_EMIT coinsSent(this, rcp, transaction_array);
283 }
284
285 checkBalanceChanged(m_wallet->getBalances()); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
286}
287
289{
290 return optionsModel;
291}
292
294{
295 return addressTableModel;
296}
297
299{
301}
302
304{
306}
307
309{
310 if(!m_wallet->isCrypted())
311 {
312 // A previous bug allowed for watchonly wallets to be encrypted (encryption keys set, but nothing is actually encrypted).
313 // To avoid misrepresenting the encryption status of such wallets, we only return NoKeys for watchonly wallets that are unencrypted.
314 if (m_wallet->privateKeysDisabled()) {
315 return NoKeys;
316 }
317 return Unencrypted;
318 }
319 else if(m_wallet->isLocked())
320 {
321 return Locked;
322 }
323 else
324 {
325 return Unlocked;
326 }
327}
328
330{
331 return m_wallet->encryptWallet(passphrase);
332}
333
334bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
335{
336 if(locked)
337 {
338 // Lock
339 return m_wallet->lock();
340 }
341 else
342 {
343 // Unlock
344 return m_wallet->unlock(passPhrase);
345 }
346}
347
348bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
349{
350 m_wallet->lock(); // Make sure wallet is locked before attempting pass change
351 return m_wallet->changeWalletPassphrase(oldPass, newPass);
352}
353
354// Handlers for core signals
355static void NotifyUnload(WalletModel* walletModel)
356{
357 qDebug() << "NotifyUnload";
358 bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
359 assert(invoked);
360}
361
363{
364 qDebug() << "NotifyKeyStoreStatusChanged";
365 bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
366 assert(invoked);
367}
368
369static void NotifyAddressBookChanged(WalletModel *walletmodel,
370 const CTxDestination &address, const std::string &label, bool isMine,
371 wallet::AddressPurpose purpose, ChangeType status)
372{
373 QString strAddress = QString::fromStdString(EncodeDestination(address));
374 QString strLabel = QString::fromStdString(label);
375
376 qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + QString::number(static_cast<uint8_t>(purpose)) + " status=" + QString::number(status);
377 bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook",
378 Q_ARG(QString, strAddress),
379 Q_ARG(QString, strLabel),
380 Q_ARG(bool, isMine),
381 Q_ARG(wallet::AddressPurpose, purpose),
382 Q_ARG(int, status));
383 assert(invoked);
384}
385
386static void NotifyTransactionChanged(WalletModel *walletmodel, const Txid& hash, ChangeType status)
387{
388 Q_UNUSED(hash);
389 Q_UNUSED(status);
390 bool invoked = QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
391 assert(invoked);
392}
393
394static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
395{
396 // emits signal "showProgress"
397 bool invoked = QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
398 Q_ARG(QString, QString::fromStdString(title)),
399 Q_ARG(int, nProgress));
400 assert(invoked);
401}
402
404{
405 bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
406 assert(invoked);
407}
408
410{
411 // Connect signals to wallet
412 m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this));
413 m_handler_status_changed = m_wallet->handleStatusChanged(std::bind(&NotifyKeyStoreStatusChanged, this));
414 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));
415 m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
416 m_handler_show_progress = m_wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
417 m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged(std::bind(NotifyCanGetAddressesChanged, this));
418}
419
421{
422 // Disconnect signals from wallet
423 m_handler_unload->disconnect();
424 m_handler_status_changed->disconnect();
425 m_handler_address_book_changed->disconnect();
426 m_handler_transaction_changed->disconnect();
427 m_handler_show_progress->disconnect();
429}
430
431// WalletModel::UnlockContext implementation
433{
434 // Bugs in earlier versions may have resulted in wallets with private keys disabled to become "encrypted"
435 // (encryption keys are present, but not actually doing anything).
436 // To avoid issues with such wallets, check if the wallet has private keys disabled, and if so, return a context
437 // that indicates the wallet is not encrypted.
438 if (m_wallet->privateKeysDisabled()) {
439 return UnlockContext(this, /*valid=*/true, /*relock=*/false);
440 }
441 bool was_locked = getEncryptionStatus() == Locked;
442 if(was_locked)
443 {
444 // Request UI to unlock wallet
445 Q_EMIT requireUnlock();
446 }
447 // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
448 bool valid = getEncryptionStatus() != Locked;
449
450 return UnlockContext(this, valid, was_locked);
451}
452
453WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
454 wallet(_wallet),
455 valid(_valid),
456 relock(_relock)
457{
458}
459
461{
462 if(valid && relock)
463 {
464 wallet->setWalletLocked(true);
465 }
466}
467
468bool WalletModel::bumpFee(Txid hash, Txid& new_hash)
469{
470 CCoinControl coin_control;
471 coin_control.m_signal_bip125_rbf = true;
472 std::vector<bilingual_str> errors;
473 CAmount old_fee;
474 CAmount new_fee;
476 if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) {
477 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
478 (errors.size() ? QString::fromStdString(errors[0].translated) : "") +")");
479 return false;
480 }
481
482 // allow a user based fee verification
483 /*: Asks a user if they would like to manually increase the fee of a transaction that has already been created. */
484 QString questionString = tr("Do you want to increase the fee?");
485 questionString.append("<br />");
486 questionString.append("<table style=\"text-align: left;\">");
487 questionString.append("<tr><td>");
488 questionString.append(tr("Current fee:"));
489 questionString.append("</td><td>");
490 questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee));
491 questionString.append("</td></tr><tr><td>");
492 questionString.append(tr("Increase:"));
493 questionString.append("</td><td>");
494 questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee));
495 questionString.append("</td></tr><tr><td>");
496 questionString.append(tr("New fee:"));
497 questionString.append("</td><td>");
498 questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee));
499 questionString.append("</td></tr></table>");
500
501 // Display warning in the "Confirm fee bump" window if the "Coin Control Features" option is enabled
502 if (getOptionsModel()->getCoinControlFeatures()) {
503 questionString.append("<br><br>");
504 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."));
505 }
506
507 const bool enable_send{!wallet().privateKeysDisabled() || wallet().hasExternalSigner()};
508 const bool always_show_unsigned{getOptionsModel()->getEnablePSBTControls()};
509 auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, enable_send, always_show_unsigned, nullptr);
510 confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
511 // TODO: Replace QDialog::exec() with safer QDialog::show().
512 const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());
513
514 // cancel sign&broadcast if user doesn't want to bump the fee
515 if (retval != QMessageBox::Yes && retval != QMessageBox::Save) {
516 return false;
517 }
518
519 // Short-circuit if we are returning a bumped transaction PSBT to clipboard
520 if (retval == QMessageBox::Save) {
521 // "Create Unsigned" clicked
523 bool complete = false;
524 const auto err{wallet().fillPSBT(std::nullopt, /*sign=*/false, /*bip32derivs=*/true, nullptr, psbtx, complete)};
525 if (err || complete) {
526 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
527 return false;
528 }
529 // Serialize the PSBT
530 DataStream ssTx{};
531 ssTx << psbtx;
532 GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
533 Q_EMIT message(tr("PSBT copied"), tr("Fee-bump PSBT copied to clipboard"), CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL);
534 return true;
535 }
536
538 if (!ctx.isValid()) {
539 return false;
540 }
541
542 assert(!m_wallet->privateKeysDisabled() || wallet().hasExternalSigner());
543
544 // sign bumped transaction
545 if (!m_wallet->signBumpTransaction(mtx)) {
546 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));
547 return false;
548 }
549 // commit the bumped transaction
550 if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
551 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
552 QString::fromStdString(errors[0].translated)+")");
553 return false;
554 }
555 return true;
556}
557
558void WalletModel::displayAddress(std::string sAddress) const
559{
560 CTxDestination dest = DecodeDestination(sAddress);
561 try {
562 util::Result<void> result = m_wallet->displayAddress(dest);
563 if (!result) {
564 QMessageBox::warning(nullptr, tr("Signer error"), QString::fromStdString(util::ErrorString(result).translated));
565 }
566 } catch (const std::runtime_error& e) {
567 QMessageBox::critical(nullptr, tr("Can't display address"), e.what());
568 }
569}
570
572{
573 return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
574}
575
577{
578 return QString::fromStdString(m_wallet->getWalletName());
579}
580
582{
584}
585
587{
588 return m_node.walletLoader().getWallets().size() > 1;
589}
590
591void WalletModel::refresh(bool pk_hash_only)
592{
593 addressTableModel = new AddressTableModel(this, pk_hash_only);
594}
595
597{
599}
600
602{
603 // No selected coins, return the cached balance
604 if (!control || !control->HasSelected()) {
606 return balances.balance;
607 }
608 // Fetch balance from the wallet, taking into account the selected coins
609 return wallet().getAvailableBalance(*control);
610}
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
Definition: addresstype.h:143
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
ArgsManager gArgs
Definition: args.cpp:42
node::NodeContext m_node
Definition: bitcoin-gui.cpp:42
Qt model of the address book in the core.
void updateEntry(const QString &address, const QString &label, bool isMine, wallet::AddressPurpose purpose, int status)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: args.cpp:507
static QString formatHtmlWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as HTML string (with unit)
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Definition: interface_ui.h:66
@ MODAL
Force blocking, modal message box dialog (not just OS notification)
Definition: interface_ui.h:60
Model for Bitcoin network client.
Definition: clientmodel.h:57
uint256 getBestBlockHash() EXCLUSIVE_LOCKS_REQUIRED(!m_cached_tip_mutex)
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:147
size_type size() const
Definition: streams.h:181
value_type * data()
Definition: streams.h:188
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:43
bool getEnablePSBTControls() const
Definition: optionsmodel.h:108
Model for list of recently generated payment requests / bitcoin: URIs.
UI model for the transaction table of a wallet.
UnlockContext(WalletModel *wallet, bool valid, bool relock)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:49
OptionsModel * optionsModel
Definition: walletmodel.h:174
AddressTableModel * addressTableModel
Definition: walletmodel.h:176
RecentRequestsTableModel * getRecentRequestsTableModel() const
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:182
void refresh(bool pk_hash_only=false)
uint256 m_cached_last_update_tip
Definition: walletmodel.h:186
ClientModel * m_client_model
Definition: walletmodel.h:167
bool bumpFee(Txid hash, Txid &new_hash)
interfaces::Node & m_node
Definition: walletmodel.h:168
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: walletmodel.h:164
void startPollBalance()
Definition: walletmodel.cpp:62
void pollBalanceChanged()
Definition: walletmodel.cpp:91
AddressTableModel * getAddressTableModel() const
RecentRequestsTableModel * recentRequestsTableModel
Definition: walletmodel.h:178
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const wallet::CCoinControl &coinControl)
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:177
bool setWalletEncrypted(const SecureString &passphrase)
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
void updateAddressBook(const QString &address, const QString &label, bool isMine, wallet::AddressPurpose purpose, int status)
void message(const QString &title, const QString &message, unsigned int style)
bool validateAddress(const QString &address) const
void sendCoins(WalletModelTransaction &transaction)
void setClientModel(ClientModel *client_model)
Definition: walletmodel.cpp:76
void updateStatus()
Definition: walletmodel.cpp:82
CAmount getAvailableBalance(const wallet::CCoinControl *control)
bool isMultiwallet() const
void timerTimeout()
std::unique_ptr< interfaces::Handler > m_handler_can_get_addrs_changed
Definition: walletmodel.h:166
std::unique_ptr< interfaces::Handler > m_handler_unload
Definition: walletmodel.h:161
void displayAddress(std::string sAddress) const
EncryptionStatus getEncryptionStatus() const
TransactionTableModel * getTransactionTableModel() const
interfaces::Wallet & wallet() const
Definition: walletmodel.h:139
std::unique_ptr< interfaces::Handler > m_handler_status_changed
Definition: walletmodel.h:162
interfaces::WalletBalances m_cached_balances
Definition: walletmodel.h:181
bool fForceCheckBalanceChanged
Definition: walletmodel.h:170
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
QString getDisplayName() const
OptionsModel * getOptionsModel() const
void checkBalanceChanged(const interfaces::WalletBalances &new_balances)
void unsubscribeFromCoreSignals()
void requireUnlock()
void updateTransaction()
uint256 getLastBlockProcessed() const
QTimer * timer
Definition: walletmodel.h:183
WalletModel(std::unique_ptr< interfaces::Wallet > wallet, ClientModel &client_model, const PlatformStyle *platformStyle, QObject *parent=nullptr)
Definition: walletmodel.cpp:42
std::unique_ptr< interfaces::Handler > m_handler_address_book_changed
Definition: walletmodel.h:163
void encryptionStatusChanged()
std::unique_ptr< interfaces::Wallet > m_wallet
Definition: walletmodel.h:160
UnlockContext requestUnlock()
void balanceChanged(const interfaces::WalletBalances &balances)
static bool isWalletEnabled()
interfaces::WalletBalances getCachedBalance() const
QString getWalletName() const
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: walletmodel.h:165
@ AmountWithFeeExceedsBalance
Definition: walletmodel.h:62
@ TransactionCreationFailed
Definition: walletmodel.h:64
@ AmountExceedsBalance
Definition: walletmodel.h:61
@ DuplicateAddress
Definition: walletmodel.h:63
void subscribeToCoreSignals()
Data model for a walletmodel transaction.
void setTransactionFee(const CAmount &newFee)
void reassignAmounts(int nChangePosRet)
QList< SendCoinsRecipient > getRecipients() const
virtual WalletLoader & walletLoader()=0
Get wallet loader.
virtual CAmount getAvailableBalance(const wallet::CCoinControl &coin_control)=0
Get available balance.
virtual std::optional< common::PSBTError > fillPSBT(std::optional< int > sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
virtual bool hasExternalSigner()=0
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
virtual bool privateKeysDisabled()=0
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
256-bit opaque blob.
Definition: uint256.h:196
Coin Control Features.
Definition: coincontrol.h:81
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
Definition: coincontrol.h:101
bool HasSelected() const
Returns true if there are pre-selected inputs.
Definition: coincontrol.cpp:15
static constexpr auto MODEL_UPDATE_DELAY
Definition: guiconstants.h:14
bool IsValidDestinationString(const std::string &str, const CChainParams &params)
Definition: key_io.cpp:310
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
Definition: key_io.cpp:299
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:294
QString WalletDisplayName(const QString &name)
Definition: guiutil.cpp:990
auto ExceptionSafeConnect(Sender sender, Signal signal, Receiver receiver, Slot method, Qt::ConnectionType type=Qt::AutoConnection)
A drop-in replacement of QObject::connect function (see: https://doc.qt.io/qt-5/qobject....
Definition: guiutil.h:369
void setClipboard(const QString &str)
Definition: guiutil.cpp:668
Definition: messages.h:20
bilingual_str ErrorString(const Result< T > &result)
Definition: result.h:93
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:135
AddressPurpose
Address purpose field that has been been stored with wallet sending and receiving addresses since BIP...
Definition: types.h:61
is a home for public enum and struct type definitions that are used internally by node code,...
static constexpr TransactionSerParams TX_WITH_WITNESS
Definition: transaction.h:195
const char * name
Definition: rest.cpp:49
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:58
#define SEND_CONFIRM_DELAY
A mutable version of CTransaction.
Definition: transaction.h:378
A version of CTransaction with the PSBT format.
Definition: psbt.h:1119
Collection of wallet balances.
Definition: wallet.h:371
bool balanceChanged(const WalletBalances &prev) const
Definition: wallet.h:376
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
std::string EncodeBase64(std::span< const unsigned char > input)
assert(!tx.IsCoinBase())
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:544
static void NotifyTransactionChanged(WalletModel *walletmodel, const Txid &hash, ChangeType status)
static void NotifyUnload(WalletModel *walletModel)
static void NotifyAddressBookChanged(WalletModel *walletmodel, const CTxDestination &address, const std::string &label, bool isMine, wallet::AddressPurpose purpose, ChangeType status)
static void NotifyCanGetAddressesChanged(WalletModel *walletmodel)
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)