@@ -41,6 +41,31 @@ int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *pWal
41
41
return GetVirtualTransactionSize (txNew);
42
42
}
43
43
44
+ bool CFeeBumper::preconditionChecks (const CWallet *pWallet, const CWalletTx& wtx) {
45
+ if (pWallet->HasWalletSpend (wtx.GetHash ())) {
46
+ vErrors.push_back (" Transaction has descendants in the wallet" );
47
+ currentResult = BumpFeeResult::INVALID_PARAMETER;
48
+ return false ;
49
+ }
50
+
51
+ {
52
+ LOCK (mempool.cs );
53
+ auto it_mp = mempool.mapTx .find (wtx.GetHash ());
54
+ if (it_mp != mempool.mapTx .end () && it_mp->GetCountWithDescendants () > 1 ) {
55
+ vErrors.push_back (" Transaction has descendants in the mempool" );
56
+ currentResult = BumpFeeResult::INVALID_PARAMETER;
57
+ return false ;
58
+ }
59
+ }
60
+
61
+ if (wtx.GetDepthInMainChain () != 0 ) {
62
+ vErrors.push_back (" Transaction has been mined, or is conflicted with a mined transaction" );
63
+ currentResult = BumpFeeResult::WALLET_ERROR;
64
+ return false ;
65
+ }
66
+ return true ;
67
+ }
68
+
44
69
CFeeBumper::CFeeBumper (const CWallet *pWallet, const uint256 txidIn, int newConfirmTarget, bool specifiedConfirmTarget, CAmount totalFee, bool newTxReplaceable)
45
70
:
46
71
txid(std::move(txidIn)),
@@ -58,25 +83,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
58
83
auto it = pWallet->mapWallet .find (txid);
59
84
const CWalletTx& wtx = it->second ;
60
85
61
- if (pWallet->HasWalletSpend (txid)) {
62
- vErrors.push_back (" Transaction has descendants in the wallet" );
63
- currentResult = BumpFeeResult::INVALID_PARAMETER;
64
- return ;
65
- }
66
-
67
- {
68
- LOCK (mempool.cs );
69
- auto it_mp = mempool.mapTx .find (txid);
70
- if (it_mp != mempool.mapTx .end () && it_mp->GetCountWithDescendants () > 1 ) {
71
- vErrors.push_back (" Transaction has descendants in the mempool" );
72
- currentResult = BumpFeeResult::INVALID_PARAMETER;
73
- return ;
74
- }
75
- }
76
-
77
- if (wtx.GetDepthInMainChain () != 0 ) {
78
- vErrors.push_back (" Transaction has been mined, or is conflicted with a mined transaction" );
79
- currentResult = BumpFeeResult::WALLET_ERROR;
86
+ if (!preconditionChecks (pWallet, wtx)) {
80
87
return ;
81
88
}
82
89
@@ -248,6 +255,11 @@ bool CFeeBumper::commit(CWallet *pWallet)
248
255
}
249
256
CWalletTx& oldWtx = pWallet->mapWallet [txid];
250
257
258
+ // make sure the transaction still has no descendants and hasen't been mined in the meantime
259
+ if (!preconditionChecks (pWallet, oldWtx)) {
260
+ return false ;
261
+ }
262
+
251
263
CWalletTx wtxBumped (pWallet, MakeTransactionRef (std::move (mtx)));
252
264
// commit/broadcast the tx
253
265
CReserveKey reservekey (pWallet);
0 commit comments