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

BSV知识库 专栏收录该内容
79 篇文章 3 订阅

特别提示:

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

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/


  • 对比特币区块链开发感兴趣的朋友可以通过CSDN站内私信联系我们,申请加入BSV开发者交流群。
  • 同时,您也可以扫描下方二维码,关注比特币协会官方微信公众号——BA资讯,了解更多区块链领域的实时资讯。

 

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值