class Graphdb::Model::Transaction

Public Class Methods

create_from_txid(txid) click to toggle source
# 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

Private Class Methods

load_tx(txid) click to toggle source
# File lib/graphdb/model/transaction.rb, line 49
def self.load_tx(txid)
  Bitcoin2Graphdb::Bitcoin.provider.tx(txid)
end