From 21810a998309dba12843e146caad224093680794 Mon Sep 17 00:00:00 2001 From: Yevhen Hrubiian Date: Mon, 16 Nov 2026 08:24:44 +0200 Subject: [PATCH] wallet: don't abort bumpfee on a transaction with blinded inputs CreateRateBumpTransaction summed the inputs with GetAmount(), which asserts that the amount is explicit, so bumpfee/psbtbumpfee on any wallet transaction spending a confidential coin aborted the node. Return the existing "can only be called on an unblinded transaction" error instead. --- src/wallet/feebumper.cpp | 5 ++ test/functional/test_runner.py | 2 + .../wallet_elements_bumpfee_blinded.py | 57 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100755 test/functional/wallet_elements_bumpfee_blinded.py diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 39cb4cd64f..0b3bbe5e42 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -205,6 +205,11 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo errors.emplace_back(Untranslated(strprintf("%s:%u is already spent", txin.prevout.hash.GetHex(), txin.prevout.n))); return Result::MISC_ERROR; } + // ELEMENTS: the input value is summed below, which needs explicit amounts. + if (!coin.out.nValue.IsExplicit() || !coin.out.nAsset.IsExplicit()) { + errors.push_back(Untranslated("bumpfee can only be called on an unblinded transaction")); + return Result::WALLET_ERROR; + } PreselectedInput& preset_txin = new_coin_control.Select(txin.prevout); if (!wallet.IsMine(txin.prevout)) { preset_txin.SetTxOut(coin.out); diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 529c80a9a2..bf2b966bc2 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -121,6 +121,8 @@ 'wallet_elements_regression_1259.py --legacy-wallet', 'wallet_elements_21million.py --legacy-wallet', 'wallet_elements_dust_relay.py --legacy-wallet', + 'wallet_elements_bumpfee_blinded.py --legacy-wallet', + 'wallet_elements_bumpfee_blinded.py --descriptors', # Longest test should go first, to favor running tests in parallel # vv Tests less than 5m vv 'feature_taproot.py', diff --git a/test/functional/wallet_elements_bumpfee_blinded.py b/test/functional/wallet_elements_bumpfee_blinded.py new file mode 100755 index 0000000000..4ba870b108 --- /dev/null +++ b/test/functional/wallet_elements_bumpfee_blinded.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026 The Elements Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""Test bumpfee and psbtbumpfee on a wallet transaction that spends a blinded (confidential) coin. + +The fee bumper summed the input amounts with GetAmount(), which asserts that the amount is explicit, +so bumping such a transaction aborted the node. It must fail with an RPC error instead, as it already +does for a transaction with blinded outputs. +""" + +from decimal import Decimal + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_raises_rpc_error + +UNBLINDED_ONLY = "bumpfee can only be called on an unblinded transaction" + + +class BumpFeeBlindedInputTest(BitcoinTestFramework): + def set_test_params(self): + self.num_nodes = 1 + self.extra_args = [["-blindedaddresses=1"]] + + def add_options(self, parser): + self.add_wallet_options(parser) + + def skip_test_if_missing_module(self): + self.skip_if_no_wallet() + + def run_test(self): + node = self.nodes[0] + + self.log.info("Create a blinded coin") + node.sendtoaddress(node.getnewaddress(), 5) + self.generate(node, 1) + coin = next(u for u in node.listunspent() if "amountcommitment" in u) + + self.log.info("Spend it in a replaceable transaction") + fee = Decimal("0.0001") + raw = node.createrawtransaction([{"txid": coin["txid"], "vout": coin["vout"]}], + [{node.getnewaddress(): coin["amount"] - fee}, {"fee": fee}], + 0, True) + signed = node.signrawtransactionwithwallet(node.blindrawtransaction(raw)) + assert signed["complete"] + txid = node.sendrawtransaction(signed["hex"]) + + self.log.info("bumpfee and psbtbumpfee fail with an RPC error and the node keeps running") + assert_raises_rpc_error(-4, UNBLINDED_ONLY, node.bumpfee, txid) + assert_raises_rpc_error(-4, UNBLINDED_ONLY, node.psbtbumpfee, txid) + explicit_output = {node.getaddressinfo(node.getnewaddress())["unconfidential"]: coin["amount"] - 2 * fee} + assert_raises_rpc_error(-4, UNBLINDED_ONLY, node.bumpfee, txid, {"outputs": [explicit_output]}) + assert txid in node.getrawmempool() + + +if __name__ == '__main__': + BumpFeeBlindedInputTest(__file__).main()