Class: Bitcoin::Storage::Models::Tx
- Inherits:
-
Protocol::Tx
- Object
- Protocol::Tx
- Bitcoin::Storage::Models::Tx
- Defined in:
- lib/bitcoin/storage/models.rb
Overview
Transaction retrieved from storage. (see Bitcoin::Protocol::Tx)
Constant Summary
Constants inherited from Protocol::Tx
Protocol::Tx::DEFAULT_BLOCK_PRIORITY_SIZE, Protocol::Tx::SIGHASH_TYPE
Instance Attribute Summary collapse
-
#blk_id ⇒ Object
readonly
Returns the value of attribute blk_id.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lock_time ⇒ Object
Returns the value of attribute lock_time.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#ver ⇒ Object
Returns the value of attribute ver.
Attributes inherited from Protocol::Tx
Instance Method Summary collapse
-
#confirmations ⇒ Object
get the number of blocks that confirm this tx in the main chain.
-
#get_block ⇒ Object
get the block this transaction is in.
-
#initialize(store, data) ⇒ Tx
constructor
A new instance of Tx.
Methods inherited from Protocol::Tx
#==, #add_in, #add_out, binary_from_hash, binary_from_json, #binary_hash, #calculate_minimum_fee, from_file, from_hash, from_json, from_json_file, #hash_from_payload, #is_coinbase?, #minimum_block_fee, #minimum_relay_fee, #parse_data_from_io, #signature_hash_for_input, #to_hash, #to_json, #to_json_file, #to_payload, #validator, #verify_input_signature
Constructor Details
#initialize(store, data) ⇒ Tx
Returns a new instance of Tx.
46 47 48 49 50 51 |
# File 'lib/bitcoin/storage/models.rb', line 46 def initialize store, data @store = store @id = data[:id] @blk_id = data[:blk_id] super(nil) end |
Instance Attribute Details
#blk_id ⇒ Object (readonly)
Returns the value of attribute blk_id.
44 45 46 |
# File 'lib/bitcoin/storage/models.rb', line 44 def blk_id @blk_id end |
#hash ⇒ Object
Returns the value of attribute hash.
43 44 45 |
# File 'lib/bitcoin/storage/models.rb', line 43 def hash @hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
44 45 46 |
# File 'lib/bitcoin/storage/models.rb', line 44 def id @id end |
#lock_time ⇒ Object
Returns the value of attribute lock_time.
43 44 45 |
# File 'lib/bitcoin/storage/models.rb', line 43 def lock_time @lock_time end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
44 45 46 |
# File 'lib/bitcoin/storage/models.rb', line 44 def store @store end |
#ver ⇒ Object
Returns the value of attribute ver.
43 44 45 |
# File 'lib/bitcoin/storage/models.rb', line 43 def ver @ver end |
Instance Method Details
#confirmations ⇒ Object
get the number of blocks that confirm this tx in the main chain
60 61 62 63 |
# File 'lib/bitcoin/storage/models.rb', line 60 def confirmations return 0 unless get_block @store.get_head.depth - get_block.depth + 1 end |
#get_block ⇒ Object
get the block this transaction is in
54 55 56 57 |
# File 'lib/bitcoin/storage/models.rb', line 54 def get_block return nil unless @blk_id @store.get_block_by_id(@blk_id) end |