Skip to content

wallet: Use util::Result for fee bumping methods - #37017

Open
rustaceanrob wants to merge 2 commits into
bitcoin:masterfrom
rustaceanrob:refactor-fee-bumper-expected
Open

rustaceanrob wants to merge 2 commits into
bitcoin:masterfrom
rustaceanrob:refactor-fee-bumper-expected

Conversation

@rustaceanrob

Copy link
Copy Markdown
Member

Currently the fee bumping transactions use in/out params and a feebumper::Result type to report error status. This is emulating util::Result and util::Expected. There are also a few problems in the current implementation: There is an error vector passed to each method, but only one error can occupy it at any time. In the case that a transaction cannot be marked as replaced, the error is actually treated as a warning and shown to the user. The INVALID_REQUEST variant is not used.

We can resolve these using the existing util::Result and Expected. This is also required for #35302 in CreateRateBumpTransaction.

Also, one failure case was missing a functional test, which I added here as well

Both RPCs should fail with RPC_INVALID_ADDRESS_OR_KEY when the txid is
not in the wallet. There are no current tests for this condition:

git grep -n -C2 "Invalid or non-wallet transaction id" -- test/functional | grep -i bump
Currently the fee bumping transactions use in/out params and a
`feebumper::Result` type to report error status. This is emulating
`util::Result` and `util::Expected`. There are also a few problems in
the current implementation:
1. There is an error vector passed to each method, but only one error
   can occupy it at any time.
2. In the case that a transaction cannot be marked as replaced, the
   error is actually treated as a warning and shown to the user.
3. The `INVALID_REQUEST` variant is not used.

This commit adds `util::Result` to creating and commiting fee bumped
transactions, which resolves these issues and also allows for adding
more fields to the successes. For instance, in the context
of silent payments, fee bumped transactions change the outputs of the
recipient and should be reported in the return type. The
`feebumper::Result` type is removed in favor of an error code and error
message.
@DrahtBot

DrahtBot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK Eunovo, Conradgabe
Concept ACK rkrux

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37055 (refactor: drop format calls on strings without arguments by fanquake)
  • #35302 (Silent Payments: Sending (take 2) by Eunovo)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • src/wallet/types.h: wanrings → warnings [misspelling]
  • src/wallet/types.h: comitting → committing [misspelling]

2026-11-30 09:02:16

@rustaceanrob rustaceanrob changed the title Refactor fee bumper expected wallet: Use util::Result for fee bumping methods Nov 30, 2026

@Eunovo Eunovo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 1f31ecd

self.log.info("Test outputs and original_change_index cannot both be provided")
assert_raises_rpc_error(-8, "The options 'outputs' and 'original_change_index' are incompatible. You can only either specify a new set of outputs, or designate a change output to be recycled.", rbf_node.bumpfee, rbfid, {"original_change_index": 2, "outputs": [{dest_address: 0.1}]})

self.log.info("Test that a txid not in the wallet cannot be bumped")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

699ca17:

Verified that this test fails if these lines

if (it == wallet.mapWallet.end()) {
errors.emplace_back(Untranslated("Invalid or non-wallet transaction id"));
return Result::INVALID_ADDRESS_OR_KEY;
}
are commented out.

@Conradgabe

Copy link
Copy Markdown
Contributor

tACK 1f31ecd

Confirmed wallet_bumpfee.py passes at 699ca17 and 1f31ecd, and feebumper_tests passes at the head, also tested bumpfee on regtest and it passed (both a successful bump and an unknown txid returning error -5)

@rkrux

rkrux commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Strong Concept ACK - this kind of code refactor (cleanup) is desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants