rust-bitcoin / rust-bitcoin/rust-miniscript

thresh(N, n subs) is not optimized to And() if N == 1

Open
#237 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
426
Forks
200
Avg merge
7d 17h
Merged PRs (30d)
8

Description

thresh(1, pk) will be compiled to pk OP_CHECKSIG 1 OP_EQUAL. It seems strange at first sight but i believe it'd actually make us panic:
https://github.com/rust-bitcoin/rust-miniscript/blob/42367cf75b0db6c82cabd1343613a5457404aa07/src/policy/compiler.rs#L1003

So maybe it was on purpose (i can't recall, though i introduced this code). Will take a look soon ™️
[self-assignment]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect src/policy/compiler.rs around line 1003 and trace how thresh(1, pk) is compiled. Confirm whether the generated script can panic and determine the intended handling for this case. Done means the behavior is understood and the issue's safety or optimization concern has a decided resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.