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