Skip to content

Commit 718f05c

Browse files
committed
move more bumpfee prechecks to feebumper::PreconditionChecks
1 parent b5e4b9b commit 718f05c

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/wallet/feebumper.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ 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

@@ -94,23 +113,6 @@ Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoin
94113
return result;
95114
}
96115

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-
114116
// figure out which output was change
115117
// if there was no change output or multiple change outputs, fail
116118
int nOutput = -1;
@@ -228,6 +230,7 @@ Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoin
228230
}
229231
}
230232

233+
231234
return Result::OK;
232235
}
233236

0 commit comments

Comments
 (0)