[41]OP_RETURN参数阅读记录

opreturn参数的发展历史和未来展望

https://bitzuma.com/posts/op-return-and-the-future-of-bitcoin/
描述了opreturn参数的发展历史和未来展望

Validation scripts offer an obvious method for encoding application-specific data, but other techniques have been used. For example,?one scheme?stored data by writing it into two payment addresses.
历史上曾经有提议,将数据存储在地址中

A more serious concern stems from the need to keep application-specific data within the unspent transaction output (UTXO) set. The UTXO set contains references to all spendable coins, and so should be kept small to ensure fast transaction validation. Embedding application data into addresses or challenge scripts forces each full node to add a reference to the UTXO set.
UTXO数据集需要尽量小,以便提高交易验证效率。
将数据内嵌在地址或脚本中,将使得所有全节点维护的UTXO数据集中增加引用数量。
这句话的核心是,将数据存储在地址和签名中的行为,有可能使这笔交易成为不可执行的交易,即永久性增加UTXO的数据,这将对整个系统的验证效率产生潜在威胁。

比特币脚本介绍 1

https://davidederosa.com/basic-blockchain-programming/scripts-in-transaction-processing/
介绍比特币的脚本

Although stored in the block chain,?OP_RETURN?bytes are excluded from the UTXO set, conserving a scarce resource. As a side effect, an output using an?OP_RETURN?challenge script becomes unspendable. For this reason, the value of an?OP_RETURN?output is usually set to 0.

UTXO (unspent transaction output)数据集被矿工维护,以便能够快速验证交易合法性,防止双花现象。
OP_RETURN不属于UTXO数据集。
OP_RETURN脚本存储在一个output中,金额为0。

However, a 40 byte sequence more than suffices to encode an identifier such as a hash value. This value can uniquely represent any digital document, from an image, to a poem, to an abstract data structure. Embedded hash values in turn offer a method to link the block chain to other data stores such as?distributed hash tables.
40字节足够存储1个哈希值。这个哈希值可以唯一代表任意一个数字文件,从图片到文字到数据结构。
内嵌的哈希值可以将区块链连接到任意存储文件。

The Bitcoin Core 0.9.0 release notes?attempted to clarify the purpose of?OP_RETURN:

0.9.0版本正式定义了op_return参数

比特币脚本介绍 2

https://bitzuma.com/posts/op-return-and-the-future-of-bitcoin/
这篇文章介绍op_return很详细。

比特币脚本介绍 3

https://bitcoin.org/en/release/v0.12.0#relay-any-sequence-of-pushdatas-in-opreturn-outputs-now-allowed

Relay: Any sequence of pushdatas in OP_RETURN outputs now allowed
Previously OP_RETURN outputs with a payload were only relayed and mined if they had a single pushdata. This restriction has been lifted to allow any combination of data pushes and numeric constant opcodes (OP_1 to OP_16) after the OP_RETURN. The limit on OP_RETURN output size is now applied to the entire serialized scriptPubKey, 83 bytes by default. (the previous 80 byte default plus three bytes overhead)

  • 默认长度是83字节
  • 比特币协议V0.12.0,去除了长度限制,目前op_return长度的上限是scriptPubKey的长度限制?

比特币op_return格式说明

长度上限83B,前3个字节为固定参数(前2个字节为标志,第3个字节存储),后面的为自定义内容。
固定格式:

  • 6a 4c 50/ff xxxx
  • “6a 4c”是固定标注,
  • 第3个字节存储自定义内容的长度
  • 50是16进制,代表十进制80,表示自定义内容的长度是80
  • op_return自定义内容的长度是由用户自行定义,根据“op_return数据统计网站-长度统计”,长度为20和80 的比例最高
  • 可疑的情况是,在testnet中,第3个字节可以设置为ff,代表十进制255,实验测试可以存储超过80 的数据。
  • [op_return数据统计网站-长度统计]https://opreturn.org/op-return-sizes/
  • [长度为255的交易testnet]https://live.blockcypher.com/btc-testnet/tx/1da4803e97df8aa21f117eab735b76111537c5a04db6549b627ddbfd6561f2f1/#

op_return自定义内容的特征

  • 前3个字节有一定规律,有“op_return数据统计网站-protocls”专门统计分类情况。有两类情况占主要比例。
  • [op_return数据统计网站-protocls]https://opreturn.org/op-return-protocols/

op_return参数在输出脚本中的比例

  • 从“op_return数据统计网站-脚本比例”上的数据,可以看出op_return的比例远小于1%,与我原来印象10%,差距巨大。需要调研此问题。
  • [op_return数据统计网站-脚本比例]https://btc.com/stats/script?time_range=all&latest_block=620227&static_type=amount_stats

比特币op_return参数数据统计网站1

http://coinsecrets.org/
这个网站专门记录比特币op_return参数中存储的数据。
http://api.coinsecrets.org/block/353197?where?353197?is a bitcoin block number.
这个网站提供的API参数可以查看每个区块中存储的opreturn数据。

比特币op_return参数数据统计网站2

https://opreturn.org/
此网站提供8种数据,包括每月数据,协议,大小,脚本类型、隔离见证等,值得深入研究。


-更新时间:20200305
-更新内容:补充了统计网站,介绍3等内容,完善格式。
-下一步要补充op_return参数在各次协议升级中的变化

-更新时间:20190807
-更新内容:原始文章