Class: Bitcoin::PSBT::GlobalXpub

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xpub, info) ⇒ GlobalXpub

Returns a new instance of GlobalXpub.



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

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

Instance Attribute Details

#infoObject (readonly)

Bitcoin::PSBT::KeyOriginInfo



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

def info
  @info
end

#xpubObject (readonly)

Bitcoin::ExtPubkey



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

def xpub
  @xpub
end

Instance Method Details

#to_hObject



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

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

#to_payloadObject



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

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

#to_sObject



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

def to_s
  to_h.to_s
end