Class: Runar::SDK::MockSigner

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

Overview

Deterministic signer for testing. Does not perform real cryptography.

signer = Runar::SDK::MockSigner.new
signer.get_public_key  # => "0200...00" (66 hex chars)
signer.sign(...)       # => "3000...0041" (72-byte mock DER signature)

Constant Summary collapse

DEFAULT_PUB_KEY =
('02' + '00' * 32).freeze
DEFAULT_ADDRESS =
('00' * 20).freeze

Instance Method Summary collapse

Constructor Details

#initialize(pub_key_hex: '', address: '') ⇒ MockSigner

Returns a new instance of MockSigner.



47
48
49
50
# File 'lib/runar/sdk/signer.rb', line 47

def initialize(pub_key_hex: '', address: '')
  @pub_key = pub_key_hex.empty? ? DEFAULT_PUB_KEY : pub_key_hex
  @address = address.empty?     ? DEFAULT_ADDRESS  : address
end

Instance Method Details

#get_addressObject



56
57
58
# File 'lib/runar/sdk/signer.rb', line 56

def get_address
  @address
end

#get_public_keyObject



52
53
54
# File 'lib/runar/sdk/signer.rb', line 52

def get_public_key
  @pub_key
end

#sign(_tx_hex, _input_index, _subscript, _satoshis, _sighash_type = nil) ⇒ Object

Returns a deterministic 72-byte mock signature: DER prefix (0x30) + 70 zero bytes + sighash byte (0x41).



62
63
64
# File 'lib/runar/sdk/signer.rb', line 62

def sign(_tx_hex, _input_index, _subscript, _satoshis, _sighash_type = nil)
  '30' + ('00' * 70) + '41'
end