diybitcoinhardware / embit

A minimal bitcoin library for MicroPython and Python3 with a focus on embedded systems
https://embit.rocks
MIT License
85 stars 29 forks source link

`0` and `1` are valid miniscript fragments #57

Open bigspider opened 7 months ago

bigspider commented 7 months ago

It appears that the 0 and 1 fragments are not supported. However they are valid in miniscripts, and they are occasionally produced by the policy compilers.

Some examples of valid descriptors that fail to parse:

wsh(and_b(pk(tpubDDcmHJ6bsQqSRDzXrF1cgyPfXpFTHmqBUcq5cevfszh83XJtjqXZXDYwP3N82bA51dBVhbe3uaaWwAxW2tEsjgZPXmupQpNwdmULXq1WXDU/0/*),a:or_d(pk(tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK/0/*),0)))

wsh(and_b(pk(tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK/0/*),a:1))

wsh(and_b(pk(tpubDDcmHJ6bsQqSRDzXrF1cgyPfXpFTHmqBUcq5cevfszh83XJtjqXZXDYwP3N82bA51dBVhbe3uaaWwAxW2tEsjgZPXmupQpNwdmULXq1WXDU/0/*),a:and_b(1,s:pk(tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK/0/*))))```

(sorry for the very not minimal examples, they came out from my test suite)

bigspider commented 7 months ago

I added the two fragments with this commit in my clone of embit.