Can OP_CHECKDATASIGVERIFY be used to write a Quine?

Script:

OP_OVER OP_TOALTSTACK <pubkey> OP_DUP OP_TOALTSTACK OP_CHECKDATASIGVERIFY OP_FROMALTSTACK OP_FROMALTSTACK OP_SWAP OP_CHECKSIG

Stack:

<sig> <msg>
<sig> <msg> <sig>
<sig> <msg>
<sig> <msg> <pubkey>
<sig> <msg> <pubkey> <pubkey>
<sig> <msg> <pubkey>
(empty)
<pubkey>
<pubkey> <sig>
<sig> <pubkey>
1

The only missing part is checking if <msg> is a valid transaction with correct outputs. We can ensure that the output script is exactly the same, then it will form a Quine! Did I miss something, or is it possible? Now I am trying to test that.

Yes, OP_CHECKDATASIGVERIFY was the upgrade that first enabled covenants, contracts that require that the spender creates outputs according to the contract’s specification.

Introspection upgrade made it much easier to require that exact same bytecode is copied over to the output, you can now just use: OP_OUTPUTBYTECODE OP_INPUTINDEX OP_UTXOBYTECODE OP_EQUAL

The unlocking script then just needs to push a number (output index) to tell the locking script which output to look at.

Here’s an example that places requirements on 2 outputs: Happy Bitcoin Cash May-2022 upgrade! Follow up on the 2.5 BCH giveaway (or how I outsourced making history) : btc

1 Like