Class: Bitcoin::Descriptor::Tr
- Inherits:
-
Expression
- Object
- Expression
- Bitcoin::Descriptor::Tr
- Defined in:
- lib/bitcoin/descriptor/tr.rb
Overview
tr() expression.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(key, tree = nil) ⇒ Tr
constructor
Constructor.
- #to_script ⇒ Object
- #top_level? ⇒ Boolean
- #type ⇒ Object
Methods inherited from Expression
#==, #compressed_key?, #derive_path, #extract_pubkey, #to_hex, #to_s
Constructor Details
#initialize(key, tree = nil) ⇒ Tr
Constructor.
11 12 13 14 15 16 17 18 |
# File 'lib/bitcoin/descriptor/tr.rb', line 11 def initialize(key, tree = nil) raise ArgumentError, "Key must be string." unless key.is_a?(String) k = extract_pubkey(key) raise ArgumentError, "Uncompressed key are not allowed." unless k.compressed? validate_tree!(tree) @key = key @tree = tree end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/bitcoin/descriptor/tr.rb', line 7 def key @key end |
#tree ⇒ Object (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
#args ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bitcoin/descriptor/tr.rb', line 28 def args if tree.nil? key else tree.is_a?(Array) ? "#{key},#{tree_string(tree)}" : "#{key},#{tree}" end end |
#to_script ⇒ Object
36 37 38 39 |
# File 'lib/bitcoin/descriptor/tr.rb', line 36 def to_script builder = build_tree_scripts builder.build end |
#top_level? ⇒ Boolean
24 25 26 |
# File 'lib/bitcoin/descriptor/tr.rb', line 24 def top_level? true end |
#type ⇒ Object
20 21 22 |
# File 'lib/bitcoin/descriptor/tr.rb', line 20 def type :tr end |