@@ -27,9 +27,9 @@ OP_CHECKTEMPLATEVERIFY does the following:
2727
2828* There is at least one element on the stack, fail otherwise
2929* The element on the stack is 32 bytes long, NOP otherwise
30- * The StandardTemplateHash of the transaction at the current input index is equal to the element on the stack, fail otherwise
30+ * The DefaultCheckTemplateVerifyHash of the transaction at the current input index is equal to the element on the stack, fail otherwise
3131
32- The StandardTemplateHash commits to the serialized version, locktime, scriptSigs hash (if any
32+ The DefaultCheckTemplateVerifyHash commits to the serialized version, locktime, scriptSigs hash (if any
3333non-null scriptSigs), number of inputs, sequences hash, number of outputs, outputs hash, and
3434currently executing input index.
3535
@@ -139,13 +139,13 @@ specification for the semantics of OP_CHECKTEMPLATEVERIFY.
139139 case OP_CHECKTEMPLATEVERIFY:
140140 {
141141 // if flags not enabled; treat as a NOP4
142- if (!(flags & SCRIPT_VERIFY_STANDARD_TEMPLATE )) break;
142+ if (!(flags & SCRIPT_VERIFY_DEFAULT_CHECK_TEMPLATE_VERIFY_HASH )) break;
143143 if (stack.size() < 1)
144144 return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
145145 // If the argument was not 32 bytes, treat as OP_NOP4:
146146 switch (stack.back().size()) {
147147 case 32:
148- if (!checker.CheckStandardTemplateHash (stack.back())) {
148+ if (!checker.CheckDefaultCheckTemplateVerifyHash (stack.back())) {
149149 return set_error(serror, SCRIPT_ERR_TEMPLATE_MISMATCH);
150150 }
151151 break;
@@ -161,17 +161,17 @@ specification for the semantics of OP_CHECKTEMPLATEVERIFY.
161161
162162The hash is computed as follows:
163163
164- uint256 GetStandardTemplateHash (const CTransaction& tx, uint32_t input_index) {
165- return GetStandardTemplateHash (tx, GetOutputsSHA256(tx), GetSequenceSHA256(tx), input_index);
164+ uint256 GetDefaultCheckTemplateVerifyHash (const CTransaction& tx, uint32_t input_index) {
165+ return GetDefaultCheckTemplateVerifyHash (tx, GetOutputsSHA256(tx), GetSequenceSHA256(tx), input_index);
166166 }
167- uint256 GetStandardTemplateHash (const CTransaction& tx, const uint256& outputs_hash, const uint256& sequences_hash,
167+ uint256 GetDefaultCheckTemplateVerifyHash (const CTransaction& tx, const uint256& outputs_hash, const uint256& sequences_hash,
168168 const uint32_t input_index) {
169169 bool skip_scriptSigs = std::find_if(tx.vin.begin(), tx.vin.end(),
170170 [](const CTxIn& c) { return c.scriptSig != CScript(); }) == tx.vin.end();
171- return skip_scriptSigs ? GetStandardTemplateHashEmptyScript (tx, outputs_hash, sequences_hash, input_index) :
172- GetStandardTemplateHashWithScript (tx, outputs_hash, sequences_hash, GetScriptSigsSHA256(tx), input_index);
171+ return skip_scriptSigs ? GetDefaultCheckTemplateVerifyHashEmptyScript (tx, outputs_hash, sequences_hash, input_index) :
172+ GetDefaultCheckTemplateVerifyHashWithScript (tx, outputs_hash, sequences_hash, GetScriptSigsSHA256(tx), input_index);
173173 }
174- uint256 GetStandardTemplateHashWithScript (const CTransaction& tx, const uint256& outputs_hash, const uint256& sequences_hash,
174+ uint256 GetDefaultCheckTemplateVerifyHashWithScript (const CTransaction& tx, const uint256& outputs_hash, const uint256& sequences_hash,
175175 const uint256& scriptSig_hash, const uint32_t input_index) {
176176 auto h = CHashWriter(SER_GETHASH, 0)
177177 << tx.nVersion
@@ -184,7 +184,7 @@ The hash is computed as follows:
184184 << input_index;
185185 return h.GetSHA256();
186186 }
187- uint256 GetStandardTemplateHashEmptyScript (const CTransaction& tx, const uint256& outputs_hash, const uint256& sequences_hash,
187+ uint256 GetDefaultCheckTemplateVerifyHashEmptyScript (const CTransaction& tx, const uint256& outputs_hash, const uint256& sequences_hash,
188188 const uint32_t input_index) {
189189 auto h = CHashWriter(SER_GETHASH, 0)
190190 << tx.nVersion
@@ -198,9 +198,9 @@ The hash is computed as follows:
198198 }
199199
200200
201- A PayToBasicStandardTemplate output matches the following template:
201+ A PayToBareDefaultCheckTemplateVerifyHash output matches the following template:
202202
203- bool CScript::IsPayToBasicStandardTemplate () const
203+ bool CScript::IsPayToBareDefaultCheckTemplateVerifyHash () const
204204 {
205205 // Extra-fast test for pay-to-basic-standard-template CScripts:
206206 return (this->size() == 34 &&
@@ -221,7 +221,8 @@ For the avoidance of unclarity, the parameters are:
221221 consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY].nStartTime = 1583020800; // March 1, 2020
222222 consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY].nTimeout = 1614556800; // March 1, 2021
223223
224- In order to facilitate using CHECKTEMPLATEVERIFY, the common case of a PayToBasicStandardTemplate
224+ In order to facilitate using CHECKTEMPLATEVERIFY, the common case of a
225+ PayToBareDefaultCheckTemplateVerifyHash
225226with no scriptSig data shall be made standard to permit relaying. Future template types may be
226227standardized later as policy changes.
227228
@@ -241,7 +242,7 @@ Below we'll discuss the rules one-by-one:
241242
242243
243244
244- ====The StandardTemplateHash of the transaction at the current input index matches the top of the stack ====
245+ ====The DefaultCheckTemplateVerifyHash of the transaction at the current input index matches the top of the stack ====
245246
246247The set of data committed to is a superset of data which can impact the TXID of the transaction,
247248other than the inputs. This ensures that for a given known input, the TXIDs can also be known ahead
@@ -272,13 +273,13 @@ spend, as long as the exact scriptsig for the legacy output is committed. This i
272273simply disallowing any scriptSig to be set with CHECKTEMPLATEVERIFY.
273274
274275If no scriptSigs are set in the transaction, there is no purpose in hashing the data or including it
275- in the StandardTemplateHash , so we elide it. It is expected to be common that no scriptSigs will be
276+ in the DefaultCheckTemplateVerifyHash , so we elide it. It is expected to be common that no scriptSigs will be
276277set as segwit mandates that the scriptSig must be empty (to avoid malleability).
277278
278279We commit to the hash rather than the values themselves as this is already
279280precomputed for each transaction to optimize SIGHASH_ALL signatures.
280281
281- Committing to the hash additionally makes it simpler to construct StandardTemplateHashes safely and unambiguously from
282+ Committing to the hash additionally makes it simpler to construct DefaultCheckTemplateVerifyHash safely and unambiguously from
282283script.
283284
284285
@@ -314,7 +315,7 @@ specific applications.
314315
315316In principal, committing to the Sequences Hash (below) implicitly commits to the number of inputs,
316317making this field strictly redundant. However, separately committing to this number makes it easier
317- to construct StandardTemplateHashes from script.
318+ to construct DefaultCheckTemplateVerifyHash from script.
318319
319320We treat the number of inputs as a `uint32_t` because signature checking code expects nIn to be an
320321`unsigned int`, even though in principal a transaction can encode more than a `uint32_t`'s worth of
@@ -329,14 +330,14 @@ with OP_CSV because OP_CSV enforces a minimum nSequence value, not a literal val
329330We commit to the hash rather than the values themselves as this is already
330331precomputed for each transaction to optimize SIGHASH_ALL signatures.
331332
332- Committing to the hash additionally makes it simpler to construct StandardTemplateHashes safely and unambiguously from
333+ Committing to the hash additionally makes it simpler to construct DefaultCheckTemplateVerifyHash safely and unambiguously from
333334script.
334335
335336=====Committing to the Number of Outputs =====
336337
337338In principal, committing to the Outputs Hash (below) implicitly commits to the number of outputs,
338339making this field strictly redundant. However, separately committing to this number makes it easier
339- to construct StandardTemplateHashes from script.
340+ to construct DefaultCheckTemplateVerifyHash from script.
340341
341342We treat the number of outputs as a `uint32_t` because a `COutpoint` index is a `uint32_t`, even
342343though in principal a transaction could encode more outputs.
@@ -349,7 +350,7 @@ requested.
349350We commit to the hash rather than the values themselves as this is already
350351precomputed for each transaction to optimize SIGHASH_ALL signatures.
351352
352- Committing to the hash additionally makes it simpler to construct StandardTemplateHashes safely and unambiguously from
353+ Committing to the hash additionally makes it simpler to construct DefaultCheckTemplateVerifyHash safely and unambiguously from
353354script.
354355
355356=====Committing to the current input's index =====
@@ -370,7 +371,8 @@ added to Bitcoin, the index may simply be passed in by the witness before hashin
370371
371372=====Committing to Values by Hash =====
372373
373- Committing to values by hash makes it easier and more efficient to construct a StandardTemplateHash
374+ Committing to values by hash makes it easier and more efficient to construct a
375+ DefaultCheckTemplateVerifyHash
374376from script. Fields which are not intended to be set may be committed to by hash without incurring
375377O(n) overhead to re-hash.
376378
@@ -528,7 +530,7 @@ for mining and block validation. Similar soft forks for OP_CHECKSEQUENCEVERIFY a
528530(see BIP-0065 and BIP-0112) have similarly changed OP_NOP semantics without introducing compatibility issues.
529531
530532Older wallet software will be able to accept spends from OP_CHECKTEMPLATEVERIFY outputs, but will
531- require an upgrade in order to treat PayToBasicStandardTemplate chains with a confirmed ancestor as
533+ require an upgrade in order to treat PayToBareDefaultCheckTemplateVerifyHash chains with a confirmed ancestor as
532534being "trusted" (i.e., eligible for spending before the transaction is confirmed).
533535
534536Backports of OP_CHECKTEMPLATEVERIFY can be trivially prepared (see the reference implementation)
0 commit comments