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, #value

Instance Method Summary collapse

Methods inherited from Protocol::TxOut

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

Constructor Details

#initialize(store, data) ⇒ TxOut

Returns a new instance of TxOut.



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

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.



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

def id
  @id
end

#storeObject (readonly)

Returns the value of attribute store.



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

def store
  @store
end

#tx_idObject (readonly)

Returns the value of attribute tx_id.



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

def tx_id
  @tx_id
end

#tx_idxObject (readonly)

Returns the value of attribute tx_idx.



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

def tx_idx
  @tx_idx
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#get_addressObject

get all addresses this txout corresponds to (if possible)



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

def get_address
  script.get_address
end

#get_addressesObject

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



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

def get_addresses
  script.get_addresses
end

#get_namecoin_nameObject



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

def get_namecoin_name
  @store.get_name_by_txout_id(@id)
end

#get_next_inObject

get the next input that references this output



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

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

#get_txObject

get the transaction this output is in



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

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

#hash160Object



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

def hash160
  script.get_hash160
end

#scriptObject



170
171
172
# File 'lib/bitcoin/storage/models.rb', line 170

def script
  @_script = Bitcoin::Script.new(@pk_script)
end