coloredcoins 0.0.1 → 0.0.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: 6dc49542256b1f86ce32aa7e6a107e7abd8fa590
4
- data.tar.gz: fca4a8dfe2efe63b375429dcdf28e8b8e2635020
3
+ metadata.gz: cc8e4c5b4f4d87e29d1ce9c2e0d5b22890dd75c3
4
+ data.tar.gz: 3ffc996218444f1665ca80199d326244c33d7a78
5
5
  SHA512:
6
- metadata.gz: 6ab10c67df4296f21fc45b78751860bd191c5cea6504c5f443fd9e43016aa382ef25f683620986f206d65b9f00eae5910a08f2ddd3bd23a1415b84cf57dbfb49
7
- data.tar.gz: 16887fe9d1b9eede983785c6fe111aa808ed05dbe9071da01b67bf62f095aea6f79bb8f5b70b2cde2e5688025f847b667b5e9aaed5d041fb31a67b5d89a65282
6
+ metadata.gz: 3e207996c656637f96f0f30aaf55cc52b10ac68bf5dc4335447de584e2e78a60c80a86d1c0dc1703a90c79cd38b7192d9d4c6edf2b1957bb6baa3c8db87a30f9
7
+ data.tar.gz: 1d74d40c5008bad348de132ce5d285d0f9fdf22c312fe04ea6e1954483a1e3df151bd89a8c834d09ebdb4ecc59d650bfb21484293e3a16a19cf4046de23844e5
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ *.sublime-workspace
@@ -0,0 +1,17 @@
1
+ {
2
+ "folders":
3
+ [
4
+ {
5
+ "file_exclude_patterns": ["*.sublime-workspace"],
6
+ "folder_exclude_patterns": [
7
+ "pkg",
8
+ "coverage",
9
+ "tmp"
10
+ ],
11
+ "path": ".",
12
+ "follow_symlinks": true,
13
+ "tab_size": 2,
14
+ "translate_tabs_to_spaces": false,
15
+ }
16
+ ]
17
+ }
@@ -3,10 +3,6 @@ module Coloredcoins
3
3
  attr_reader :m, :pub_keys
4
4
  attr_accessor :redeem_script
5
5
 
6
- def self.valid_sig?(i, script)
7
- tx.verify_input_signature(i, script)
8
- end
9
-
10
6
  def initialize(m = nil, pub_keys = nil)
11
7
  @m = m
12
8
  @pub_keys = pub_keys
@@ -23,6 +19,10 @@ module Coloredcoins
23
19
  end
24
20
  end
25
21
 
22
+ def valid_sig?(i, script)
23
+ tx.verify_input_signature(i, script)
24
+ end
25
+
26
26
  def address
27
27
  @address ||= Bitcoin.hash160_to_p2sh_address(Bitcoin.hash160(redeem_script.hth))
28
28
  end
@@ -38,6 +38,8 @@ module Coloredcoins
38
38
  end
39
39
 
40
40
  def build_script_sig(sigs, sig_hash, initial)
41
+ # sort them first since they could not be sorted comming from a difirent library
42
+ initial = Bitcoin::Script.sort_p2sh_multisig_signatures(initial, sig_hash)
41
43
  sigs.each do |sig|
42
44
  Bitcoin::Script.add_sig_to_multisig_script_sig(sig, initial)
43
45
  end
@@ -2,7 +2,6 @@ module Coloredcoins
2
2
  class MultisigTx < Transaction
3
3
  attr_accessor :m,
4
4
  :pub_keys,
5
- :redeem_script,
6
5
  :multisig
7
6
 
8
7
  def self.build(tx_hex)
@@ -21,6 +20,10 @@ module Coloredcoins
21
20
  @multisig ||= Coloredcoins::Multisig.new(m, pub_keys)
22
21
  end
23
22
 
23
+ def redeem_script
24
+ multisig.redeem_script
25
+ end
26
+
24
27
  def redeem_script=(script)
25
28
  multisig.redeem_script = script
26
29
  end
@@ -1,3 +1,3 @@
1
1
  module Coloredcoins
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -13,6 +13,28 @@ describe Coloredcoins::MultisigTx do
13
13
  ec81f128e2eac8e2f0e62465cd8700000000
14
14
  ).join
15
15
  end
