Class: Graphdb::Model::Transaction
Class Method Summary
collapse
#openassets_tx?, prepended
remove_module
Class Method Details
.create_from_txid(txid) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/graphdb/model/transaction.rb', line 25
def self.create_from_txid(txid)
puts "create tx #{txid}. #{Time.now}"
tx = new
hash = load_tx(txid)
tx.hex = hash['hex']
tx.txid = hash['txid']
tx.version = hash['version']
tx.block_time = hash['blocktime']
tx.lock_time = hash['locktime']
tx.block_hash = hash['blockhash']
tx.time = hash['time']
tx.confirmations = hash['confirmations']
tx.save!
hash['vin'].each do |i|
tx.inputs << Graphdb::Model::TxIn.create_from_hash(i)
end
hash['vout'].each do |o|
tx.outputs << Graphdb::Model::TxOut.create_from_hash(o)
end
tx.save!
tx
end
|