Class: Bitcoin::Descriptor::Tr

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

Overview

tr() expression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from KeyExpression

#extracted_key, #musig?

Methods inherited from Expression

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

Constructor Details

#initialize(key, tree = nil) ⇒ Tr

Constructor.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
# File 'lib/bitcoin/descriptor/tr.rb', line 11

def initialize(key, tree = nil)
  super(key)
  validate_tree!(tree)
  raise ArgumentError, "Uncompressed key are not allowed." unless extracted_key.compressed?
  @tree = tree
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/bitcoin/descriptor/tr.rb', line 7

def key
  @key
end

#treeObject (readonly)

Returns the value of attribute tree.



8
9
10
# File 'lib/bitcoin/descriptor/tr.rb', line 8

def tree
  @tree
end

Instance Method Details

#argsObject



26
27
28
29
30
31
32
# File 'lib/bitcoin/descriptor/tr.rb', line 26

def args
  if tree.nil?
    key
  else
    tree.is_a?(Array) ? "#{key},#{tree_string(tree)}" : "#{key},#{tree}"
  end
end

#to_scriptObject



34
35
36
37
# File 'lib/bitcoin/descriptor/tr.rb', line 34

def to_script
  builder = build_tree_scripts
  builder.build
end

#top_level?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bitcoin/descriptor/tr.rb', line 22

def top_level?
  true
end

#typeObject



18
19
20
# File 'lib/bitcoin/descriptor/tr.rb', line 18

def type
  :tr
end