class Bitcoin::Taproot::LeafNode

Attributes

leaf_ver[R]
script[R]

Public Class Methods

new(script, leaf_ver) click to toggle source

Initialize @param [Bitcoin::Script] script Locking script @param [Integer] leaf_ver The leaf version of this script.

# File lib/bitcoin/taproot/leaf_node.rb, line 10
def initialize(script, leaf_ver)
  raise Taproot::Error, 'script must be Bitcoin::Script object' unless script.is_a?(Bitcoin::Script)
  @script = script
  @leaf_ver = leaf_ver
end

Public Instance Methods

leaf_hash() click to toggle source

Calculate leaf hash. @return [String] leaf hash.

# 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