Do OP_RETURN messages persist on the blockchain?

3

1

I've been doing a lot of reading on OP_RETURN, and I want to understand something that still seems unclear. When we create a transaction with OP_RETURN (which I understand will not eternally pollute node's RAM as the transaction is not put into the UTXO database), is the OP_RETURN data replicated across the blockchain?

This answer from a related question here (Blockchain transaction message length limit) states that the OP_RETURN is not part of the Bitcoin protocol, and the OP_RETURN data can only be accessed using blockchain.info, which doesn't make sense from what I've read, as the code to standardize the number of bytes for OP_RETURN messages is directly within the Bitcoin source-code, and therefore is part of the protocol, right?

TL;DR: I'm trying to make an application which utilizes OP_RETURN, and I would like to know if the OP_RETURN data exists on the blockchain forever, and can be retrieved using APIs other than blockchain.info. Thanks everyone

delos

Posted 2016-12-12T02:13:06.083

Reputation: 133

Answers

2

Yes, the OP_RETURN output is part of the blockchain forever.

This is easy to show: the OP_RETURN and the message that follows is part of the transaction's output set, therefore changing the message changes the transaction ID, which in turn will change the hash of the block. If the message were to be deleted after a certain time, then new nodes on the network would fail to sync as they would not be able to validate that block. Therefore all full nodes will retain your message forever (as you mentioned, not in RAM, but buried deep in a file on your hard drive).

As for actually accessing the data, apart from the Blockchain.info API, I guess you could run a Toshi node locally (on your own hardware). Since it uses PostgreSQL, you can just query the blockchain as you would any database. This way, you don't depend on any external API that could turn evil or shut down. The hard drive requirements, however, are enormous (even worse than a Bitcoin Core full node).

maservant

Posted 2016-12-12T02:13:06.083

Reputation: 891

1Thanks for the answer, that clears things up a lot. As for Toshi, that's a really interesting project, definitely going to look into it. It says that the Toshi service will be retired in a few days, and it looks like the API has a lot of bugs. Do you know of any similar self-hosted projects that allow the blockchain it to be queried in some way?delos 2016-12-12T05:22:06.997