16
+ let!(:pre_signed_tx_hex) do
17
+ %w(
18
+ 010000000125b956a45ff3c6927ab85aaed92d88cdbea00a0d813
19
+ 41cfe535b982ab50cf9f700000000fd150100483045022100d57f
20
+ 6d91ce7475d0e47e8ec76f486d1c6a24a04caad93b484b7d0dc3d7
21
+ d90ac802201e1793473e2c1b88695fe50b99ec8a92b88a947f21cb
22
+ d073cdf7aa03ffbf269b014cc95241047a130127056525587eac13
23
+ ad69f23c5e198d596025f65ac33d769e54fa3e3094b7aa4bad47ae
24
+ c9a0b1d487fd2b4f41eed468079de70f4526c721924ac3bfd12141
25
+ 0442dbb77ea49ebe546982d2ad1cb0bea3ff3abfe8fb6368582956
26
+ 22f8c5cbfd07b5a66e811e5178d8971a5f352299c163258aa6d81b
27
+ 56c980b679f1644b1dfd80410499df3d55d5741a2222d9a5d175e3
28
+ bbd9124e61b4c7f5830356c0d8082861a0e3c61ee29ec2eaabd693
29
+ f5f83568dfea0add98b1c3e971b9da7b01ed97ab3b74fb53aeffff
30
+ ffff03ac0200000000000047512103ffffffffffffffffffffffff
31
+ ffffffffffffffffffffffffffffffffffffffff2103caf376cb1c
32
+ b7d09e33bf355c4c7f5b7962502173627efbd1e3d2fc16573a65fb
33
+ 52ae00000000000000001c6a1a4343020287d1e95ca859b73cda02
34
+ c81c772ba186dc1a12a00110e45c01000000000017a914e1088f81
35
+ edc427ec81f128e2eac8e2f0e62465cd8700000000
36
+ ).join
37
+ end
16
38
  let!(:prev_tx_hex) do
17
39
  %w(
18
40
  0100000001463e1b35f72a4e978f2b7fb82f95823e90e4f50b30
@@ -113,29 +135,56 @@ describe Coloredcoins::MultisigTx do
113
135
  expect { subject.to_hex }.not_to raise_error
114
136
  end
115
137
 
116
- context 'when signing with another key' do
138
+ context 'with another key' do
117
139
  let!(:partially_signed_tx) do
118
140
  Coloredcoins::MultisigTx.build(subject.to_hex) do |tx|
119
141
  tx.m = m
120
142
  tx.pub_keys = pub_keys
121
143
  end
122
144
  end
123
- let(:tx) { partially_signed_tx.tx }
145
+ let(:partial_tx) { partially_signed_tx.tx }
146
+
147
+ it { expect(partially_signed_tx.to_hex) }
148
+
149
+ context 'when signed' do
150
+ before { partially_signed_tx.sign(keys[1]) }
124
151
 
125
- it 'should be valid' do
126
- partially_signed_tx.sign(keys[1])
127
- tx.inputs.each_with_index do |_input, i|
128
- expect(tx.verify_input_signature(i, prev_tx)).to be true
152
+ it 'should be valid' do
153
+ partial_tx.inputs.each_with_index do |_input, i|
154
+ expect(partial_tx.verify_input_signature(i, prev_tx)).to be true
155
+ end
129
156
  end
130
- end
131
157
 
132
- it 'can be converted to hex' do
133
- expect { partially_signed_tx.to_hex }.not_to raise_error
158
+ it 'can be converted to hex' do
159
+ expect { partially_signed_tx.to_hex }.not_to raise_error
160
+ end
134
161
  end
135
162
  end
136
163
  end
137
164
  end
138
165
 
166
+ context 'with a pre-signed signed tx' do
167
+ let!(:partially_signed_tx) do
168
+ Coloredcoins::MultisigTx.build(pre_signed_tx_hex) do |tx|
169
+ tx.m = m
170
+ tx.pub_keys = pub_keys
171
+ end
172
+ end
173
+ let(:tx) { partially_signed_tx.tx }
174
+
175
+ before { partially_signed_tx.sign(keys[1]) }
176
+
177
+ it 'should be valid' do
178
+ tx.inputs.each_with_index do |_input, i|
179
+ expect(tx.verify_input_signature(i, prev_tx)).to be true
180
+ end
181
+ end
182
+
183
+ it 'can be converted to hex' do
184
+ expect { partially_signed_tx.to_hex }.not_to raise_error
185
+ end
186
+ end
187
+
139
188
  context 'with several keys' do
140
189
  let!(:key) { [keys[0], keys[1]] }
141
190
  before { subject.sign(key) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coloredcoins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -175,6 +175,7 @@ files:
175
175
  - Rakefile
176
176
  - bump
177
177
  - coloredcoins.gemspec
178
+ - coloredcoins.sublime-project
178
179
  - lib/coloredcoins.rb
179
180
  - lib/coloredcoins/api.rb
180
181
  - lib/coloredcoins/connection.rb