Skip to content

Commit e3b19d8

Browse files
committed
QT: bump fee returns PSBT on clipboard for watchonly-only wallets
1 parent 45f1519 commit e3b19d8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/qt/walletmodel.cpp

Lines changed: 19 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,21 @@ 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+
assert(!complete);
531+
assert(err == TransactionError::OK);
532+
// Serialize the PSBT
533+
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
534+
ssTx << psbtx;
535+
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
536+
Q_EMIT message(tr("PSBT copied"), "Copied to clipboard", CClientUIInterface::MSG_INFORMATION);
537+
return true;
538+
}
539+
522540
// sign bumped transaction
523541
if (!m_wallet->signBumpTransaction(mtx)) {
524542
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't sign transaction."));

0 commit comments

Comments
 (0)