Class: BSV::Wallet::LocalProofStore

Inherits:
Object
  • Object
show all
Includes:
ProofStore
Defined in:
lib/bsv/wallet_interface/local_proof_store.rb

Overview

Default proof store — persists serialised merkle proofs via a StorageAdapter. Requires no external services.

Examples:

Using the default local proof store

store   = BSV::Wallet::MemoryStore.new
proofs  = BSV::Wallet::LocalProofStore.new(store)
proofs.store_proof(txid_hex, merkle_path)
proof   = proofs.resolve_proof(txid_hex)

Instance Method Summary collapse

Constructor Details

#initialize(storage) ⇒ LocalProofStore

Returns a new instance of LocalProofStore.

Parameters:



17
18
19
# File 'lib/bsv/wallet_interface/local_proof_store.rb', line 17

def initialize(storage)
  @storage = storage
end

Instance Method Details

#resolve_proof(txid) ⇒ BSV::Transaction::MerklePath?

Resolve and deserialise a merkle proof.

Parameters:

  • txid (String)

    hex transaction ID

Returns:

  • (BSV::Transaction::MerklePath, nil)

    the proof, or nil if unknown



34
35
36
37
38
39
# File 'lib/bsv/wallet_interface/local_proof_store.rb', line 34

def resolve_proof(txid)
  bump_hex = @storage.find_proof(txid)
  return unless bump_hex

  BSV::Transaction::MerklePath.from_hex(bump_hex)
end

#store_proof(txid, merkle_path) ⇒ void

This method returns an undefined value.

Serialise and store a merkle proof.

Parameters:

  • txid (String)

    hex transaction ID

  • merkle_path (BSV::Transaction::MerklePath)

    the proof to store



26
27
28
# File 'lib/bsv/wallet_interface/local_proof_store.rb', line 26

def store_proof(txid, merkle_path)
  @storage.store_proof(txid, merkle_path.to_hex)
end