76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/block_io/extended_bitcoinrb.rb', line 76
def initialize(priv_key: nil, pubkey: nil, key_type: nil, compressed: true, allow_hybrid: false)
raise "key_type must always be Bitcoin::KEY::TYPES[:compressed]" unless key_type == TYPES[:compressed]
puts '[Warning] Use key_type parameter instead of compressed. compressed parameter removed in the future.' if key_type.nil? && !compressed.nil? && pubkey.nil?
if key_type
@key_type = key_type
compressed = @key_type != TYPES[:uncompressed]
else
@key_type = compressed ? TYPES[:compressed] : TYPES[:uncompressed]
end
@secp256k1_module = Bitcoin.secp_impl
@priv_key = priv_key
if @priv_key
raise ArgumentError, Errors::Messages::INVALID_PRIV_KEY unless validate_private_key_range(@priv_key)
end
if pubkey
@pubkey = pubkey
else
@pubkey = generate_pubkey(priv_key, compressed: compressed) if priv_key
end
raise ArgumentError, Errors::Messages::INVALID_PUBLIC_KEY unless fully_valid_pubkey?(allow_hybrid)
end
|