Class: Bitcoind::Transaction

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Memoizable
Defined in:
lib/bitcoind/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, account, id) ⇒ Transaction

Returns a new instance of Transaction.



5
6
7
8
9
# File 'lib/bitcoind/transaction.rb', line 5

def initialize(client, , id)
  @client = client
  self. = 
  self.id = id
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



4
5
6
# File 'lib/bitcoind/transaction.rb', line 4

def 
  @account
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/bitcoind/transaction.rb', line 4

def id
  @id
end

Instance Method Details

#amountObject



22
23
24
# File 'lib/bitcoind/transaction.rb', line 22

def amount
  detail_hash['amount']
end

#confirmationsObject



26
27
28
# File 'lib/bitcoind/transaction.rb', line 26

def confirmations
  detail_hash['confirmations'] rescue 0
end

#confirmed?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/bitcoind/transaction.rb', line 35

def confirmed?
  confirmations > 6
end

#detail_hashObject



11
12
13
# File 'lib/bitcoind/transaction.rb', line 11

def detail_hash
  @client.request 'gettransaction', self.id
end

#inspectObject



16
17
18
19
20
# File 'lib/bitcoind/transaction.rb', line 16

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

#timeObject



30
31
32
# File 'lib/bitcoind/transaction.rb', line 30

def time
  Time.at detail_hash['time']
end