Commit 810ba7314c83bf1a7f5bb4619fb4899311e319dc

Authored by comboy
Committed by Julian Langschaedel
1 parent 95af4c99ef

cleanup script naming in txout

Showing 3 changed files with 5 additions and 13 deletions Side-by-side Diff

lib/bitcoin/protocol/tx.rb
... ... @@ -122,7 +122,7 @@
122 122  
123 123 pin = @in.map.with_index{|input,idx|
124 124 if idx == input_idx
125   - subscript = subscript.out[ input.prev_out_index ].script if subscript.respond_to?(:out) # legacy api (outpoint_tx)
  125 + subscript = subscript.out[ input.prev_out_index ].pk_script if subscript.respond_to?(:out) # legacy api (outpoint_tx)
126 126 input.to_payload(subscript)
127 127 else
128 128 case (hash_type & 0x1f)
lib/bitcoin/protocol/txout.rb
... ... @@ -43,8 +43,8 @@
43 43  
44 44 alias :parse_payload :parse_data
45 45  
46   - def get_script
47   - @script_cache ||= Bitcoin::Script.new(@pk_script)
  46 + def script
  47 + @script ||= Bitcoin::Script.new(@pk_script)
48 48 end
49 49  
50 50 def to_payload
... ... @@ -56,7 +56,6 @@
56 56 end
57 57  
58 58 def to_hash(options = {})
59   - script = get_script
60 59 h = { 'value' => "%.8f" % (@value / 100000000.0),
61 60 'scriptPubKey' => script.to_string }
62 61 h["address"] = script.get_address if script.is_hash160? && options[:with_address]
63 62  
... ... @@ -70,15 +69,12 @@
70 69 end
71 70  
72 71 # set pk_script and pk_script_length
73   - def pk_script=(script)
74   - @pk_script_length, @pk_script = script.bytesize, script
  72 + def pk_script=(pk_script)
  73 + @pk_script_length, @pk_script = pk_script.bytesize, pk_script
75 74 end
76 75  
77 76 alias :amount :value
78 77 alias :amount= :value=
79   - alias :script :pk_script
80   - alias :script= :pk_script=
81   -
82 78  
83 79 # create output spending +value+ btc (base units) to +address+
84 80 def self.value_to_address(value, address)
lib/bitcoin/storage/models.rb
... ... @@ -165,10 +165,6 @@
165 165 script.type
166 166 end
167 167  
168   - def script
169   - @_script = Bitcoin::Script.new(@pk_script)
170   - end
171   -
172 168 end
173 169  
174 170 end