Class: Bitcoin::Descriptor::Wsh

Inherits:
ScriptExpression show all
Defined in:
lib/bitcoin/descriptor/wsh.rb

Overview

wsh() expression

Instance Attribute Summary

Attributes inherited from ScriptExpression

#script

Instance Method Summary collapse

Methods inherited from ScriptExpression

#args, #initialize

Methods inherited from Expression

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

Constructor Details

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

Instance Method Details

#to_scriptObject



10
11
12
# File 'lib/bitcoin/descriptor/wsh.rb', line 10

def to_script
  Script.to_p2wsh(script.to_script)
end

#top_level?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/bitcoin/descriptor/wsh.rb', line 14

def top_level?
  false
end

#typeObject



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

def type
  :wsh
end

#validate!(script) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
# File 'lib/bitcoin/descriptor/wsh.rb', line 18

def validate!(script)
  super(script)
  raise ArgumentError, 'A function is needed within P2WSH.' unless script.is_a?(Expression)
  if script.is_a?(Wpkh) || script.is_a?(Wsh)
    raise ArgumentError, "Can only have #{script.type}() at top level or inside sh()."
  end
  if script.to_script.get_pubkeys.any?{|p|!compressed_key?(p)}
    raise ArgumentError, "Uncompressed key are not allowed."
  end
end