Class: BSV::Transaction::MerklePath::PathElement

Inherits:
Object
  • Object
show all
Defined in:
lib/bsv/transaction/merkle_path.rb

Overview

A single leaf in one level of the merkle path.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(offset:, hash: nil, txid: false, duplicate: false) ⇒ PathElement

Returns a new instance of PathElement.

Parameters:

  • offset (Integer)

    position index within the tree level

  • hash (String, nil) (defaults to: nil)

    32-byte hash (nil when duplicate)

  • txid (Boolean) (defaults to: false)

    BRC-74 flag — true when this leaf represents a transaction in the tree (the 0x02 bit in the BRC-74 serialisation). This is NOT a txid value; it is a boolean presence flag mandated by the BRC-74 specification.

  • duplicate (Boolean) (defaults to: false)

    whether this leaf duplicates its sibling



37
38
39
40
41
42
# File 'lib/bsv/transaction/merkle_path.rb', line 37

def initialize(offset:, hash: nil, txid: false, duplicate: false)
  @offset = offset
  @hash = hash
  @txid = txid
  @duplicate = duplicate
end

Instance Attribute Details

#duplicateBoolean (readonly)

Returns whether this leaf duplicates its sibling.

Returns:

  • (Boolean)

    whether this leaf duplicates its sibling



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bsv/transaction/merkle_path.rb', line 28

class PathElement
  attr_reader :offset, :hash, :txid, :duplicate

  # @param offset [Integer] position index within the tree level
  # @param hash [String, nil] 32-byte hash (nil when duplicate)
  # @param txid [Boolean] BRC-74 flag — true when this leaf represents a transaction
  #   in the tree (the 0x02 bit in the BRC-74 serialisation). This is NOT a txid
  #   value; it is a boolean presence flag mandated by the BRC-74 specification.
  # @param duplicate [Boolean] whether this leaf duplicates its sibling
  def initialize(offset:, hash: nil, txid: false, duplicate: false)
    @offset = offset
    @hash = hash
    @txid = txid
    @duplicate = duplicate
  end
end

#hashString? (readonly)

Returns 32-byte hash (nil when duplicate).

Returns:

  • (String, nil)

    32-byte hash (nil when duplicate)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bsv/transaction/merkle_path.rb', line 28

class PathElement
  attr_reader :offset, :hash, :txid, :duplicate

  # @param offset [Integer] position index within the tree level
  # @param hash [String, nil] 32-byte hash (nil when duplicate)
  # @param txid [Boolean] BRC-74 flag — true when this leaf represents a transaction
  #   in the tree (the 0x02 bit in the BRC-74 serialisation). This is NOT a txid
  #   value; it is a boolean presence flag mandated by the BRC-74 specification.
  # @param duplicate [Boolean] whether this leaf duplicates its sibling
  def initialize(offset:, hash: nil, txid: false, duplicate: false)
    @offset = offset
    @hash = hash
    @txid = txid
    @duplicate = duplicate
  end
end

#offsetInteger (readonly)

Returns position index within the tree level.

Returns:

  • (Integer)

    position index within the tree level



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bsv/transaction/merkle_path.rb', line 28

class PathElement
  attr_reader :offset, :hash, :txid, :duplicate

  # @param offset [Integer] position index within the tree level
  # @param hash [String, nil] 32-byte hash (nil when duplicate)
  # @param txid [Boolean] BRC-74 flag — true when this leaf represents a transaction
  #   in the tree (the 0x02 bit in the BRC-74 serialisation). This is NOT a txid
  #   value; it is a boolean presence flag mandated by the BRC-74 specification.
  # @param duplicate [Boolean] whether this leaf duplicates its sibling
  def initialize(offset:, hash: nil, txid: false, duplicate: false)
    @offset = offset
    @hash = hash
    @txid = txid
    @duplicate = duplicate
  end
end

#txidBoolean (readonly)

Returns BRC-74 flag — whether this leaf represents a transaction in the merkle tree (the 0x02 bit in the BRC-74 serialisation). Not a txid value.

Returns:

  • (Boolean)

    BRC-74 flag — whether this leaf represents a transaction in the merkle tree (the 0x02 bit in the BRC-74 serialisation). Not a txid value.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bsv/transaction/merkle_path.rb', line 28

class PathElement
  attr_reader :offset, :hash, :txid, :duplicate

  # @param offset [Integer] position index within the tree level
  # @param hash [String, nil] 32-byte hash (nil when duplicate)
  # @param txid [Boolean] BRC-74 flag — true when this leaf represents a transaction
  #   in the tree (the 0x02 bit in the BRC-74 serialisation). This is NOT a txid
  #   value; it is a boolean presence flag mandated by the BRC-74 specification.
  # @param duplicate [Boolean] whether this leaf duplicates its sibling
  def initialize(offset:, hash: nil, txid: false, duplicate: false)
    @offset = offset
    @hash = hash
    @txid = txid
    @duplicate = duplicate
  end
end