Class: Bitcoind::Transaction
- Inherits:
-
Object
- Object
- Bitcoind::Transaction
- Extended by:
- ActiveSupport::Memoizable
- Defined in:
- lib/bitcoind/transaction.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #amount ⇒ Object
- #confirmations ⇒ Object
- #confirmed? ⇒ Boolean
- #detail_hash ⇒ Object
-
#initialize(client, account, id) ⇒ Transaction
constructor
A new instance of Transaction.
- #inspect ⇒ Object
- #time ⇒ Object
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, account, id) @client = client self.account = account self.id = id end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
4 5 6 |
# File 'lib/bitcoind/transaction.rb', line 4 def account @account end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/bitcoind/transaction.rb', line 4 def id @id end |
Instance Method Details
#amount ⇒ Object
22 23 24 |
# File 'lib/bitcoind/transaction.rb', line 22 def amount detail_hash['amount'] end |
#confirmations ⇒ Object
26 27 28 |
# File 'lib/bitcoind/transaction.rb', line 26 def confirmations detail_hash['confirmations'] rescue 0 end |
#confirmed? ⇒ Boolean
35 36 37 |
# File 'lib/bitcoind/transaction.rb', line 35 def confirmed? confirmations > 6 end |
#detail_hash ⇒ Object
11 12 13 |
# File 'lib/bitcoind/transaction.rb', line 11 def detail_hash @client.request 'gettransaction', self.id end |
#inspect ⇒ Object
16 17 18 19 20 |
# File 'lib/bitcoind/transaction.rb', line 16 def inspect "#<Bitcoind::Transaction #{id} #{amount} to #{account.name} at #{time}>" rescue RestClient::InternalServerError "#<Bitcoind::Transaction #{id} UNCONFIRMED>" end |
#time ⇒ Object
30 31 32 |
# File 'lib/bitcoind/transaction.rb', line 30 def time Time.at detail_hash['time'] end |