Class: Runar::SDK::ExternalSigner

Inherits:
Signer
  • Object
show all
Defined in:
lib/runar/sdk/signer.rb

Overview

Callback-based signer that delegates to caller-provided Procs or lambdas.

Useful for wrapping a real signing library without coupling the SDK to it:

signer = Runar::SDK::ExternalSigner.new(
  pub_key_hex: my_pub_key,
  address: my_address,
  sign_fn: ->(tx_hex, input_index, subscript, satoshis, sighash_type) {
    my_library.sign(tx_hex, input_index, subscript, satoshis, sighash_type)
  }
)

Instance Method Summary collapse

Constructor Details

#initialize(pub_key_hex:, address:, sign_fn:) ⇒ ExternalSigner

Returns a new instance of ExternalSigner.

Parameters:

  • pub_key_hex (String)

    hex-encoded compressed public key

  • address (String)

    BSV address

  • sign_fn (#call)

    callable accepting (tx_hex, input_index, subscript, satoshis, sighash_type) and returning a hex signature



83
84
85
86
87
# File 'lib/runar/sdk/signer.rb', line 83

def initialize(pub_key_hex:, address:, sign_fn:)
  @pub_key = pub_key_hex
  @address = address
  @sign_fn = sign_fn
end

Instance Method Details

#get_addressObject



93
94
95
# File 'lib/runar/sdk/signer.rb', line 93

def get_address
  @address
end

#get_public_keyObject



89
90
91
# File 'lib/runar/sdk/signer.rb', line 89

def get_public_key
  @pub_key
end

#sign(tx_hex, input_index, subscript, satoshis, sighash_type = nil) ⇒ Object



97
98
99
# File 'lib/runar/sdk/signer.rb', line 97

def sign(tx_hex, input_index, subscript, satoshis, sighash_type = nil)
  @sign_fn.call(tx_hex, input_index, subscript, satoshis, sighash_type)
end