Skip to content

Thresh bug with equal verify #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/miniscript/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ pub fn parse<Ctx: ScriptContext>(
))?
},
),
Tk::Num(k) => {
non_term.push(NonTerm::Verify);
non_term.push(NonTerm::ThreshW {
k: k as usize,
n: 0
});
},
),
x => {
tokens.un_next(x);
Expand Down
6 changes: 6 additions & 0 deletions src/miniscript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,12 @@ mod tests {
OP_PUSHNUM_1\
)"
);

// Thresh bug with equal verify roundtrip
roundtrip(
&ms_str!("tv:thresh(1,pk(02d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e))", ),
"Script(OP_PUSHBYTES_33 02d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e OP_CHECKSIG OP_PUSHNUM_1 OP_EQUALVERIFY OP_PUSHNUM_1)",
);
Comment on lines +879 to +882
Copy link
Contributor

@darosior darosior Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to only be able to reproduce it with a single subpolicy, which is not a valid Miniscript (see #242 ). EDIT: not the case anymore.

Also, a broader Miniscript question: why isn't the Script here 1 <pk> CHECKSIG ADD 1 EQUALVERIFY 1 (as i would have expected of a thresh wrapped in a v, wrapped in a and_v(X, 1)) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have been away for a while. Will catch up with all the miniscript stuff this week.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and_or is a ternary fragment(3 args) and this is binary fragment(2 args). Why should we have and_or here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i meant and_v. Editing now.

Copy link
Contributor

@darosior darosior Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And i think i answered the question myself, ADD is only appended if k > 1. Sorry for the noise :)

}

#[test]
Expand Down