Add BIP-110 compatible envelope parser#4545
Open
lifofifoX wants to merge 1 commit into
Open
Conversation
Collaborator
|
Looks good to me! Let's wait until BIP-110 activates to merge this. |
d2b4a3c to
bd32556
Compare
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.
bd32556 to
26a7d5c
Compare
Contributor
|
ACK |
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.
|
signaling support for this. ordpool is ready! 🫡 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

BIP-110 disables
OP_IFandOP_NOTIFin 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_DROPandOP_2DROP.