Class: Bitcoin::Storage::Models::TxOut

Inherits:
Protocol::TxOut show all
Defined in:
lib/bitcoin/storage/models.rb

Overview

Transaction output retrieved from storage. (see Bitcoin::Protocol::TxOut)

Instance Attribute Summary collapse

Attributes inherited from Protocol::TxOut

#pk_script, #pk_script_length, #redeem_script, #value

Instance Method Summary collapse

Methods inherited from Protocol::TxOut

#==, from_hash, from_io, #parse_data, #parse_data_from_io, #parsed_script, #to_hash, #to_null_payload, #to_payload, value_to_address

Constructor Details

#initialize(store, data) ⇒ TxOut

Returns a new instance of TxOut.



129
130
131
132
133
134
135
# File 'lib/bitcoin/storage/models.rb', line 129

def initialize store, data
  @store = store
  @id = data[:id]
  @tx_id = data[:tx_id]
  @tx_idx = data[:tx_idx]
  @type = data[:type]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



127
128
129
# File 'lib/bitcoin/storage/models.rb', line 127

def id
  @id
end

#storeObject (readonly)

Returns the value of attribute store.



127
128
129
# File 'lib/bitcoin/storage/models.rb', line 127

def store
  @store
end

#tx_idObject (readonly)

Returns the value of attribute tx_id.



127
128
129
# File 'lib/bitcoin/storage/models.rb', line 127

def tx_id
  @tx_id
end

#tx_idxObject (readonly)

Returns the value of attribute tx_idx.



127
128
129
# File 'lib/bitcoin/storage/models.rb', line 127

def tx_idx
  @tx_idx
end

#typeObject (readonly)

Returns the value of attribute type.



127
128
129
# File 'lib/bitcoin/storage/models.rb', line 127

def type
  @type
end

Instance Method Details

#get_addressObject

get all addresses this txout corresponds to (if possible)



152
153
154
# File 'lib/bitcoin/storage/models.rb', line 152

def get_address
  parsed_script.get_address
end

#get_addressesObject

get the single address this txout corresponds to (first for multisig tx)



157
158
159
# File 'lib/bitcoin/storage/models.rb', line 157

def get_addresses
  parsed_script.get_addresses
end

#get_namecoin_nameObject



161
162
163
# File 'lib/bitcoin/storage/models.rb', line 161

def get_namecoin_name
  @store.get_name_by_txout_id(@id)
end

#get_next_inObject

get the next input that references this output



147
148
149
# File 'lib/bitcoin/storage/models.rb', line 147

def get_next_in
  @store.get_txin_for_txout(get_tx.hash, @tx_idx)
end

#get_txObject

get the transaction this output is in



142
143
144
# File 'lib/bitcoin/storage/models.rb', line 142

def get_tx
  @tx ||= @store.get_tx_by_id(@tx_id)
end

#hash160Object



137
138
139
# File 'lib/bitcoin/storage/models.rb', line 137

def hash160
  parsed_script.get_hash160
end