lib/bitcoin/protocol/txin.rb in bitcoin-ruby-0.0.6 vs lib/bitcoin/protocol/txin.rb in bitcoin-ruby-0.0.7
- old
+ new
@@ -83,14 +83,16 @@
t['sequence'] = @sequence.unpack("V")[0] unless @sequence == "\xff\xff\xff\xff"
t
end
def self.from_hash(input)
- txin = TxIn.new([ input['prev_out']['hash'] ].pack('H*').reverse, input['prev_out']['n'])
+ previous_hash = input['previous_transaction_hash'] || input['prev_out']['hash']
+ previous_output_index = input['output_index'] || input['prev_out']['n']
+ txin = TxIn.new([ previous_hash ].pack('H*').reverse, previous_output_index)
if input['coinbase']
txin.script_sig = [ input['coinbase'] ].pack("H*")
else
- txin.script_sig = Script.binary_from_string(input['scriptSig'])
+ txin.script_sig = Script.binary_from_string(input['scriptSig'] || input['script'])
end
txin.sequence = [ input['sequence'] || 0xffffffff ].pack("V")
txin
end