rest: fix unreachable provably-unspendable script classification - #246
rest: fix unreachable provably-unspendable script classification#246zloglevel wants to merge 1 commit into
Conversation
|
@zloglevel 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. |
Signed-off-by: zloglevel <loglevel@outlook.com>
1dccac3 to
726e91c
Compare
Thanks for the review. @EddieHouston I updated the implementation to follow the compatibility approach from mempool/electrs#138. The REST classification now uses a feature-specific The Bitcoin implementation preserves the existing I also kept the regression test covering OP_RETURN, provably unspendable, and unknown scripts. Both Bitcoin and Liquid library builds pass with |
Thanks, we will take a look at it again. For the macos issue... we plan to resolve this in the repo soon... in the short term you can do this (or add it to your AGENTS.md or CLAUDE.md): Also see #224 |
|
@zloglevel Thanks for the update. I reviewed the latest commit, 726e91c (726e91c). The feature-specific IsProvablyUnspendable helper addresses the deprecation concern and preserves the intended behavior: Bitcoin retains the existing ReturnOp | IllegalOp classification, while Liquid delegates to elements::Script::is_provably_unspendable(). Keeping the dedicated op_return check first also preserves the REST API distinction. I ran the focused regression test successfully under both configurations: cargo test --lib test_script_type_unspendable_classification Both passed using the temporary macOS electrumd patch described above. No further issues from my side. Thanks! |
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
is_op_return()check withis_provably_unspendable().op_returnclassification by checking it first.Verification
cargo +1.92.0 check --libcargo +1.92.0 check --lib --features liquid