Class: Bitcoin::Taproot::LeafNode
- Inherits:
-
Object
- Object
- Bitcoin::Taproot::LeafNode
- Defined in:
- lib/bitcoin/taproot/leaf_node.rb
Instance Attribute Summary collapse
-
#leaf_ver ⇒ Object
readonly
Returns the value of attribute leaf_ver.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
-
#initialize(script, leaf_ver = Bitcoin::TAPROOT_LEAF_TAPSCRIPT) ⇒ LeafNode
constructor
Initialize.
-
#leaf_hash ⇒ String
Calculate leaf hash.
Constructor Details
#initialize(script, leaf_ver = Bitcoin::TAPROOT_LEAF_TAPSCRIPT) ⇒ LeafNode
Initialize
10 11 12 13 14 |
# File 'lib/bitcoin/taproot/leaf_node.rb', line 10 def initialize(script, leaf_ver = Bitcoin::TAPROOT_LEAF_TAPSCRIPT) raise Taproot::Error, 'script must be Bitcoin::Script object' unless script.is_a?(Bitcoin::Script) @script = script @leaf_ver = leaf_ver end |
Instance Attribute Details
#leaf_ver ⇒ Object (readonly)
Returns the value of attribute leaf_ver.
5 6 7 |
# File 'lib/bitcoin/taproot/leaf_node.rb', line 5 def leaf_ver @leaf_ver end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
5 6 7 |
# File 'lib/bitcoin/taproot/leaf_node.rb', line 5 def script @script end |
Instance Method Details
#leaf_hash ⇒ String
Calculate leaf hash.
18 19 20 |
# File 'lib/bitcoin/taproot/leaf_node.rb', line 18 def leaf_hash @hash_value ||= Bitcoin.tagged_hash('TapLeaf', [leaf_ver].pack('C') + Bitcoin.pack_var_string(script.to_payload)) end |