Skip to content

rest: fix unreachable provably-unspendable script classification - #246

Open
zloglevel wants to merge 1 commit into
Blockstream:new-indexfrom
zloglevel:fix/provably-unspendable
Open

rest: fix unreachable provably-unspendable script classification#246
zloglevel wants to merge 1 commit into
Blockstream:new-indexfrom
zloglevel:fix/provably-unspendable

Conversation

@zloglevel

Copy link
Copy Markdown

Summary

Fix REST output script classification for provably unspendable scripts.

The existing classification contained two identical is_op_return() branches.

The second branch was unreachable, causing non-OP_RETURN provably unspendable scripts to be reported as unknown.

Changes

  • Replace the unreachable duplicate is_op_return() check with is_provably_unspendable().
  • Preserve the dedicated op_return classification by checking it first.
  • Add regression coverage for:
    • OP_RETURN scripts
    • non-OP_RETURN provably unspendable scripts
    • unknown but potentially spendable scripts
  • Cover both Bitcoin and Liquid builds.

Verification

  • cargo +1.92.0 check --lib
  • cargo +1.92.0 check --lib --features liquid

Signed-off-by: zloglevel <loglevel@outlook.com>
@EddieHouston

EddieHouston commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Thank for your submission. The duplicated is_op_return() branch is clearly unreachable, and this restores the original REST distinction between op_return and other provably-unspendable scripts. (changed with e497577)

Could we avoid introducing a new call to the deprecated bitcoin::Script::is_provably_unspendable() and suppressing it with #[allow(deprecated)]?

The same compatibility issue was handled in mempool/electrs#138 (mempool/electrs#138), specifically in commit f8302d7c (mempool/electrs@f8302d7). It defines a small feature-specific IsProvablyUnspendable helper: the Bitcoin implementation preserves the existing ReturnOp | IllegalOp behavior, while the Liquid implementation delegates to elements::Script::is_provably_unspendable().

Using the same approach here would preserve the intended API behavior without depending on a method that rust-bitcoin plans to remove.

It would also be good to run the new unit test under both the default and liquid configurations rather than only cargo check.

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.

2 participants