wallet/feebumper: reject an original_change_index output without a destination #36962

Open
Eunovo wants to merge 1 commit from refactor-fee-bumper into master AGit
Eunovo commented 2026-11-24 12:09:44 +00:00 (Migrated from github.com)

Moved from #35302 due to https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-7126751401.

This PR:
refactors CreateRateBumpTransaction to return a util::Expected of a Result and Error Struct instead of using out params. This change makes it easier for #35302 to add a sp_recipients field to the Result Struct instead of adding a new output parameter.

  • rejects an original_change_index that specifies an output without a destination. The pre-existing behaviour silently replaced the specified output if an OP_RETURN output was specified.

EDIT:
Scrapped the refactor of CreateRateBumpTransaction to return util::Expected in favour of https://github.com/bitcoin/bitcoin/pull/37017.

Moved from #35302 due to https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-7126751401. This PR: ~~refactors `CreateRateBumpTransaction` to return a `util::Expected` of a Result and Error Struct instead of using out params. This change makes it easier for #35302 to add a sp_recipients field to the Result Struct instead of adding a new output parameter.~~ - rejects an `original_change_index` that specifies an output without a destination. The pre-existing behaviour silently replaced the specified output if an `OP_RETURN` output was specified. EDIT: Scrapped the refactor of `CreateRateBumpTransaction` to return `util::Expected` in favour of https://github.com/bitcoin/bitcoin/pull/37017.
DrahtBot commented 2026-11-24 12:09:53 +00:00 (Migrated from github.com)

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 rustaceanrob
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:

  • #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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36962 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36962.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36962#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [rustaceanrob](https://github.com/bitcoin/bitcoin/pull/36962#pullrequestreview-6112322107) | | Concept ACK | [rkrux](https://github.com/bitcoin/bitcoin/pull/36962#issuecomment-7375564292) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#35302](https://github.com/bitcoin/bitcoin/pull/35302) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35302.svg"></sub> (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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

🔵 Suggestion · original_change_index help omits the new output restriction

The shared bumpfee and psbtbumpfee help promises reuse of the selected output script without mentioning that CNoDestination outputs now cause an invalid-parameter error.

Location: src/wallet/feebumper.cpp:199 (head).

🔵 Suggestion · The new guard's P2PK acceptance is untested

The original_change_index tests do not distinguish rejecting CNoDestination from rejecting every false ExtractDestination result, which would incorrectly reject valid P2PK change outputs.

Location: test/functional/wallet_bumpfee.py:298 (head).


Reviewed: b903c2bc9dcf · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:312ddb2095238aa2ca395a9cc39b05ab5a38a7177afbdb0d69098df9c3e0bef9:9a7f127b15c6116c267953d38288a9f17ec7c7bcd3a975fb71a2db8bfd974dbf --> <!-- ralph-base:afedb19cca4c3b40d89514fb0c66b0c20e4f5d62 --> <!-- ralph-head:b903c2bc9dcfa0b85605a19c1822026d01e69feb --> <!-- ralph-case:d9e6333c02053278ca0ae24abf638cc09d2e5e92ed6a5f51cc23590646d37eff --> **🔵 Suggestion · `original_change_index` help omits the new output restriction** The shared `bumpfee` and `psbtbumpfee` help promises reuse of the selected output script without mentioning that `CNoDestination` outputs now cause an invalid-parameter error. Location: [`src/wallet/feebumper.cpp:199`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b903c2bc9dcfa0b85605a19c1822026d01e69feb/src/wallet/feebumper.cpp#L199>) (head). **🔵 Suggestion · The new guard's P2PK acceptance is untested** The `original_change_index` tests do not distinguish rejecting `CNoDestination` from rejecting every false `ExtractDestination` result, which would incorrectly reject valid P2PK change outputs. Location: [`test/functional/wallet_bumpfee.py:298`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b903c2bc9dcfa0b85605a19c1822026d01e69feb/test/functional/wallet_bumpfee.py#L298>) (head). <!-- Review tier: sensitive --> --- Reviewed: [`b903c2bc9dcf`](<https://git.fish.foo/bitcoin/bitcoin/commit/b903c2bc9dcfa0b85605a19c1822026d01e69feb>) · [Review report](<https://review.fish.foo/report/36962-b903c2bc9dcfa0b85605a19c1822026d01e69feb-3330-4.html>) · [Previous reports](<https://review.fish.foo/traces/36962/>) [permalink](<https://review.fish.foo/report/36962-b903c2bc9dcfa0b85605a19c1822026d01e69feb-3330-4.html>)
rustaceanrob (Migrated from github.com) reviewed 2026-11-24 13:35:25 +00:00
rustaceanrob (Migrated from github.com) left a comment

Concept ACK

As I mentioned in https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-7126751401, this can replace an OP_RETURN which is posting a proof for a meta protocol or similar. I agree that this should throw an error explicitly as this a mistake on behalf of the user.

Concept ACK As I mentioned in https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-7126751401, this can replace an `OP_RETURN` which is posting a proof for a meta protocol or similar. I agree that this should throw an error explicitly as this a mistake on behalf of the user.
rustaceanrob (Migrated from github.com) commented 2026-11-24 13:22:29 +00:00

I think something like Change position refers to an output that cannot receive change (e.g. OP_RETURN) might be more user friendly in troubleshooting the issue.

I think something like `Change position refers to an output that cannot receive change (e.g. OP_RETURN)` might be more user friendly in troubleshooting the issue.
cyb3ralbert commented 2026-11-26 09:17:09 +00:00 (Migrated from github.com)

Could you also cover psbtbumpfee in the regression test?

I ran wallet_bumpfee.py on Linux arm64 at d03bccefa15587e40a4a482bad774f168863ad56, and it passed. In a local variant of the test, psbtbumpfee also rejected an attempt to designate an OP_RETURN output as change via original_change_index. With the new guard removed, the bumpfee regression assertion failed as expected.

Could you also cover `psbtbumpfee` in the regression test? I ran `wallet_bumpfee.py` on Linux arm64 at `d03bccefa15587e40a4a482bad774f168863ad56`, and it passed. In a local variant of the test, `psbtbumpfee` also rejected an attempt to designate an `OP_RETURN` output as change via `original_change_index`. With the new guard removed, the `bumpfee` regression assertion failed as expected.
Eunovo (Migrated from github.com) reviewed 2026-11-26 09:57:28 +00:00
Eunovo (Migrated from github.com) commented 2026-11-26 09:57:28 +00:00

Done.

Done.
Eunovo commented 2026-11-26 09:57:59 +00:00 (Migrated from github.com)

re: @cyb3ralbert

Could you also cover psbtbumpfee in the regression test?

Done.

re: @cyb3ralbert > Could you also cover `psbtbumpfee` in the regression test? Done.
rustaceanrob (Migrated from github.com) reviewed 2026-11-30 09:05:06 +00:00
rustaceanrob (Migrated from github.com) left a comment

See #37017 for an approach to remove feebumper::Result entirely

See #37017 for an approach to remove `feebumper::Result` entirely
rustaceanrob (Migrated from github.com) approved these changes 2026-11-30 12:40:02 +00:00
rustaceanrob (Migrated from github.com) left a comment
ACK b903c2bc9dcfa0b85605a19c1822026d01e69feb
rkrux commented 2026-12-03 10:39:27 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36962
No description provided.