hash160/ripemd160: concrete hash missing in output script
At https://bitcoin.sipa.be/miniscript/, if I enter this miniscript:
sha256(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
I receive the expected script structure:
OP_SIZE <20> OP_EQUALVERIFY OP_SHA256
<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> OP_EQUAL
For hash160/ripemd160 however, the hash is missing in the script. For example:
hash160(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) results in:
OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 OP_EQUAL
(<a....> is missing before OP_EQUAL).
using hash160(H) correctly outputs:
OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 <h> OP_EQUAL
I also just noticed this inconsistency:
In the translation table for the hash functions, the Bitcoin Script uses decimal <32>:
SIZE <32> EQUALVERIFY SHA256 <h> EQUAL
While the script structure compilation output prints it in hex <20>:
OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 <h> OP_EQUAL
Did a double-take there - would be good to make this consistent and document which format is used for clarity (or maybe use the 0x prefix for hex values).
There's also a subtle ~typo.
hash160(H) & ripemd160(H) (using upper case H as a variable) ends up producing ASM with <h> (lower case h).
Keeping case sensitive would also be nice.
sha256 and hash256 work as expected.
BTW: I'd rather keep the notation <20>, where 20 is in fact 0x20 when enclosed within angle quotation marks.