From 568c05a591705552b435d384e526f702e23a08c9 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 3 Dec 2015 09:53:23 +0100 Subject: [PATCH 1/3] Allow to opt-into RBF when creating a transaction --- src/wallet/coincontrol.h | 4 ++++ src/wallet/wallet.cpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index eaf4ff806..4e93e929b 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -6,6 +6,7 @@ #define BITCOIN_WALLET_COINCONTROL_H #include "primitives/transaction.h" +#include "wallet/wallet.h" /** Coin Control Features. */ class CCoinControl @@ -24,6 +25,8 @@ public: CFeeRate nFeeRate; //! Override the default confirmation target, 0 = use default int nConfirmTarget; + //! Signal BIP-125 replace by fee. + bool signalRbf; CCoinControl() { @@ -40,6 +43,7 @@ public: nFeeRate = CFeeRate(0); fOverrideFeeRate = false; nConfirmTarget = 0; + signalRbf = fWalletRbf; } bool HasSelected() const diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 625199809..1dddafb77 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2566,9 +2566,10 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt // to avoid conflicting with other possible uses of nSequence, // and in the spirit of "smallest posible change from prior // behavior." + bool rbf = coinControl ? coinControl->signalRbf : fWalletRbf; for (const auto& coin : setCoins) txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(), - std::numeric_limits::max() - (fWalletRbf ? 2 : 1))); + std::numeric_limits::max() - (rbf ? 2 : 1))); // Fill in dummy signatures for fee calculation. int nIn = 0; From 838a58e7ca5c534ae125ab510fbd65d2feec72a9 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 5 Apr 2016 16:55:41 +0200 Subject: [PATCH 2/3] [Qt] Add simple optin-RBF checkbox and confirmation info --- src/qt/forms/sendcoinsdialog.ui | 14 ++++++++++++-- src/qt/sendcoinsdialog.cpp | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index ca8ecffaf..e25fe054e 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -1158,6 +1158,16 @@ + + + + Request Replace-By-Fee + + + Indicates that the sender may wish to replace this transaction with a new one paying higher fees (prior to being confirmed). + + + @@ -1168,8 +1178,8 @@ - 800 - 1 + 40 + 5 diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 5aeda7a30..c30120c02 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -245,6 +245,8 @@ void SendCoinsDialog::on_sendButton_clicked() else ctrl.nConfirmTarget = 0; + ctrl.signalRbf = ui->optInRBF->isChecked(); + prepareStatus = model->prepareTransaction(currentTransaction, &ctrl); // process prepareStatus and on error generate message shown to user @@ -324,6 +326,13 @@ void SendCoinsDialog::on_sendButton_clicked() questionString.append(QString("
(=%2)
") .arg(alternativeUnits.join(" " + tr("or") + "
"))); + if (ui->optInRBF->isChecked()) + { + questionString.append("
"); + questionString.append(tr("This transaction signals replaceability (optin-RBF).")); + questionString.append(""); + } + SendConfirmationDialog confirmationDialog(tr("Confirm send coins"), questionString.arg(formatted.join("
")), SEND_CONFIRM_DELAY, this); confirmationDialog.exec(); From c4e4792c537bae6228fc3438dd971634985922f4 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Thu, 19 Jan 2017 18:19:39 -0500 Subject: [PATCH 3/3] [Qt] Change RBF checkbox to reflect -walletrbf setting Before this commit, the checkbox would always start off unchecked. After this commit it will respect the -walletrbf setting (which is currently false by default). --- src/qt/sendcoinsdialog.cpp | 1 + src/qt/walletmodel.cpp | 5 +++++ src/qt/walletmodel.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index c30120c02..ee841c254 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -112,6 +112,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p ui->groupCustomFee->button((int)std::max(0, std::min(1, settings.value("nCustomFeeRadio").toInt())))->setChecked(true); ui->customFee->setValue(settings.value("nTransactionFee").toLongLong()); ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool()); + ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked); minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool()); } diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 0a5a7c3e9..8004e9b25 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -706,3 +706,8 @@ int WalletModel::getDefaultConfirmTarget() const { return nTxConfirmTarget; } + +bool WalletModel::getDefaultWalletRbf() const +{ + return fWalletRbf; +} diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index cd7585635..78e45dc36 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -213,6 +213,8 @@ public: int getDefaultConfirmTarget() const; + bool getDefaultWalletRbf() const; + private: CWallet *wallet; bool fHaveWatchOnly;