Class: Bitcoin::Descriptor::Wpkh

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

Overview

wpkh() expression

Instance Attribute Summary

Attributes inherited from KeyExpression

#key

Instance Method Summary collapse

Methods inherited from KeyExpression

#args, #extracted_key, #musig?, #top_level?

Methods inherited from Expression

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

Constructor Details

#initialize(key) ⇒ Wpkh

Returns a new instance of Wpkh.

Raises:

  • (ArgumentError)


5
6
7
8
9
# File 'lib/bitcoin/descriptor/wpkh.rb', line 5

def initialize(key)
  raise ArgumentError, 'musig() is not allowed in wpkh().' if key.is_a?(MuSig)
  super(key)
  raise ArgumentError, "Uncompressed key are not allowed." unless extract_pubkey(key).compressed?
end

Instance Method Details

#to_scriptObject



15
16
17
# File 'lib/bitcoin/descriptor/wpkh.rb', line 15

def to_script
  Script.to_p2wpkh(extracted_key.hash160)
end

#typeObject



11
12
13
# File 'lib/bitcoin/descriptor/wpkh.rb', line 11

def type
  :wpkh
end