Skip to content

Commit 8e6f9f4

Browse files
committed
Merge #12296: wallet: Only fee-bump non-conflicted/non-confirmed txes
faca18d feebumper: Use PreconditionChecks to determine bump eligibility (MarcoFalke) 718f05c move more bumpfee prechecks to feebumper::PreconditionChecks (Gregory Sanders) Pull request description: This only affects the gui. Fee-bumping of transactions that are already confirmed or are already conflicted by other transactions should not be offered by the gui. Tree-SHA512: 4acf8087c69fbe5bd67be0485cdb4055e985bbf84acc420aa786ad31e2dc6c2572baaac1d359af10a6907790f626edca690285d9a46ae5440900ea12624c634f
2 parents c8b54b2 + faca18d commit 8e6f9f4

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

src/wallet/feebumper.cpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,39 @@ static feebumper::Result PreconditionChecks(const CWallet* wallet, const CWallet
6565
errors.push_back("Transaction has been mined, or is conflicted with a mined transaction");
6666
return feebumper::Result::WALLET_ERROR;
6767
}
68+
69+
if (!SignalsOptInRBF(*wtx.tx)) {
70+
errors.push_back("Transaction is not BIP 125 replaceable");
71+
return feebumper::Result::WALLET_ERROR;
72+
}
73+
74+
if (wtx.mapValue.count("replaced_by_txid")) {
75+
errors.push_back(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid")));
76+
return feebumper::Result::WALLET_ERROR;
77+
}
78+
79+
// check that original tx consists entirely of our inputs
80+
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
81+
if (!wallet->IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
82+
errors.push_back("Transaction contains inputs that don't belong to this wallet");
83+
return feebumper::Result::WALLET_ERROR;
84+
}
85+
86+
6887
return feebumper::Result::OK;
6988
}
7089

7190
namespace feebumper {
7291

73-
bool TransactionCanBeBumped(CWallet* wallet, const uint256& txid)
92+
bool TransactionCanBeBumped(const CWallet* wallet, const uint256& txid)
7493
{
7594
LOCK2(cs_main, wallet->cs_wallet);
7695
const CWalletTx* wtx = wallet->GetWalletTx(txid);
77-
return wtx && SignalsOptInRBF(*wtx->tx) && !wtx->mapValue.count("replaced_by_txid");
96+
if (wtx == nullptr) return false;
97+
98+
std::vector<std::string> errors_dummy;
99+
feebumper::Result res = PreconditionChecks(wallet, *wtx, errors_dummy);
100+
return res == feebumper::Result::OK;
78101
}
79102

80103
Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoinControl& coin_control, CAmount total_fee, std::vector<std::string>& errors,
@@ -94,23 +117,6 @@ Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoin
94117
return result;
95118
}
96119

97-
if (!SignalsOptInRBF(*wtx.tx)) {
98-
errors.push_back("Transaction is not BIP 125 replaceable");
99-
return Result::WALLET_ERROR;
100-
}
101-
102-
if (wtx.mapValue.count("replaced_by_txid")) {
103-
errors.push_back(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", txid.ToString(), wtx.mapValue.at("replaced_by_txid")));
104-
return Result::WALLET_ERROR;
105-
}
106-
107-
// check that original tx consists entirely of our inputs
108-
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
109-
if (!wallet->IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
110-
errors.push_back("Transaction contains inputs that don't belong to this wallet");
111-
return Result::WALLET_ERROR;
112-
}
113-
114120
// figure out which output was change
115121
// if there was no change output or multiple change outputs, fail
116122
int nOutput = -1;
@@ -228,6 +234,7 @@ Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoin
228234
}
229235
}
230236

237+
231238
return Result::OK;
232239
}
233240

src/wallet/feebumper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum class Result
2626
};
2727

2828
//! Return whether transaction can be bumped.
29-
bool TransactionCanBeBumped(CWallet* wallet, const uint256& txid);
29+
bool TransactionCanBeBumped(const CWallet* wallet, const uint256& txid);
3030

3131
//! Create bumpfee transaction.
3232
Result CreateTransaction(const CWallet* wallet,

0 commit comments

Comments
 (0)