3
I am currently looking into the Bitcoin script. I want to create a transaction with one output with OP_RETURN and some data, and one output which pays coins to some address. I am confused, does OP_RETURN mark the whole transaction as invalid or just the output.
I am especially confused because the wiki is not clear on this issue: https://en.bitcoin.it/wiki/Script#Flow_control (says the whole transaction is marked as invalid) https://en.bitcoin.it/wiki/OP_RETURN (says just the output is marked as invalid)
But doesn't that actually mean only the information in the second link is correct? If I have a transaction with 2 outputs. One with a OP_RETURN and one with the standard paytopubhash script. I can still use the second output as an input for another transaction? – Martin – 2016-10-29T12:28:09.617
Yes, you can spend the second output (if it's a standard pay-to-pubkey-hash script) by signing the spending transaction with the corresponding private key. The OP_RETURN one is permanently unspendable, so it is a good idea to send zero satoshis there. See this transaction https://blockchain.info/tx/8bae12b5f4c088d940733dcd1455efc6a3a69cf9340e17a981286d3778615684?show_adv=true which is your exact use case. Notice the non-OP_RETURN output is marked spent, proving it's allowed.
– maservant – 2016-10-29T14:22:41.690Both links are correct. But the first one is about a transaction that spends an OP_RETURN. The second one is about an output that creates an OP_RETURN. – Pieter Wuille – 2016-10-29T17:45:43.917