Difference between revisions of "Pushdata Opcodes"
(Added detail) |
|||
Line 7: | Line 7: | ||
0x08 <8 byte data item> - would leave the 8 byte data item on the stack. | 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 | 0x20 <32 byte data item> - would leave the 32 byte data item on the stack | ||
Line 14: | Line 15: | ||
Examples: | Examples: | ||
0x4C 0x64 <100 byte data item> - would leave the 100 byte data item on the stack | 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 | 0x4C 0xFF <255 byte data item> - would leave the 255 byte data item on the stack | ||
Line 20: | Line 22: | ||
Examples: | 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 === | === OP_PUSHDATA4 === | ||
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,295B onto the stack. | 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,295B 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 BitcoinScript limiting the size of individual data items in script to 4,294,967,295B. 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. | OP_PUSHDATA4 is the largest Pushdata opcode in BitcoinScript limiting the size of individual data items in script to 4,294,967,295B. 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. |
Revision as of 23:16, 13 January 2020
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
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
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
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
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,295B 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 BitcoinScript limiting the size of individual data items in script to 4,294,967,295B. 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.