Sha256: 64f38039c5a9e06800f9ec8b458766f64277bc0a46b46d6e1effff2c6523a607

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module Bitcoiner
  class Transaction
    attr_accessor :id, :account

    def initialize(client, account, id)
      @client = client
      @account = account
      @id = id
    end

    def detail_hash
      @detail_hash ||= @client.request 'gettransaction', @id
    end

    def inspect
      "#<Bitcoiner::Transaction #{id} #{amount} to #{account.name} at #{time}>"
    rescue
      "#<Bitcoiner::Transaction #{id} UNCONFIRMED>"
    end

    def amount
      detail_hash['amount']
    end

    def confirmations
      detail_hash['confirmations'] rescue 0
    end

    def time
      @time ||= Time.at detail_hash['time']
    end

    def confirmed?(min_confirmations = 6)
      confirmations > min_confirmations
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bitcoiner-0.1.1 lib/bitcoiner/transaction.rb
bitcoiner-0.1.0 lib/bitcoiner/transaction.rb