You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flip argument order of Witness::combine for and_v and and_b
Given an `and` instruction, miniscript produces a witness stack that
is wrongly ordered:
The left branch of an `and` instruction is evaluated first, which means
whatever witness stack is produced by this branch needs to come _after_
the witness stack of the right branch.
Unfortunately, Witness::combine simply concatenates the two vectors,
resulting in the witness stack for the left branch to end up _before_ the
one for the right branch.
This is what we currently have:
Witness in memory:
|----A-----|----B-----|--and(A,B)--|
Witness stack evaluation:
Round 0:
Stack: Instructions:
check(A) check(B)
|----B-----|
|----A-----|
Round 1:
Stack: Instructions:
|----B-----| check(A) check(B)
|----A-----|
Round 2:
Failure due to wrong signature.
With this patch, this changes to what we actually want:
Witness in memory:
|----B-----|----A-----|--and(A,B)--|
Witness stack evaluation:
Round 0:
Stack: Instructions:
check(A) check(B)
|----A-----|
|----B-----|
Round 1:
Stack: Instructions:
|----A-----| check(A) check(B)
|----B-----|
Round 2:
Stack: Instructions:
check(B)
|----B-----|
Round 3:
Stack: Instructions:
|----B-----| check(B)
Round 4:
Script successfully executed!
Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
let sig_a = secp256k1::Signature::from_str("3045022100a7acc3719e9559a59d60d7b2837f9842df30e7edcd754e63227e6168cec72c5d022066c2feba4671c3d99ea75d9976b4da6c86968dbf3bab47b1061e7a1966b1778c").unwrap();
let sig_b = secp256k1::Signature::from_str("3044022075b7b65a7e6cd386132c5883c9db15f9a849a0f32bc680e9986398879a57c276022056d94d12255a4424f51c700ac75122cb354895c9f2f88f0cbb47ba05c9c589ba").unwrap();
966
+
967
+
let descriptor = Descriptor::<bitcoin::PublicKey>::from_str(&format!(
0 commit comments