feat: complete BEEF serialisation (BRC-62/95/96)#121
Merged
Conversation
…hods Add convenience methods on Transaction for BEEF serialisation: - Transaction#to_beef / #to_beef_hex: build BEEF V2 from tx + ancestry - Transaction.from_beef / .from_beef_hex: parse BEEF, return subject tx Collects ancestor chain via source_transaction references and merkle paths, producing a dependency-ordered BEEF bundle. Implements sub-task #116 of HLR #92. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add merge methods to the Beef class: - merge_bump: add/deduplicate BUMPs by block height and merkle root - merge_transaction: recursively merge a tx and its ancestors - merge_raw_tx: merge from raw transaction bytes - merge: combine two BEEF bundles with BUMP index remapping - make_txid_only: convert a transaction entry to TXID-only format Implements sub-task #117 of HLR #92. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add structural validation and transaction ordering to Beef: - valid?(allow_txid_only:): checks every tx is proven or has known ancestors - sort_transactions!: topological sort via Kahn's algorithm Validation iteratively resolves: proven txs (with BUMPs) are known, then txs whose inputs all reference known txids become known. TXID-only entries are invalid by default (opt-in via allow_txid_only: true). Implements sub-task #118 of HLR #92. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add additional lookup and convenience methods to Beef: - find_bump: find merkle path for a transaction by txid - find_transaction_for_signing: return tx with wired source inputs - find_atomic_transaction: recursive proof tree wiring for ancestors - to_atomic_hex: hex convenience wrapper for to_atomic_binary Implements sub-task #119 of HLR #92. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add conformance spec validating Ruby BEEF implementation against Go SDK test vectors and expected values: - BRC-62 (V1) format: version, BUMP count, tx count, merkle path wiring - BRC-96 (V2) format: version (4022206466), 3 BUMPs, 3 txs, known txid - BRC-95 (Atomic BEEF): magic prefix, subject txid, round-trip - Empty BEEF: V1/V2 empty hex matches Go SDK expected output - V1 → V2 upgrade: data preservation across format versions - Merge conformance: deduplication, combination, post-merge validity - Transaction convenience methods: from_beef/to_beef round-trips - Validation: structural validity for all vectors, invalid magic rejection Implements sub-task #120 of HLR #92. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
Completes the BEEF (Background Evaluation Extended Format) implementation for HLR #92:
Transaction#to_beef/.from_beefbuild and parse BEEF bundles directly from transactions, collecting ancestry chains viasource_transactionreferences ([Task 1] Transaction#to_beef / Transaction.from_beef convenience methods #116)Beef#merge_bump,merge_transaction,merge_raw_tx,merge, andmake_txid_onlyfor combining BEEF bundles with BUMP deduplication ([Task 2] Beef#merge — combine BEEF bundles #117)Beef#valid?iteratively resolves proven transactions and their dependents;sort_transactions!provides topological ordering via Kahn's algorithm ([Task 3] Beef#valid? — structural validation and topological sort #118)find_bump,find_transaction_for_signing,find_atomic_transaction,to_atomic_hexmatching Go/TS SDK APIs ([Task 4] Beef lookup methods — find_bump, find_transaction_for_signing #119)986 lines added across 4 files. Full test suite: 1363 examples, 0 failures.
Closes #92, closes #116, closes #117, closes #118, closes #119, closes #120
Test plan
🤖 Generated with Claude Code