Skip to content

Add BIP-110 compatible envelope parser#4545

Open
lifofifoX wants to merge 1 commit into
ordinals:masterfrom
lifofifoX:bip110-envelope
Open

Add BIP-110 compatible envelope parser#4545
lifofifoX wants to merge 1 commit into
ordinals:masterfrom
lifofifoX:bip110-envelope

Conversation

@lifofifoX

@lifofifoX lifofifoX commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

BIP-110 disables OP_IF and OP_NOTIF in tapscript and limits data pushes to 256 bytes.

This PR adds an alternative inscription envelope: a bare protocol push followed by a series of data pushes, which are then dropped with OP_DROP and OP_2DROP.

@casey

casey commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me! Let's wait until BIP-110 activates to merge this.

BIP-110 forbids executing OP_IF and OP_NOTIF in tapscript and limits
data pushes to 256 bytes, which rules out the OP_FALSE OP_IF envelope.
Recognize an alternative envelope: a bare protocol push followed by
data pushes balanced by OP_DROP and OP_2DROP. The envelope is complete
when every element it pushed, including the protocol push, has been
dropped.

Pushnum opcodes parse in both envelope formats via a shared table; in
a BIP-110 envelope a pushnum pushes a real stack element, so it counts
toward the envelope stack and must be dropped like any other push.
@cbspears

cbspears commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

ACK

@decentralizd

Copy link
Copy Markdown

cheekyb approves
image - 2026-06-24T231130 433

@thewrlck

thewrlck commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Luke is crying 😭

hans-crypto added a commit to ordpool-space/ordpool-parser that referenced this pull request Jul 4, 2026
Follow-up simplify pass. The two envelope shapes (classic +
BIP-110 per ordinals/ord#4545) share the same "ord" push; the
prior version treated them as two peers and doubled almost every
step. Collapsed:

  hex marker (2 -> 1)
    INSCRIPTION_MARK_HEX = '036f7264' -- the 4-byte "ord" push
    that both shapes carry. A classic envelope is any occurrence
    preceded by OP_FALSE OP_IF; anything else is BIP-110.

  scanner (2 -> 1)
    getNextInscriptionMark(raw, start) now returns
    { pointer, isClassic } | null. getNextBip110InscriptionMark
    is gone.

  parse loop (2 while-loops over raw -> 1)
    parseInscriptionsWithinWitness walks the witness once.

  extractor (2 methods, 2 envelope-size formulas -> 1)
    extractInscriptionData(raw, pointer, isClassic) reads fields
    + body inline; the terminator is OP_ENDIF for classic and a
    balanced OP_DROP / OP_2DROP sequence for BIP-110. Envelope
    size is a single subtraction; no +7 / -4 fudge factors.

  hasInscription single .includes() on the shared marker (both
    shapes contain it as a substring).

  spec + testdata trimmed: one assertion, stripped-down
  Esplora-shape fixture.

Net PR delta: 288 -> ~72 insertions. All existing tests updated
for the new getNextInscriptionMark return type. 1033/1033 green
in node and browser realms.
hans-crypto added a commit to ordpool-space/ordpool-parser that referenced this pull request Jul 4, 2026
BIP-110 disables OP_IF and OP_NOTIF in tapscript and limits data
pushes to 256 bytes.

Adds an alternative inscription envelope parser: a bare protocol
push followed by a series of data pushes balanced by OP_DROP and
OP_2DROP. Matches the envelope shape proposed in ordinals/ord#4545
so we parse the same inscriptions the ord indexer will.

Both envelope shapes share the same "ord" push (four bytes);
a classic envelope is any occurrence preceded by OP_FALSE OP_IF,
anything else is BIP-110. One marker, one scanner, one extractor
handles both -- the terminator switches to OP_DROP / OP_2DROP for
BIP-110 and the envelope-size math is a single subtraction, no
fudge factors.

Testing: no BIP-110 shape inscription exists on chain yet, so the
spec uses a hand-crafted synthetic transaction (txid = "deadbeef"
x 8). The GOLDEN RULE (every test uses real blockchain data) is
waived here on purpose: this test pins the wire-format parsing so
it works on day one when a real BIP-110 envelope lands. Add a
real-tx spec when one exists on mainnet.
hans-crypto added a commit to ordpool-space/ordpool-parser that referenced this pull request Jul 4, 2026
BIP-110 disables OP_IF and OP_NOTIF in tapscript and limits data
pushes to 256 bytes.

Adds an alternative inscription envelope parser: a bare protocol
push followed by a series of data pushes balanced by OP_DROP and
OP_2DROP. Matches the envelope shape proposed in ordinals/ord#4545
so we parse the same inscriptions the ord indexer will.

Both envelope shapes share the same "ord" push (four bytes);
a classic envelope is any occurrence preceded by OP_FALSE OP_IF,
anything else is BIP-110. One marker, one scanner, one extractor
handles both -- the terminator switches to OP_DROP / OP_2DROP for
BIP-110 and the envelope-size math is a single subtraction, no
fudge factors.

Testing: no BIP-110 shape inscription exists on chain yet, so the
spec uses a hand-crafted synthetic transaction (txid = "deadbeef"
x 8). The GOLDEN RULE (every test uses real blockchain data) is
waived here on purpose: this test pins the wire-format parsing so
it works on day one when a real BIP-110 envelope lands. Add a
real-tx spec when one exists on mainnet.
hans-crypto added a commit to ordpool-space/ordpool-parser that referenced this pull request Jul 4, 2026
BIP-110 disables OP_IF and OP_NOTIF in tapscript and limits data
pushes to 256 bytes.

Adds an alternative inscription envelope parser: a bare protocol
push followed by a series of data pushes balanced by OP_DROP and
OP_2DROP. Matches the envelope shape proposed in ordinals/ord#4545
so we parse the same inscriptions the ord indexer will.

Both envelope shapes share the same "ord" push (four bytes);
a classic envelope is any occurrence preceded by OP_FALSE OP_IF,
anything else is BIP-110. One marker, one scanner, one extractor
handles both -- the terminator switches to OP_DROP / OP_2DROP for
BIP-110 and the envelope-size math is a single subtraction, no
fudge factors.

Testing: no BIP-110 shape inscription exists on chain yet, so the
spec uses a hand-crafted synthetic transaction (txid = "deadbeef"
x 8). The GOLDEN RULE (every test uses real blockchain data) is
waived here on purpose: this test pins the wire-format parsing so
it works on day one when a real BIP-110 envelope lands. Add a
real-tx spec when one exists on mainnet.
@hans-crypto

Copy link
Copy Markdown

signaling support for this. ordpool is ready! 🫡

ordpool-space/ordpool-parser#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants