A 3-of-3 that turns into a 2-of-3 after 90 days #341
-
I had a doubt about the bitcoin script encoded from the miniscript of the above mentioned spending policy. The below is output generated by the current policy compiler.
Why do we need the last OP_ADD ? I assume the stack state before running this script to be as follows (the first element is on top of the stack)
at this point, I also don't understand what this some_number should be. Does it act like true-false, or is the sequence number of the transaction? If it is not true or false, the last OP_ADD operation looks invalid to me. I referred this BIP which explains the working for CSV. Also, I assumed that the successful execution of CSV will act as a NOP (as mentioned in the above BIP). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@kanishk779 this is a pretty cool construction. It took me a bit to reverse-engineer what Miniscript is doing here but it is correct: First, we have this After several of these we have the construction The final |
Beta Was this translation helpful? Give feedback.
-
By the way -- thank you very much for filing this issue. In studying your script I found a serious security issue in Miniscript (see #360 for more info) which we were able to fix over the last 24 hours. |
Beta Was this translation helpful? Give feedback.
@kanishk779 this is a pretty cool construction. It took me a bit to reverse-engineer what Miniscript is doing here but it is correct:
First, we have this
CHECKSIG ADD SWAP
idiom, which takes an accumulator, adds the result ofCHECKSIG
(which will be 0 if the signature failed or 1 if it passed), and then moves it one space back in the stack to make room for the next signature. After each of these, the second-to-top stack element will contain a count of how many signatures have passed, and the top stack element will be a witness for the next check.After several of these we have the construction
DUP IF <timelock check> ENDIF
. This takes as witness either a 0 or 1. If it's a 0 the whole bloc…