feat: implement SPV verification (Transaction#verify)#135
Merged
Conversation
Queue-based SPV verification matching TS/Go/Python reference SDKs: - Merkle path short-circuit for proven transactions - Recursive source transaction verification via queue - Script execution via interpreter for each input - Optional fee model validation (root tx only) - Output ≤ input constraint check - Deduplication via verified txid set Implements sub-task #132 of HLR #95. Co-Authored-By: Claude <noreply@anthropic.com>
8 conformance specs validating against all three reference SDKs: merkle path short-circuit, invalid proof handling, fee-only-on-root, output ≤ input constraint, deduplication, script execution, recursive ancestry, and FeeModel integration. Implements sub-task #134 of HLR #95. Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Add BSV::Transaction::VerificationError with typed error codes (:invalid_merkle_proof, :insufficient_fee, :output_overflow) matching Go SDK's typed error pattern - Replace `|| 0` in verify_output_constraint with total_input_satoshis (nil inputs already caught by verify_input_requirements) - Update all specs to expect VerificationError Co-Authored-By: Claude <noreply@anthropic.com>
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
Transaction#verify(chain_tracker:, fee_model: nil)for full SPV verification matching all three reference SDKs (TS, Go, Python)Changes
lib/bsv/transaction/transaction.rb— Added#verifypublic method and private helpers (verify_input_requirements,verify_fee,verify_output_constraint)spec/bsv/transaction/transaction_verify_spec.rb— 17 unit/integration specsspec/conformance/spv_verify_spec.rb— 8 cross-SDK conformance specsCloses #95, #132, #133, #134
Test plan
🤖 Generated with Claude Code