Bitcoin Core 22.99.0
P2P Digital Currency
walletmodel.cpp
Go to the documentation of this file.
1// Copyright (c) 2011-2020 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#if defined(HAVE_CONFIG_H)
7#endif
8
9#include <qt/walletmodel.h>
10
12#include <qt/clientmodel.h>
13#include <qt/guiconstants.h>
14#include <qt/guiutil.h>
15#include <qt/optionsmodel.h>
16#include <qt/paymentserver.h>
18#include <qt/sendcoinsdialog.h>
20
21#include <interfaces/handler.h>
22#include <interfaces/node.h>
23#include <key_io.h>
24#include <node/ui_interface.h>
25#include <psbt.h>
26#include <util/system.h> // for GetBoolArg
27#include <util/translation.h>
28#include <wallet/coincontrol.h>
29#include <wallet/wallet.h> // for CRecipient
30
31#include <stdint.h>
32#include <functional>
33
34#include <QDebug>
35#include <QMessageBox>
36#include <QSet>
37#include <QTimer>
38
39
40WalletModel::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();
54 transactionTableModel = new TransactionTableModel(platformStyle, this);
56
58}
59
61{
63}
64
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);
73}
74
76{
77 m_client_model = client_model;
78 if (!m_client_model) timer->stop();
79}
80
82{
83 EncryptionStatus newEncryptionStatus = getEncryptionStatus();
84
85 if(cachedEncryptionStatus != newEncryptionStatus) {
87 }
88}
89
91{
92 // Avoid recomputing wallet balances unless a TransactionChanged or
93 // BlockTip notification was received.
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
108
109 // Balance and number of transactions might have changed
110 m_cached_last_update_tip = block_hash;
111
112 checkBalanceChanged(new_balances);
115 }
116}
117
119{
120 if(new_balances.balanceChanged(m_cached_balances)) {
121 m_cached_balances = new_balances;
122 Q_EMIT balanceChanged(new_balances);
123 }
124}
125
127{
128 // Balance and number of transactions might have changed
130}
131
132void WalletModel::updateAddressBook(const QString &address, const QString &label,
133 bool isMine, const QString &purpose, int status)
134{
136 addressTableModel->updateEntry(address, label, isMine, purpose, status);
137}
138
139void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
140{
141 fHaveWatchOnly = fHaveWatchonly;
142 Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
143}
144
145bool WalletModel::validateAddress(const QString &address)
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 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 {
199 }
200
201 {
202 CAmount nFeeRequired = 0;
203 int nChangePosRet = -1;
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 {
217 }
218 Q_EMIT message(tr("Send Coins"), QString::fromStdString(error.translated),
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
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
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
285{
286 return optionsModel;
287}
288
290{
291 return addressTableModel;
292}
293
295{
297}
298
300{
302}
303
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
321{
322 return m_wallet->encryptWallet(passphrase);
323}
324
325bool 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
339bool 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
346static void NotifyUnload(WalletModel* walletModel)
347{
348 qDebug() << "NotifyUnload";
349 bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
350 assert(invoked);
351}
352
354{
355 qDebug() << "NotifyKeyStoreStatusChanged";
356 bool invoked = QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
357 assert(invoked);
358}
359
360static 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
378static 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
386static 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
395static 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
403{
404 bool invoked = QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged");
405 assert(invoked);
406}
407
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
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();
430}
431
432// WalletModel::UnlockContext implementation
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
447WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
448 wallet(_wallet),
449 valid(_valid),
450 relock(_relock)
451{
452}
453
455{
456 if(valid && relock)
457 {
458 wallet->setWalletLocked(true);
459 }
460}
461
463{
464 // Transfer context; old object no longer relocks wallet
465 *this = rhs;
466 rhs.relock = false;
467}
468
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;
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 auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString);
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) {
516 return false;
517 }
518
520 if(!ctx.isValid())
521 {
522 return false;
523 }
524
525 // Short-circuit if we are returning a bumped transaction PSBT to clipboard
526 if (create_psbt) {
528 bool complete = false;
529 const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
530 if (err != TransactionError::OK || complete) {
531 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
532 return false;
533 }
534 // Serialize the PSBT
536 ssTx << psbtx;
537 GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
538 Q_EMIT message(tr("PSBT copied"), "Copied to clipboard", CClientUIInterface::MSG_INFORMATION);
539 return true;
540 }
541
542 // sign bumped transaction
543 if (!m_wallet->signBumpTransaction(mtx)) {
544 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));
545 return false;
546 }
547 // commit the bumped transaction
548 if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
549 QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
550 QString::fromStdString(errors[0].translated)+")");
551 return false;
552 }
553 return true;
554}
555
556bool WalletModel::displayAddress(std::string sAddress)
557{
558 CTxDestination dest = DecodeDestination(sAddress);
559 bool res = false;
560 try {
561 res = m_wallet->displayAddress(dest);
562 } catch (const std::runtime_error& e) {
563 QMessageBox::critical(nullptr, tr("Can't display address"), e.what());
564 }
565 return res;
566}
567
569{
570 return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
571}
572
574{
575 return QString::fromStdString(m_wallet->getWalletName());
576}
577
579{
580 const QString name = getWalletName();
581 return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
582}
583
585{
586 return m_node.walletClient().getWallets().size() > 1;
587}
588
589void WalletModel::refresh(bool pk_hash_only)
590{
591 addressTableModel = new AddressTableModel(this, pk_hash_only);
592}
593
595{
597}
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
NodeContext m_node
Definition: bitcoin-gui.cpp:36
Qt model of the address book in the core.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:602
static QString formatHtmlWithUnit(int 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: ui_interface.h:66
Coin Control Features.
Definition: coincontrol.h:29
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
Definition: coincontrol.h:50
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:205
std::string str() const
Definition: streams.h:242
value_type * data()
Definition: streams.h:264
size_type size() const
Definition: streams.h:255
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:406
Model for Bitcoin network client.
Definition: clientmodel.h:48
uint256 getBestBlockHash()
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:39
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)
void CopyFrom(UnlockContext &&rhs)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:52
OptionsModel * optionsModel
Definition: walletmodel.h:176
bool validateAddress(const QString &address)
AddressTableModel * addressTableModel
Definition: walletmodel.h:178
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:184
void refresh(bool pk_hash_only=false)
uint256 m_cached_last_update_tip
Definition: walletmodel.h:188
ClientModel * m_client_model
Definition: walletmodel.h:168
std::unique_ptr< interfaces::Handler > m_handler_watch_only_changed
Definition: walletmodel.h:166
interfaces::Node & m_node
Definition: walletmodel.h:169
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: walletmodel.h:164
void startPollBalance()
Definition: walletmodel.cpp:65
void pollBalanceChanged()
Definition: walletmodel.cpp:90
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
RecentRequestsTableModel * recentRequestsTableModel
Definition: walletmodel.h:180
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:179
bool setWalletEncrypted(const SecureString &passphrase)
void notifyWatchonlyChanged(bool fHaveWatchonly)
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
void message(const QString &title, const QString &message, unsigned int style)
bool displayAddress(std::string sAddress)
void setClientModel(ClientModel *client_model)
Definition: walletmodel.cpp:75
void updateStatus()
Definition: walletmodel.cpp:81
AddressTableModel * getAddressTableModel()
OptionsModel * getOptionsModel()
std::unique_ptr< interfaces::Handler > m_handler_can_get_addrs_changed
Definition: walletmodel.h:167
std::unique_ptr< interfaces::Handler > m_handler_unload
Definition: walletmodel.h:161
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl &coinControl)
EncryptionStatus getEncryptionStatus() const
interfaces::Wallet & wallet() const
Definition: walletmodel.h:144
RecentRequestsTableModel * getRecentRequestsTableModel()
std::unique_ptr< interfaces::Handler > m_handler_status_changed
Definition: walletmodel.h:162
interfaces::WalletBalances m_cached_balances
Definition: walletmodel.h:183
bool fForceCheckBalanceChanged
Definition: walletmodel.h:172
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
QString getDisplayName() const
bool bumpFee(uint256 hash, uint256 &new_hash)
void checkBalanceChanged(const interfaces::WalletBalances &new_balances)
bool isMultiwallet()
void unsubscribeFromCoreSignals()
void updateTransaction()
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
uint256 getLastBlockProcessed() const
QTimer * timer
Definition: walletmodel.h:185
bool fHaveWatchOnly
Definition: walletmodel.h:171
WalletModel(std::unique_ptr< interfaces::Wallet > wallet, ClientModel &client_model, const PlatformStyle *platformStyle, QObject *parent=nullptr)
Definition: walletmodel.cpp:40
void updateWatchOnlyFlag(bool fHaveWatchonly)
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()
QString getWalletName() const
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: walletmodel.h:165
@ AmountWithFeeExceedsBalance
Definition: walletmodel.h:65
@ TransactionCreationFailed
Definition: walletmodel.h:67
@ AmountExceedsBalance
Definition: walletmodel.h:64
@ DuplicateAddress
Definition: walletmodel.h:66
void subscribeToCoreSignals()
TransactionTableModel * getTransactionTableModel()
Data model for a walletmodel transaction.
void setTransactionFee(const CAmount &newFee)
void reassignAmounts(int nChangePosRet)
QList< SendCoinsRecipient > getRecipients() const
virtual WalletClient & walletClient()=0
Get wallet client.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
virtual TransactionError fillPSBT(int sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
void push_back(const T &value)
Definition: prevector.h:437
256-bit opaque blob.
Definition: uint256.h:124
TransactionError
Definition: error.h:22
static const int MODEL_UPDATE_DELAY
Definition: guiconstants.h:11
@ SIGHASH_ALL
Definition: interpreter.h:27
bool IsValidDestinationString(const std::string &str, const CChainParams &params)
Definition: key_io.cpp:272
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:256
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
Definition: key_io.cpp:261
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:392
void setClipboard(const QString &str)
Definition: guiutil.cpp:645
const char * name
Definition: rest.cpp:43
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:59
@ SER_NETWORK
Definition: serialize.h:138
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:310
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
std::string EncodeBase64(Span< const unsigned char > input)
A mutable version of CTransaction.
Definition: transaction.h:345
A version of CTransaction with the PSBT format.
Definition: psbt.h:392
Bilingual messages:
Definition: translation.h:16
Collection of wallet balances.
Definition: wallet.h:356
bool balanceChanged(const WalletBalances &prev) const
Definition: wallet.h:365
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
static secp256k1_context * ctx
Definition: tests.c:42
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
ArgsManager gArgs
Definition: system.cpp:85
assert(!tx.IsCoinBase())
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:12
std::shared_ptr< CWallet > m_wallet
Definition: interfaces.cpp:502
static const bool DEFAULT_DISABLE_WALLET
Definition: wallet.h:97
static void NotifyUnload(WalletModel *walletModel)
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
static void NotifyCanGetAddressesChanged(WalletModel *walletmodel)
static void NotifyAddressBookChanged(WalletModel *walletmodel, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)