Skip to content

Commit 742f84d

Browse files
committed
Merge #17492: QT: bump fee returns PSBT on clipboard for watchonly-only wallets
3c30d71 QT: Change bumpFee asserts to simple error message (Gregory Sanders) e3b19d8 QT: bump fee returns PSBT on clipboard for watchonly-only wallets (Gregory Sanders) Pull request description: Very small set of changes to support PSBT-based fee bumping on watchonly wallets in QT. quasi-companion to bitcoin/bitcoin#16373 ACKs for top commit: gwillen: code review ACK 3c30d71 promag: Code review ACK 3c30d71. Sjors: utACK 3c30d71 achow101: ACK 3c30d71 Tree-SHA512: 7a706141e46d7fd0ad513a08a96c16f2e7e531427a6776b689362f82e32cbd9d4b7eeb98f6936aa3f9347d23ccc94128516fcffa695efacd9cac43606ea916e2
2 parents 631df3e + 3c30d71 commit 742f84d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/qt/walletmodel.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <qt/addresstablemodel.h>
1212
#include <qt/guiconstants.h>
13+
#include <qt/guiutil.h>
1314
#include <qt/optionsmodel.h>
1415
#include <qt/paymentserver.h>
1516
#include <qt/recentrequeststablemodel.h>
@@ -487,8 +488,10 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
487488
return false;
488489
}
489490

491+
const bool create_psbt = privateKeysDisabled();
492+
490493
// allow a user based fee verification
491-
QString questionString = tr("Do you want to increase the fee?");
494+
QString questionString = create_psbt ? tr("Do you want to draft a transaction with fee increase?") : tr("Do you want to increase the fee?");
492495
questionString.append("<br />");
493496
questionString.append("<table style=\"text-align: left;\">");
494497
questionString.append("<tr><td>");
@@ -519,6 +522,23 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
519522
return false;
520523
}
521524

525+
// Short-circuit if we are returning a bumped transaction PSBT to clipboard
526+
if (create_psbt) {
527+
PartiallySignedTransaction psbtx(mtx);
528+
bool complete = false;
529+
const TransactionError err = wallet().fillPSBT(psbtx, complete, SIGHASH_ALL, false /* sign */, true /* bip32derivs */);
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
535+
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
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+
522542
// sign bumped transaction
523543
if (!m_wallet->signBumpTransaction(mtx)) {
524544
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));

0 commit comments

Comments
 (0)