Class: Runar::SDK::ExternalSigner
- 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
- #get_address ⇒ Object
- #get_public_key ⇒ Object
-
#initialize(pub_key_hex:, address:, sign_fn:) ⇒ ExternalSigner
constructor
A new instance of ExternalSigner.
- #sign(tx_hex, input_index, subscript, satoshis, sighash_type = nil) ⇒ Object
Constructor Details
#initialize(pub_key_hex:, address:, sign_fn:) ⇒ ExternalSigner
Returns a new instance of ExternalSigner.
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_address ⇒ Object
93 94 95 |
# File 'lib/runar/sdk/signer.rb', line 93 def get_address @address end |
#get_public_key ⇒ Object
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 |