Sha256: 07b5f0487da38df22ce2f3fbc778bf0b23586f97be1f2f5a8066a360cb083f6e
Contents?: true
Size: 897 Bytes
Versions: 1
Compression:
Stored size: 897 Bytes
Contents
# Add column txin.p2sh_type and index the type of the inner p2sh script of all inputs Sequel.migration do up do @log.info { "Running migration #{__FILE__}" } if @store.config[:index_p2sh_type] puts "Building p2sh type index..." add_column :txin, :p2sh_type, :int self[:txout].where(type: 4).each do |txout| tx = self[:tx][id: txout[:tx_id]] next unless next_in = self[:txin][prev_out: tx[:hash].reverse, prev_out_index: txout[:tx_idx]] script = Bitcoin::Script.new(next_in[:script_sig], txout[:pk_script]) if script.is_p2sh? inner_script = Bitcoin::Script.new(script.inner_p2sh_script) p2sh_type = @store.class::SCRIPT_TYPES.index(inner_script.type) self[:txin].where(id: next_in[:id]).update(p2sh_type: p2sh_type) end end add_index :txin, [:id, :p2sh_type] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bitcoin-ruby-0.0.6 | lib/bitcoin/storage/sequel/migrations/008_add_txin_p2sh_type.rb |