Class: Blockchain::Transaction
- Inherits:
-
Object
- Object
- Blockchain::Transaction
- Defined in:
- lib/transaction.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#block_height ⇒ Object
readonly
Returns the value of attribute block_height.
-
#double_spend ⇒ Object
readonly
Returns the value of attribute double_spend.
-
#hsh ⇒ Object
readonly
Returns the value of attribute hsh.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#relayed_by ⇒ Object
readonly
Returns the value of attribute relayed_by.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#tx_index ⇒ Object
readonly
Returns the value of attribute tx_index.
-
#ver ⇒ Object
readonly
Returns the value of attribute ver.
-
#vin_sz ⇒ Object
readonly
Returns the value of attribute vin_sz.
-
#vout_sz ⇒ Object
readonly
Returns the value of attribute vout_sz.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(t) ⇒ Transaction
constructor
A new instance of Transaction.
- #txfee ⇒ Object
- #txtotalbtcinput ⇒ Object
- #txtotalbtcoutput ⇒ Object
Constructor Details
#initialize(t) ⇒ Transaction
10 11 12 13 14 15 16 |
# File 'lib/transaction.rb', line 10 def initialize(t) @hsh = t.delete('hash') t.each_key { |k| instance_variable_set("@#{k}", t[k]) } @inputs.map! { |i| Input.new(i) } @out.map! { |o| Output.new(o) } @time = DateTime.strptime(@time.to_s, '%s') end |
Instance Attribute Details
#block_height ⇒ Object (readonly)
Returns the value of attribute block_height.
4 5 6 |
# File 'lib/transaction.rb', line 4 def block_height @block_height end |
#double_spend ⇒ Object (readonly)
Returns the value of attribute double_spend.
3 4 5 |
# File 'lib/transaction.rb', line 3 def double_spend @double_spend end |
#hsh ⇒ Object (readonly)
Returns the value of attribute hsh.
3 4 5 |
# File 'lib/transaction.rb', line 3 def hsh @hsh end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
4 5 6 |
# File 'lib/transaction.rb', line 4 def inputs @inputs end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
4 5 6 |
# File 'lib/transaction.rb', line 4 def out @out end |
#relayed_by ⇒ Object (readonly)
Returns the value of attribute relayed_by.
4 5 6 |
# File 'lib/transaction.rb', line 4 def relayed_by @relayed_by end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/transaction.rb', line 3 def result @result end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/transaction.rb', line 3 def size @size end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/transaction.rb', line 3 def time @time end |
#tx_index ⇒ Object (readonly)
Returns the value of attribute tx_index.
4 5 6 |
# File 'lib/transaction.rb', line 4 def tx_index @tx_index end |
#ver ⇒ Object (readonly)
Returns the value of attribute ver.
3 4 5 |
# File 'lib/transaction.rb', line 3 def ver @ver end |
#vin_sz ⇒ Object (readonly)
Returns the value of attribute vin_sz.
3 4 5 |
# File 'lib/transaction.rb', line 3 def vin_sz @vin_sz end |
#vout_sz ⇒ Object (readonly)
Returns the value of attribute vout_sz.
3 4 5 |
# File 'lib/transaction.rb', line 3 def vout_sz @vout_sz end |
Class Method Details
.find(transaction) ⇒ Object
6 7 8 |
# File 'lib/transaction.rb', line 6 def self.find(transaction) self.new(Blockchain.rawtx(transaction)) end |
Instance Method Details
#==(o) ⇒ Object
30 31 32 |
# File 'lib/transaction.rb', line 30 def ==(o) o.instance_variables == self.instance_variables end |
#txfee ⇒ Object
26 27 28 |
# File 'lib/transaction.rb', line 26 def txfee Btc.from_satoshis(Blockchain.q("txfee/#{@hsh}")) end |
#txtotalbtcinput ⇒ Object
22 23 24 |
# File 'lib/transaction.rb', line 22 def txtotalbtcinput Btc.from_satoshis(Blockchain.q("txtotalbtcinput/#{@hsh}")) end |
#txtotalbtcoutput ⇒ Object
18 19 20 |
# File 'lib/transaction.rb', line 18 def txtotalbtcoutput Btc.from_satoshis(Blockchain.q("txtotalbtcoutput/#{@hsh}")) end |