transactions – When the validity of scriptPubKey is checked?

0
55


I’ve a few questions associated to validation of script in transaction output (scriptPubKey).

I apologize for somewhat extra textual content, however I attempted to elucidate intimately what I do not perceive.

Since all my confusion is expounded to the OP_RETURN opcode and OP_RETURN transaction, i.e. the next query and reply from Pieter Wuille all my questions are associated to the validation of the scriptPubKey that comprises this operator (OP_RETURN transaction), however I assume the identical is true for all different output scripts.

Let’s start.

Based mostly on what the Bitcoin wiki says that OP_RETURN marks the transaction as invalid and per Pieter’s remark:

Transaction output scripts are solely executed on the time they’re
tried to be spent.

My first query is:

1. If the transaction output scripts are solely executed on the time they’re tried to spent, does it imply that in scriptPubKey (transaction output script) we will write no matter we would like and its validity can be solely checked on the time of utilizing? I imply if OP_RETURN makes the transaction invalid, and the validation is realized when creating the scriptPubKey (output), then the script with the given code can by no means be a part of the blockchain

I believe the reply to first query is fake. The scriptPubKey is executed on the time its tried to spent however its validity is checked on the time of creation of transaction that has that script in its transaction output. It is like a compiling and executing C program. Compiling means checking for syntax and semantic errors, or in case of scriptPubKey verify, for instance, if all right opcodes are used, if script measurement is right, if it is likely one of the commonplace transaction (if any of the above isn’t glad, the transaction containing this UTXO can be marked as invalid and discarded from the community). Alternatively, executing a C program also can trigger this system to change into invalid, say when dividing by 0. And that is precisely as with scriptPubKey and it is executing (as Pieter mentioned) when trying to spend it. If on the time of execution the script is marked as invalid (say it stays FALSE on the stack or an OP_RETURN operator is encountered), then the transaction that consumes the UTXO (not the one comprises this UTXO) is marked as invalid. Subsequently, though validation is carried out when making a transaction output, OP_RETURN is a legitimate code that passes validation, however executing a script that comprises it invalidates the transaction. Since scriptPubKey is just executed when it’s consumed, that transaction can be marked as invalid, and never the one which created scriptPubKey.

2. Is the above written true? Is the validity of the transaction output checked when making the transaction, after which whereas utilizing the UTXO if one thing within the output script causes invalidity, the transaction that consumes that output can be marked as invalid?

Beneath is a query associated as to if I perceive validation accurately within the context of OP_RETURN.

When output containing [OP_RETURN] [DATA_PUSH] [data] is created, that UTXO can be efficiently validated (since every part in it’s OK) and acknowledged as commonplace OP_RETURN output that doesn’t change into a part of the UTXO set. If every part different in transaction is okay, transaction is legitimate. Nonetheless, if we have been to attempt to use this UTXO, the transaction that consumes the given output can be marked as invalid, as a result of it comprises OP_RETURN. Alternatively, if we add one thing further in entrance of OP_RETURN (some random opcode) in scriptPubKey, it won’t cross validation since it is not acknowledged as a regular transaction, so a transaction that has this output could be invalidated

3. Did I perceive accurately, that’s, was the above written accurately?

4. Does every part beforehand written about validation truly apply to all different forms of output (P2PK, P2PKH, P2WPKH, P2SH and so forth.). That’s, validating on creation after which doubtlessly marking an invalid transaction throughout execution (though with P2PKH this may solely occur by combining a locking and unlocking script the place the signature isn’t good, not like with an OP_RETURN transaction that UTXO itself marks an invalid transaction regardless to the unlock script)?

LEAVE A REPLY

Please enter your comment!
Please enter your name here