Class: Bitcoin::Descriptor::Combo

Inherits:
KeyExpression show all
Defined in:
lib/bitcoin/descriptor/combo.rb

Overview

combo() expression

Instance Attribute Summary

Attributes inherited from KeyExpression

#key

Instance Method Summary collapse

Methods inherited from KeyExpression

#args, #extracted_key, #initialize

Methods inherited from Expression

#args, #compressed_key?, #derive_path, #extract_pubkey, #to_hex, #to_s, #to_script

Constructor Details

This class inherits a constructor from Bitcoin::Descriptor::KeyExpression

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
# File 'lib/bitcoin/descriptor/combo.rb', line 20

def ==(other)
  return false unless other.is_a?(Combo)
  type == other.type && to_scripts == other.to_scripts
end

#to_scriptsObject



10
11
12
13
14
15
16
17
18
# File 'lib/bitcoin/descriptor/combo.rb', line 10

def to_scripts
  candidates = [Pk.new(key), Pkh.new(key)]
  pubkey = extracted_key
  if pubkey.compressed?
    candidates << Wpkh.new(pubkey.pubkey)
    candidates << Sh.new(candidates.last)
  end
  candidates.map(&:to_script)
end

#top_level?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/bitcoin/descriptor/combo.rb', line 25

def top_level?
  true
end

#typeObject



6
7
8
# File 'lib/bitcoin/descriptor/combo.rb', line 6

def type
  :combo
end