Class: Bitcoin::PSBT::GlobalXpub

Inherits:
Object
  • Object
show all
Includes:
HexConverter
Defined in:
lib/bitcoin/psbt/tx.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HexConverter

#to_hex

Constructor Details

#initialize(xpub, info) ⇒ GlobalXpub

Returns a new instance of GlobalXpub.



10
11
12
13
# File 'lib/bitcoin/psbt/tx.rb', line 10

def initialize(xpub, info)
  @xpub = xpub
  @info = info
end

Instance Attribute Details

#infoObject (readonly)

Bitcoin::PSBT::KeyOriginInfo



8
9
10
# File 'lib/bitcoin/psbt/tx.rb', line 8

def info
  @info
end

#xpubObject (readonly)

Bitcoin::ExtPubkey



7
8
9
# File 'lib/bitcoin/psbt/tx.rb', line 7

def xpub
  @xpub
end

Instance Method Details

#to_hObject



19
20
21
# File 'lib/bitcoin/psbt/tx.rb', line 19

def to_h
  {xpub: xpub.to_hex}.merge(info.to_h)
end

#to_payloadObject



15
16
17
# File 'lib/bitcoin/psbt/tx.rb', line 15

def to_payload
  PSBT.serialize_to_vector(PSBT_GLOBAL_TYPES[:xpub], key: xpub.to_payload, value: info.to_payload)
end

#to_sObject



23
24
25
# File 'lib/bitcoin/psbt/tx.rb', line 23

def to_s
  to_h.to_s
end