-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The halving block has some transactions that inscribe an ordinal and etch a rune.
Inscription 70279625
- https://ordpool.space/tx/1b37f19c0a50b7e90fba7b317a30b56ef8d3494684d7530eb6efec567ebdb32f
- https://ordinals.com/inscription/1b37f19c0a50b7e90fba7b317a30b56ef8d3494684d7530eb6efec567ebdb32fi0
Inscription 70279628
- https://ordpool.space/tx/7923e59abd8f8ab40dcc7915ae864d8b7ad6776811ba4d478f42248a7827a7f3
- https://ordinals.com/inscription/7923e59abd8f8ab40dcc7915ae864d8b7ad6776811ba4d478f42248a7827a7f3i0
The pushdata of these txns revealed a bug:
OP_PUSHBYTES_1 02
OP_0
Both inscriptions right now throw an exception, because the parser cant read the data for tag 2.
This is caused because my code for readPushdata does not handle OP_0 at all.
ordpool-parser/src/lib/reader.ts
Lines 26 to 63 in ce04d7a
| export function readPushdata(raw: Uint8Array, pointer: number): [Uint8Array, number] { | |
| let [opcodeSlice, newPointer] = readBytes(raw, pointer, 1); | |
| const opcode = opcodeSlice[0]; | |
| // Handle the special case of OP_1NEGATE (-1) | |
| if (opcode === OP_1NEGATE) { | |
| // OP_1NEGATE pushes the value -1 onto the stack, represented as 0x81 in Bitcoin Script | |
| return [new Uint8Array([0x81]), newPointer]; | |
| } | |
| // Handle minimal push numbers OP_PUSHNUM_1 (0x51) to OP_PUSHNUM_16 (0x60) | |
| // which are used to push the values 0x01 (decimal 1) through 0x10 (decimal 16) onto the stack. | |
| // To get the value, we can subtract OP_RESERVED (0x50) from the opcode to get the value to be pushed. | |
| if (opcode >= OP_PUSHNUM_1 && opcode <= OP_PUSHNUM_16) { | |
| // Convert opcode to corresponding byte value | |
| const byteValue = opcode - OP_RESERVED; | |
| return [Uint8Array.from([byteValue]), newPointer]; | |
| } | |
| // Handle direct push of 1 to 75 bytes (OP_PUSHBYTES_1 to OP_PUSHBYTES_75) | |
| if (1 <= opcode && opcode <= 75) { | |
| return readBytes(raw, newPointer, opcode); | |
| } | |
| let numBytes: number; | |
| switch (opcode) { | |
| case OP_PUSHDATA1: numBytes = 1; break; | |
| case OP_PUSHDATA2: numBytes = 2; break; | |
| case OP_PUSHDATA4: numBytes = 4; break; | |
| default: | |
| throw new Error(`Invalid push opcode ${ opcode } at position ${pointer}`); | |
| } | |
| let [dataSizeArray, nextPointer] = readBytes(raw, newPointer, numBytes); | |
| let dataSize = littleEndianBytesToNumber(dataSizeArray); | |
| return readBytes(raw, nextPointer, dataSize); | |
| } |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working