Merkle Proofs
Overview
Purpose
Basic Usage
Parse Merkle Path from Hex
Attach Merkle Proof to Transaction
Verify Merkle Proof Against Block Header
Create Merkle Path from Transaction Data
Key Features
1. TSC Merkle Path Format
2. SPV Transaction Validation
3. Merkle Path Computation
4. Source Transaction with SPV Proofs
API Reference
MerklePath Class
MerklePath Properties
MerklePath Methods
static fromHex(hex: string): MerklePath
static fromHex(hex: string): MerklePathstatic fromBinary(binary: number[]): MerklePath
static fromBinary(binary: number[]): MerklePathtoHex(): string
toHex(): stringtoBinary(): number[]
toBinary(): number[]computeRoot(txid?: string): Uint8Array
computeRoot(txid?: string): Uint8Arrayverify(txid: string, chainTracker: ChainTracker): Promise<boolean>
verify(txid: string, chainTracker: ChainTracker): Promise<boolean>ChainTracker Interface
Common Patterns
1. WhatsOnChain SPV Verification
2. Transaction Chain with SPV Proofs
3. Merkle Proof Caching and Storage
Security Considerations
1. Always Verify Merkle Roots
2. Validate ChainTracker Sources
3. Protect Against Merkle Path Manipulation
4. Handle Merkle Proof Errors Gracefully
Performance Considerations
1. Cache Merkle Proofs
2. Batch Merkle Proof Fetching
3. Optimize Merkle Root Computation
Related Components
Best Practices
1. Always Verify Merkle Proofs
2. Use Merkle Proofs for Source Transactions
3. Implement Robust ChainTrackers
4. Cache Merkle Proofs Aggressively
5. Validate Merkle Path Structure
Troubleshooting
Invalid Merkle Root
ChainTracker Failures
Merkle Path Parsing Errors
Performance Issues with Large Chains
Further Reading
Status
Last updated
