class Graphdb::Model::TxOut

Public Class Methods

create_from_hash(hash) click to toggle source
# File lib/graphdb/model/tx_out.rb, line 21
def self.create_from_hash(hash)
  tx_out = new
  tx_out.value = hash['value']
  tx_out.n = hash['n']
  tx_out.save!
  if hash['scriptPubKey']
    tx_out.script_pubkey_asm = hash['scriptPubKey']['asm']
    tx_out.script_pubkey_hex = hash['scriptPubKey']['hex']
    tx_out.output_type = hash['scriptPubKey']['type']
    tx_out.req_sigs = hash['scriptPubKey']['reqSigs']
    if hash['scriptPubKey']['addresses']
      hash['scriptPubKey']['addresses'].each do |a|
        tx_out.addresses << Address.find_or_create(a)
      end
    end
  end
  tx_out.save!
  tx_out
end
find_by_outpoint(txid, n) click to toggle source
# File lib/graphdb/model/tx_out.rb, line 41
def self.find_by_outpoint(txid, n)
  tx = Graphdb::Model::Transaction.with_txid(txid).first
  if tx
    tx.outputs.find_by(n: n)
  end
end