If I only have a single script for the script path does the hash of the script get placed at the top of the Merkle tree (instead of the effective Merkle root) or does it get placed in level 1 of the Merkle tree and get hashed up to the Merkle root with another arbitrary hash?
1 Answer
You can do either. Putting the hash of the single script (hash_TapLeaf
) instead of the Merkle root makes it cheaper to spend as you don't need to reveal other hashes to prove that script is present in the Merkle tree. However, if you want to obscure the fact that there was only a single script path in the Merkle tree on spending (and are willing to pay a higher transaction fee on spending) you may include it on a branch at level 1 (or even a higher level) of the Merkle tree. To use hash_TapBranch
you need at least two branches and so you need to place arbitrary hash(es) on whatever branch(es) you aren't using.
Thanks to Russell O'Connor for answering this on IRC.