Class: CoinOp::Bit::SparseInput

Inherits:
Object
  • Object
show all
Includes:
Encodings
Defined in:
lib/coin-op/bit/input.rb

Overview

Used in Transaction.from_native or other situations where we do not have full information about the unspent output being used for an input.

Instance Method Summary collapse

Methods included from Encodings

#base58, #decode_base58, #decode_hex, #hex

Constructor Details

#initialize(binary_hash, index) ⇒ SparseInput

Returns a new instance of SparseInput.



81
82
83
84
85
86
87
88
# File 'lib/coin-op/bit/input.rb', line 81

def initialize(binary_hash, index)
  @output = {
    # the binary hash is the result of 
    # [tx.hash].pack("H*").reverse
    :transaction_hash => hex(binary_hash.reverse),
    :index => index,
  }
end

Instance Method Details

#to_json(*a) ⇒ Object



90
91
92
93
94
# File 'lib/coin-op/bit/input.rb', line 90

def to_json(*a)
  {
    :output => @output,
  }.to_json(*a)
end