Comparability of hashed fields
In comparison with CTV, TEMPLATEHASH drops nInputs, nOutputsand scriptSigs;
and provides the taproot annex presence flag and taproot annex.
In comparison with SIGHASH_ANYSCRIPTANYPREVOUT|ALL, TEMPLATEHASH drops
hash_type, this sequence, key_versionand codesep_pos; and provides all sequences.
This places TEMPLATEHASH in a reasonably snug center floor between
CTV’s hash and ANYSCRIPTANYPREVOUT’s. It not directly commits to the
variety of inputs through sequences, is able to creating secure txids with
1 enter, and makes no concession to setting up the hash on the stack
nor to legacy script.
Capabilities
All protocols which can be potential with CTV are potential with TEMPLATEHASH.
By committing to the taproot annexit does get rid of sure perverse methods of implementing annex extensions, however not any protocol software that may use the annex. I.e. as soon as now we have an opcode that’s
anticipated for use in pre-committed transaction scripts within the wild, we
can not make a consensus rule that requires all taproot spends to have a
non-empty annex, however we will obtain the identical functionality in one other method.
Effectivity
Typically protocols utilizing TEMPLATEHASH shall be akin to or extra environment friendly than the identical utilizing CTV (or APO). It’s because TEMPLATEHASH can be utilized with an equality verify or a signature verify with out taking a penalty for a wasted hash or a wasted signature within the reverse case. Concretely, I imagine this makes TEMPLATEHASH+CSFS+IKEY 32WU extra environment friendly than LNHANCE(CTV+CSFS+IKEY+PAIRCOMMIT) for Lightning Symmetry pressure closure.
For protocols that might have used naked CTV, TEMPLATEHASH is 69WU much less
environment friendly, however as of this writing the one protocol that’s identified to
reap the benefits of naked CTV is congestion management bushes. I’m not conscious
of any concrete proposal to implement these.
Compatibility
As a result of TEMPLATEHASH just isn’t accessible in legacy bitcoin script or SegWit v0 scripts, it is just suitable with Taproot wallets. This would possibly make it more durable for customers of legacy signing infrastucture comparable to HSMs to undertake, however these identical gadgets might need issue signing scripts utilizing new opcodes even when they had been legacy scripts.

