class Bitcoin::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/bitcoin/out_point.rb, line 31 def self.create_coinbase_outpoint new(COINBASE_HASH, COINBASE_INDEX) end
from_txid(txid, index)
click to toggle source
# File lib/bitcoin/out_point.rb, line 19 def self.from_txid(txid, index) self.new(txid.rhex, index) end
new(tx_hash, index = -1)
click to toggle source
# File lib/bitcoin/out_point.rb, line 14 def initialize(tx_hash, index = -1) @tx_hash = tx_hash @index = index end
Public Instance Methods
coinbase?()
click to toggle source
# File lib/bitcoin/out_point.rb, line 23 def coinbase? tx_hash == COINBASE_HASH && index == COINBASE_INDEX end
to_payload()
click to toggle source
# File lib/bitcoin/out_point.rb, line 27 def to_payload [tx_hash.htb, index].pack('a32V') end
to_s()
click to toggle source
# File lib/bitcoin/out_point.rb, line 44 def to_s return "[#{index}]" unless tx_hash "#{txid}[#{index}]" end
txid()
click to toggle source
convert hash to txid
# File lib/bitcoin/out_point.rb, line 40 def txid tx_hash.rhex end
valid?()
click to toggle source
# File lib/bitcoin/out_point.rb, line 35 def valid? index >= 0 && (!coinbase? && tx_hash != COINBASE_HASH) end