X Tutup
Skip to content

Commit a11dbaa

Browse files
committed
0.18: wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction
Github-Pull: bitcoin#16322 Rebased-From: 5c1b971
1 parent 8f354ce commit a11dbaa

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,11 +2690,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
26902690
}
26912691
}
26922692

2693-
if (nFeeRet > maxTxFee) {
2694-
strFailReason = _("Fee exceeds maximum configured by -maxtxfee");
2695-
return false;
2696-
}
2697-
26982693
return true;
26992694
}
27002695

@@ -3131,6 +3126,11 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
31313126
}
31323127
}
31333128

3129+
if (nFeeRet > maxTxFee) {
3130+
strFailReason = _("Fee exceeds maximum configured by -maxtxfee");
3131+
return false;
3132+
}
3133+
31343134
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
31353135
// Lastly, ensure this tx will pass the mempool's chain limits
31363136
LockPoints lp;

test/functional/rpc_psbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def run_test(self):
134134
assert_greater_than(0.06, res["fee"])
135135

136136
# feeRate of 10 BTC / KB produces a total fee well above -maxtxfee
137-
# previously this was silenty capped at -maxtxfee
137+
# previously this was silently capped at -maxtxfee
138138
assert_raises_rpc_error(-4, "Fee exceeds maximum configured by -maxtxfee", self.nodes[1].walletcreatefundedpsbt, [{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99}, 0, {"feeRate": 10})
139139

140140
# partially sign multisig things with node 1

test/functional/wallet_bumpfee.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def run_test(self):
7373
test_unconfirmed_not_spendable(rbf_node, rbf_node_address)
7474
test_bumpfee_metadata(rbf_node, dest_address)
7575
test_locked_wallet_fails(rbf_node, dest_address)
76+
test_maxtxfee_fails(self, rbf_node, dest_address)
7677
self.log.info("Success")
7778

7879

@@ -204,6 +205,15 @@ def test_settxfee(rbf_node, dest_address):
204205
rbf_node.settxfee(Decimal("0.00000000")) # unset paytxfee
205206

206207

208+
def test_maxtxfee_fails(test, rbf_node, dest_address):
209+
test.restart_node(1, ['-maxtxfee=0.00003'] + test.extra_args[1])
210+
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
211+
rbfid = spend_one_input(rbf_node, dest_address)
212+
assert_raises_rpc_error(-4, "Specified or calculated fee 0.0000332 is too high (cannot be higher than maxTxFee 0.00003)", rbf_node.bumpfee, rbfid)
213+
test.restart_node(1, test.extra_args[1])
214+
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
215+
216+
207217
def test_rebumping(rbf_node, dest_address):
208218
# check that re-bumping the original tx fails, but bumping the bumper succeeds
209219
rbfid = spend_one_input(rbf_node, dest_address)

0 commit comments

Comments
 (0)
X Tutup