Skip to content

Commit 9c7b7cf

Browse files
committed
Merge #9592: [Qt] Add checkbox in the GUI to opt-in to RBF when creating a transaction
c4e4792 [Qt] Change RBF checkbox to reflect -walletrbf setting (Russell Yanofsky) 838a58e [Qt] Add simple optin-RBF checkbox and confirmation info (Jonas Schnelli) 568c05a Allow to opt-into RBF when creating a transaction (Jonas Schnelli) Tree-SHA512: 3d52dcd4e44da8aed4d631748074afef78d38c860f2a8b95323f4801a989d6599a3498a753fc10daba4098c527ef5a0eb942e5b3f1bfd656e1a6bd272b8e6c57
2 parents a387d3a + c4e4792 commit 9c7b7cf

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

src/qt/forms/sendcoinsdialog.ui

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,16 @@
11801180
</item>
11811181
</layout>
11821182
</item>
1183+
<item>
1184+
<widget class="QCheckBox" name="optInRBF">
1185+
<property name="text">
1186+
<string>Request Replace-By-Fee</string>
1187+
</property>
1188+
<property name="toolTip">
1189+
<string>Indicates that the sender may wish to replace this transaction with a new one paying higher fees (prior to being confirmed).</string>
1190+
</property>
1191+
</widget>
1192+
</item>
11831193
</layout>
11841194
</widget>
11851195
</item>
@@ -1190,8 +1200,8 @@
11901200
</property>
11911201
<property name="sizeHint" stdset="0">
11921202
<size>
1193-
<width>800</width>
1194-
<height>1</height>
1203+
<width>40</width>
1204+
<height>5</height>
11951205
</size>
11961206
</property>
11971207
</spacer>

src/qt/sendcoinsdialog.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
114114
ui->groupCustomFee->button((int)std::max(0, std::min(1, settings.value("nCustomFeeRadio").toInt())))->setChecked(true);
115115
ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
116116
ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
117+
ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked);
117118
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
118119
}
119120

@@ -247,6 +248,8 @@ void SendCoinsDialog::on_sendButton_clicked()
247248
else
248249
ctrl.nConfirmTarget = 0;
249250

251+
ctrl.signalRbf = ui->optInRBF->isChecked();
252+
250253
prepareStatus = model->prepareTransaction(currentTransaction, &ctrl);
251254

252255
// process prepareStatus and on error generate message shown to user
@@ -326,6 +329,13 @@ void SendCoinsDialog::on_sendButton_clicked()
326329
questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
327330
.arg(alternativeUnits.join(" " + tr("or") + "<br />")));
328331

332+
if (ui->optInRBF->isChecked())
333+
{
334+
questionString.append("<hr /><span>");
335+
questionString.append(tr("This transaction signals replaceability (optin-RBF)."));
336+
questionString.append("</span>");
337+
}
338+
329339
SendConfirmationDialog confirmationDialog(tr("Confirm send coins"),
330340
questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this);
331341
confirmationDialog.exec();

src/qt/walletmodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,8 @@ int WalletModel::getDefaultConfirmTarget() const
706706
{
707707
return nTxConfirmTarget;
708708
}
709+
710+
bool WalletModel::getDefaultWalletRbf() const
711+
{
712+
return fWalletRbf;
713+
}

src/qt/walletmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ class WalletModel : public QObject
213213

214214
int getDefaultConfirmTarget() const;
215215

216+
bool getDefaultWalletRbf() const;
217+
216218
private:
217219
CWallet *wallet;
218220
bool fHaveWatchOnly;

src/wallet/coincontrol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define BITCOIN_WALLET_COINCONTROL_H
77

88
#include "primitives/transaction.h"
9+
#include "wallet/wallet.h"
910

1011
/** Coin Control Features. */
1112
class CCoinControl
@@ -24,6 +25,8 @@ class CCoinControl
2425
CFeeRate nFeeRate;
2526
//! Override the default confirmation target, 0 = use default
2627
int nConfirmTarget;
28+
//! Signal BIP-125 replace by fee.
29+
bool signalRbf;
2730

2831
CCoinControl()
2932
{
@@ -40,6 +43,7 @@ class CCoinControl
4043
nFeeRate = CFeeRate(0);
4144
fOverrideFeeRate = false;
4245
nConfirmTarget = 0;
46+
signalRbf = fWalletRbf;
4347
}
4448

4549
bool HasSelected() const

src/wallet/wallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2517,9 +2517,10 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
25172517
// to avoid conflicting with other possible uses of nSequence,
25182518
// and in the spirit of "smallest possible change from prior
25192519
// behavior."
2520+
bool rbf = coinControl ? coinControl->signalRbf : fWalletRbf;
25202521
for (const auto& coin : setCoins)
25212522
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
2522-
std::numeric_limits<unsigned int>::max() - (fWalletRbf ? 2 : 1)));
2523+
std::numeric_limits<unsigned int>::max() - (rbf ? 2 : 1)));
25232524

25242525
// Fill in dummy signatures for fee calculation.
25252526
if (!DummySignTx(txNew, setCoins)) {

0 commit comments

Comments
 (0)