class Bitcoin::PSBT::HDKeyPath
HD Key
path data structure. see github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#Specification
Attributes
info[R]
pubkey[R]
Public Class Methods
new(pubkey, info)
click to toggle source
# File lib/bitcoin/psbt/hd_key_path.rb, line 11 def initialize(pubkey, info) pubkey = pubkey.encoding == Encoding::ASCII_8BIT ? pubkey : pubkey.htb raise ArgumentError, 'Size of key was not the expected size for the type BIP32 keypath.' unless [Bitcoin::Key::PUBLIC_KEY_SIZE, Bitcoin::Key::COMPRESSED_PUBLIC_KEY_SIZE].include?(pubkey.bytesize) pubkey = Bitcoin::Key.new(pubkey: pubkey.bth) raise ArgumentError, Errors::Messages::INVALID_PUBLIC_KEY unless pubkey.fully_valid_pubkey? @pubkey = pubkey.pubkey @info = info end
Public Instance Methods
to_h()
click to toggle source
# File lib/bitcoin/psbt/hd_key_path.rb, line 26 def to_h {pubkey: pubkey}.merge(info.to_h) end
to_payload(type = PSBT_IN_TYPES[:bip32_derivation])
click to toggle source
generate payload which consist of pubkey and fingerprint, hd key path payload. @return [String] a payload
# File lib/bitcoin/psbt/hd_key_path.rb, line 22 def to_payload(type = PSBT_IN_TYPES[:bip32_derivation]) PSBT.serialize_to_vector(type, key: pubkey.htb, value: info.to_payload) end
to_s()
click to toggle source
# File lib/bitcoin/psbt/hd_key_path.rb, line 30 def to_s to_h.to_s end