btcruby 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16766d44b49b6e361fcd92e76421a0ba4f815fa6
4
- data.tar.gz: 92aaedfe9cda6fcfc87ce9f6b158adbb3237e847
3
+ metadata.gz: cefd4033ae3596836149bf235bb94b7f1b3d6963
4
+ data.tar.gz: 74ebe0b3428d48d91bda78772ec5c84743ce6723
5
5
  SHA512:
6
- metadata.gz: 5cab2a47cbb54f031fe4a8f57360657a9790cd1f56843b53d613e40c840612fd35f3910822e2a1f46e9a5f33eb3b84c60635c842d71ec0c1963e19e107cadbfc
7
- data.tar.gz: bd806cad97401ba874414b63f0c35cd095e7dae9e28f9ac3e16cc4bcb7caf123a88713d24a05bc2f0f0619dd0ed965e8a000171f47a47a2b55ac1ea4f39def04
6
+ metadata.gz: c268750c6b2707040f17dee13781809a8bd3e7a36241ceaa5027fe7bc24bfef4e8eec4a13db209fa49c23575550ad6edbfe27ca01591cc2a7d4c08065286c38f
7
+ data.tar.gz: 2c610aecba52ae7c9a5cf920e2aa6371b0950a1ee39afc95d9c78950a189273d2091c5c98f4cdadc74876b2178f83d5f0ab59a09e422f26ce7a501ef8a228bcf
data/README.md CHANGED
@@ -62,9 +62,10 @@ $ rake
62
62
  4. Generate and publish the gem:
63
63
 
64
64
  ```
65
+ $ git tag VERSION
65
66
  $ git push origin --tags
66
67
  $ gem build btcruby.gemspec
67
- $ gem push btcruby-VER.gem
68
+ $ gem push btcruby-VERSION.gem
68
69
  ```
69
70
 
70
71
  ## Authors
@@ -2,6 +2,12 @@
2
2
  BTCRuby Release Notes
3
3
  =====================
4
4
 
5
+ 1.2.2 (November 12, 2015)
6
+ -----------------------
7
+
8
+ * Added support for inserting scripts during script execution in `BTC::ScriptInterpreter`.
9
+
10
+
5
11
  1.2.1 (September 8, 2015)
6
12
  -----------------------
7
13
 
@@ -25,6 +25,9 @@ module BTC
25
25
  signature_script = @signature_script
26
26
  @signature_script = nil
27
27
 
28
+ # NOTE: check for empty stack or "false" item happens
29
+ # in ScriptInterpreter before this callback is invoked.
30
+
28
31
  # If output script is not P2SH, do nothing.
29
32
  return true if !output_script.p2sh?
30
33
 
@@ -46,7 +46,7 @@ module BTC
46
46
  integer_max_size: 4,
47
47
  locktime_max_size: 5)
48
48
  @flags = flags
49
- @extensions = extensions || []
49
+ @extensions = extensions || []
50
50
  @signature_checker = signature_checker
51
51
 
52
52
  @raise_on_failure = raise_on_failure
@@ -142,7 +142,8 @@ module BTC
142
142
 
143
143
  # Altstack is not shared between individual runs, but we still store it in ivar to make available to the extensions.
144
144
  @altstack = []
145
-
145
+ @run_script_chunks = script.chunks.to_a.dup # can be modified by `insert_script`
146
+
146
147
  number_zero = ScriptNumber.new(integer: 0)
147
148
  number_one = ScriptNumber.new(integer: 1)
148
149
  zero_value = "".b
@@ -153,8 +154,11 @@ module BTC
153
154
  require_minimal = flag?(SCRIPT_VERIFY_MINIMALDATA)
154
155
  condition_flags = []
155
156
  index_after_codeseparator = 0
156
- script.chunks.each_with_index do |chunk, chunk_index|
157
-
157
+ chunk_index = -1 # start with -1 because we increment it in the beginning of the loop.
158
+
159
+ while chunk = @run_script_chunks.shift
160
+ chunk_index += 1
161
+
158
162
  opcode = chunk.opcode
159
163
  should_execute = !condition_flags.include?(false)
160
164
 
@@ -652,8 +656,8 @@ module BTC
652
656
  return set_error(SCRIPT_ERR_INVALID_STACK_OPERATION)
653
657
  end
654
658
 
655
- sig = @stack[-2]
656
- pubkey = @stack[-1]
659
+ sig = @stack[-2]
660
+ pubkey = @stack[-1]
657
661
 
658
662
  # Subset of script starting at the most recent codeseparator
659
663
  subscript = script.subscript(index_after_codeseparator..-1)
@@ -814,7 +818,13 @@ module BTC
814
818
  rescue ScriptNumberError => e
815
819
  return set_error(SCRIPT_ERR_UNKNOWN_ERROR, e.message)
816
820
  end # run_script
817
-
821
+
822
+
823
+ # Inserts another script for execution within run_script call.
824
+ def insert_script(script)
825
+ @run_script_chunks = script.chunks.to_a + @run_script_chunks
826
+ end
827
+
818
828
 
819
829
  def stack_pop
820
830
  r = @stack.pop
@@ -1,3 +1,3 @@
1
1
  module BTC
2
- VERSION = "1.2.1".freeze
2
+ VERSION = "1.2.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: btcruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Andreev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-09 00:00:00.000000000 Z
12
+ date: 2015-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi