class Tapyrus::OutPoint

outpoint class

Constants

COINBASE_HASH
COINBASE_INDEX

Attributes

index[R]
tx_hash[R]

Public Class Methods

create_coinbase_outpoint() click to toggle source
# File lib/tapyrus/out_point.rb, line 27
def self.create_coinbase_outpoint
  new(COINBASE_HASH, COINBASE_INDEX)
end
from_txid(txid, index) click to toggle source
# File lib/tapyrus/out_point.rb, line 15
def self.from_txid(txid, index)
  self.new(txid.rhex, index)
end
new(tx_hash, index = -1) click to toggle source
# File lib/tapyrus/out_point.rb, line 10
def initialize(tx_hash, index = -1)
  @tx_hash = tx_hash
  @index = index
end

Public Instance Methods

==(other) click to toggle source
# File lib/tapyrus/out_point.rb, line 35
def ==(other)
  to_payload == other&.to_payload
end
coinbase?() click to toggle source
# File lib/tapyrus/out_point.rb, line 19
def coinbase?
  tx_hash == COINBASE_HASH
end
to_payload() click to toggle source
# File lib/tapyrus/out_point.rb, line 23
def to_payload
  [tx_hash.htb, index].pack('a32V')
end
txid() click to toggle source

convert hash to txid

# File lib/tapyrus/out_point.rb, line 40
def txid
  tx_hash.rhex
end
valid?() click to toggle source
# File lib/tapyrus/out_point.rb, line 31
def valid?
  index >= 0 && (!coinbase? && tx_hash != COINBASE_HASH)
end