比特币(BSV)知识库:脚本-Pushdata操作码(Pushdata Opcodes)

特别提示:

比特币(BSV)知识库-Bitcoin wiki-目前为全英文内容,暂无中文译文,并且仍在持续编写和补充中。欢迎中国的开发者在文章底部评论,进行阐述和探讨。

比特币(BSV)知识库:脚本-Pushdata操作码(Pushdata Opcodes)_第1张图片

Pushdata Opcodes

The Pushdata opcodes each use the value of the data item in the script to determine the length of the data item to push onto the stack.

Opcodes 1-75 (0x01 - 0x4B)

Opcodes 1-75 simply push their value of bytes of data onto the stack.

Examples:

0x08 <8 byte data item> - would leave the 8 byte data item on the stack.

0x20 <32 byte data item> - would leave the 32 byte data item on the stack

OP_PUSHDATA1 (76 or 0x4C)

OP_PUSHDATA1 takes the next 1 byte as the number of bytes to push onto the stack. It can be used to push data items of length from 1 to 255 bytes onto the stack, however is typically only used for data items over 75 bytes in size.

Examples: 0x4C 0x64 <100 byte data item> - would leave the 100 byte data item on the stack

0x4C 0xFF <255 byte data item> - would leave the 255 byte data item on the stack

OP_PUSHDATA2 (77 or 0x4D)

OP_PUSHDATA2 takes the next 2 bytes as the number of bytes to push onto the stack. It can be used to push data items of length from 256 to 65,535 bytes onto the stack.

Examples: 0x4D 0x0100 <256 byte data item> - would leave the 256 byte data item on the stack

0x4D 0xFFFF <65,535 byte data item> - would leave the 65,535 byte data item on the stack

OP_PUSHDATA4 (78 or 0x4E)

OP_PUSHDATA4 takes the next 4 bytes as the number of bytes to push onto the stack. It can be used to push data items of length from 65,536B up to ‭4,294,967,295‬B onto the stack.

Examples: 0x4E 0x00010000 <65,536 byte data item> - would leave the 65,536 byte data item on the stack

0x4E 0xFFFFFFFF <‭4,294,967,295‬ byte data item> - would leave the ‭4,294,967,295‬ byte data item on the stack


OP_PUSHDATA4 is the largest Pushdata opcode in Bitcoin script limiting the size of individual data items in script to ‭4,294,967,295‬B. Once data items are on the stack it is possible to use OP_CAT to join them together, creating larger items for purposes such as file hash verifications and more.

声明:

比特币(BSV)知识库项目由比特币协会(Bitcoin Association)发起并支持,更多信息请参见知识库官网:https://wiki.bitcoinsv.io/

你可能感兴趣的:(Bitcoin,wiki,区块链,比特币,BSV)