Skip to content

fix(tbtcpg): price P2TR redeemer output scripts - #4244

Open
piotr-roslaniec wants to merge 1 commit into
split/bitcoin-p2tr-layerfrom
fix/tbtcpg-p2tr-redeemer
Open

fix(tbtcpg): price P2TR redeemer output scripts#4244
piotr-roslaniec wants to merge 1 commit into
split/bitcoin-p2tr-layerfrom
fix/tbtcpg-p2tr-redeemer

Conversation

@piotr-roslaniec

Copy link
Copy Markdown
Collaborator

Stacked on #4243, which supplies the P2TRScript handling in
pkg/bitcoin/estimator.go this needs. Retarget to main once #4243 lands.

The bug

EstimateRedemptionFee's redeemer-script switch has no P2TR arm, so a P2TR
redeemer output script falls through to the non-standard default and returns
an error. That error aborts the estimate for the entire batch, so one P2TR
request stalls every pending redemption for that wallet, not just its own.

The Bridge accepts P2TR redeemer addresses -- Redemption.sol validates
against a set that includes them -- so this is reachable as soon as any
redeemer supplies one.

This switch is byte-identical on main, so the gap predates the FROST work and
is not introduced by #3866.

The fix

Add the arm using AddOutputScript. An output costs its script length plus a
fixed header, and the real script is already in hand, so there is no need for a
canonical placeholder the way the P2PKH and P2SH arms use one.

The default arm still rejects genuinely non-standard scripts, and now names
the type it rejected -- previously the error gave an operator no way to identify
the offending request.

Testing

Two new tests: a batch containing a P2TR redeemer must be priced and must cost
strictly more than the same batch without it (an equal fee would mean the script
was silently dropped and every redemption in the batch underpaid), and an
OP_RETURN script must still be rejected with its type named.

Verified the first test fails without the fix:

a P2TR redeemer script must be priced, not rejected:
non-standard redeemer output script type [P2TR]

The redeemer-script switch in EstimateRedemptionFee has no P2TR arm, so a
P2TR redeemer output script falls through to the non-standard default and
returns an error. That aborts the fee estimate for the whole batch, so one
P2TR request stalls every pending redemption for that wallet rather than
only its own.

The Bridge accepts P2TR redeemer addresses (Redemption.sol validates
against a set that includes them), so this is reachable as soon as a
redeemer supplies one.

Price it with AddOutputScript rather than a dedicated helper: an output
costs its script length plus a fixed header, and the real script is
already in hand, so no canonical placeholder is needed. The default arm
still rejects genuinely non-standard scripts and now names the type it
rejected.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 70cc8dc0-d4b7-403f-8e0c-e578eb44aada

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant