tapyrus 0.2.4 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +37 -0
  3. data/.prettierignore +3 -0
  4. data/.prettierrc.yaml +3 -0
  5. data/CODE_OF_CONDUCT.md +7 -7
  6. data/README.md +14 -17
  7. data/Rakefile +3 -3
  8. data/lib/openassets.rb +0 -2
  9. data/lib/openassets/marker_output.rb +0 -4
  10. data/lib/openassets/payload.rb +4 -10
  11. data/lib/schnorr.rb +14 -9
  12. data/lib/schnorr/sign_to_contract.rb +51 -0
  13. data/lib/schnorr/signature.rb +3 -6
  14. data/lib/tapyrus.rb +8 -30
  15. data/lib/tapyrus/base58.rb +7 -6
  16. data/lib/tapyrus/bip175.rb +67 -0
  17. data/lib/tapyrus/block.rb +1 -2
  18. data/lib/tapyrus/block_header.rb +15 -9
  19. data/lib/tapyrus/bloom_filter.rb +5 -3
  20. data/lib/tapyrus/chain_params.rb +1 -4
  21. data/lib/tapyrus/chainparams/dev.yml +3 -2
  22. data/lib/tapyrus/chainparams/prod.yml +3 -2
  23. data/lib/tapyrus/constants.rb +29 -23
  24. data/lib/tapyrus/errors.rb +1 -3
  25. data/lib/tapyrus/ext.rb +1 -1
  26. data/lib/tapyrus/ext/ecdsa.rb +4 -4
  27. data/lib/tapyrus/ext/json_parser.rb +1 -4
  28. data/lib/tapyrus/ext_key.rb +44 -32
  29. data/lib/tapyrus/key.rb +31 -35
  30. data/lib/tapyrus/key_path.rb +15 -12
  31. data/lib/tapyrus/logger.rb +20 -16
  32. data/lib/tapyrus/merkle_tree.rb +19 -20
  33. data/lib/tapyrus/message.rb +14 -16
  34. data/lib/tapyrus/message/addr.rb +1 -7
  35. data/lib/tapyrus/message/base.rb +0 -3
  36. data/lib/tapyrus/message/block.rb +2 -9
  37. data/lib/tapyrus/message/block_transaction_request.rb +3 -6
  38. data/lib/tapyrus/message/block_transactions.rb +2 -6
  39. data/lib/tapyrus/message/block_txn.rb +0 -4
  40. data/lib/tapyrus/message/cmpct_block.rb +1 -7
  41. data/lib/tapyrus/message/error.rb +1 -4
  42. data/lib/tapyrus/message/fee_filter.rb +1 -4
  43. data/lib/tapyrus/message/filter_add.rb +0 -4
  44. data/lib/tapyrus/message/filter_clear.rb +0 -4
  45. data/lib/tapyrus/message/filter_load.rb +2 -5
  46. data/lib/tapyrus/message/get_addr.rb +0 -4
  47. data/lib/tapyrus/message/get_block_txn.rb +0 -4
  48. data/lib/tapyrus/message/get_blocks.rb +0 -3
  49. data/lib/tapyrus/message/get_data.rb +1 -4
  50. data/lib/tapyrus/message/get_headers.rb +1 -3
  51. data/lib/tapyrus/message/header_and_short_ids.rb +3 -9
  52. data/lib/tapyrus/message/headers.rb +0 -4
  53. data/lib/tapyrus/message/headers_parser.rb +3 -8
  54. data/lib/tapyrus/message/inv.rb +1 -4
  55. data/lib/tapyrus/message/inventories_parser.rb +2 -7
  56. data/lib/tapyrus/message/inventory.rb +12 -5
  57. data/lib/tapyrus/message/mem_pool.rb +0 -4
  58. data/lib/tapyrus/message/merkle_block.rb +4 -9
  59. data/lib/tapyrus/message/network_addr.rb +7 -6
  60. data/lib/tapyrus/message/not_found.rb +0 -3
  61. data/lib/tapyrus/message/ping.rb +0 -3
  62. data/lib/tapyrus/message/pong.rb +0 -3
  63. data/lib/tapyrus/message/prefilled_tx.rb +0 -4
  64. data/lib/tapyrus/message/reject.rb +0 -3
  65. data/lib/tapyrus/message/send_cmpct.rb +1 -3
  66. data/lib/tapyrus/message/send_headers.rb +0 -3
  67. data/lib/tapyrus/message/tx.rb +0 -4
  68. data/lib/tapyrus/message/ver_ack.rb +1 -5
  69. data/lib/tapyrus/message/version.rb +2 -5
  70. data/lib/tapyrus/mnemonic.rb +17 -15
  71. data/lib/tapyrus/network.rb +0 -2
  72. data/lib/tapyrus/network/connection.rb +0 -3
  73. data/lib/tapyrus/network/message_handler.rb +61 -60
  74. data/lib/tapyrus/network/peer.rb +13 -12
  75. data/lib/tapyrus/network/peer_discovery.rb +3 -5
  76. data/lib/tapyrus/network/pool.rb +12 -12
  77. data/lib/tapyrus/node.rb +1 -1
  78. data/lib/tapyrus/node/cli.rb +12 -14
  79. data/lib/tapyrus/node/configuration.rb +1 -3
  80. data/lib/tapyrus/node/spv.rb +2 -3
  81. data/lib/tapyrus/opcodes.rb +9 -7
  82. data/lib/tapyrus/out_point.rb +5 -5
  83. data/lib/tapyrus/rpc.rb +1 -0
  84. data/lib/tapyrus/rpc/http_server.rb +21 -22
  85. data/lib/tapyrus/rpc/request_handler.rb +42 -44
  86. data/lib/tapyrus/rpc/tapyrus_core_client.rb +67 -25
  87. data/lib/tapyrus/script/color.rb +20 -2
  88. data/lib/tapyrus/script/multisig.rb +13 -12
  89. data/lib/tapyrus/script/script.rb +104 -67
  90. data/lib/tapyrus/script/script_error.rb +1 -4
  91. data/lib/tapyrus/script/script_interpreter.rb +439 -399
  92. data/lib/tapyrus/script/tx_checker.rb +20 -10
  93. data/lib/tapyrus/secp256k1.rb +0 -4
  94. data/lib/tapyrus/secp256k1/native.rb +14 -15
  95. data/lib/tapyrus/secp256k1/rfc6979.rb +7 -4
  96. data/lib/tapyrus/secp256k1/ruby.rb +10 -12
  97. data/lib/tapyrus/slip39.rb +20 -5
  98. data/lib/tapyrus/slip39/share.rb +41 -29
  99. data/lib/tapyrus/slip39/sss.rb +101 -57
  100. data/lib/tapyrus/store.rb +1 -3
  101. data/lib/tapyrus/store/chain_entry.rb +0 -4
  102. data/lib/tapyrus/store/db.rb +0 -2
  103. data/lib/tapyrus/store/db/level_db.rb +5 -9
  104. data/lib/tapyrus/store/spv_chain.rb +11 -17
  105. data/lib/tapyrus/tx.rb +45 -37
  106. data/lib/tapyrus/tx_builder.rb +158 -0
  107. data/lib/tapyrus/tx_in.rb +1 -6
  108. data/lib/tapyrus/tx_out.rb +2 -7
  109. data/lib/tapyrus/util.rb +20 -7
  110. data/lib/tapyrus/validation.rb +12 -11
  111. data/lib/tapyrus/version.rb +1 -1
  112. data/lib/tapyrus/wallet/account.rb +22 -18
  113. data/lib/tapyrus/wallet/base.rb +12 -9
  114. data/lib/tapyrus/wallet/db.rb +6 -9
  115. data/lib/tapyrus/wallet/master_key.rb +2 -4
  116. data/tapyrusrb.gemspec +13 -16
  117. metadata +22 -31
  118. data/.travis.yml +0 -12
@@ -1,13 +1,11 @@
1
1
  module Tapyrus
2
2
  module Wallet
3
-
4
3
  class DB
5
-
6
4
  KEY_PREFIX = {
7
- account: 'a', # key: account index, value: Account raw data.
8
- master: 'm', # value: wallet seed.
9
- version: 'v', # value: wallet version
10
- key: 'k', # key: path to the key, value: public key
5
+ account: 'a', # key: account index, value: Account raw data.
6
+ master: 'm', # value: wallet seed.
7
+ version: 'v', # value: wallet version
8
+ key: 'k' # key: path to the key, value: public key
11
9
  }
12
10
 
13
11
  attr_reader :level_db
@@ -27,7 +25,7 @@ module Tapyrus
27
25
  def accounts
28
26
  from = KEY_PREFIX[:account] + '00000000'
29
27
  to = KEY_PREFIX[:account] + 'ffffffff'
30
- level_db.each(from: from, to: to).map { |k, v| v}
28
+ level_db.each(from: from, to: to).map { |k, v| v }
31
29
  end
32
30
 
33
31
  def save_account(account)
@@ -50,7 +48,7 @@ module Tapyrus
50
48
  id = [account.purpose, account.index].pack('I*').bth
51
49
  from = KEY_PREFIX[:key] + id + '00000000'
52
50
  to = KEY_PREFIX[:key] + id + 'ffffffff'
53
- level_db.each(from: from, to: to).map { |k, v| v}
51
+ level_db.each(from: from, to: to).map { |k, v| v }
54
52
  end
55
53
 
56
54
  # get master_key
@@ -75,7 +73,6 @@ module Tapyrus
75
73
  def version
76
74
  level_db.get(KEY_PREFIX[:version]).to_i
77
75
  end
78
-
79
76
  end
80
77
  end
81
78
  end
@@ -1,6 +1,5 @@
1
1
  module Tapyrus
2
2
  module Wallet
3
-
4
3
  # HD Wallet master seed
5
4
  class MasterKey
6
5
  include Tapyrus::HexConverter
@@ -53,7 +52,7 @@ module Tapyrus
53
52
  # [encrypted(false:0, true:1)][salt(var str)][seed(var str)]
54
53
  def to_payload
55
54
  flg = encrypted ? 1 : 0
56
- pack_var_int(flg) << [salt, seed].map{|v|pack_var_string(v.htb)}.join
55
+ pack_var_int(flg) << [salt, seed].map { |v| pack_var_string(v.htb) }.join
57
56
  end
58
57
 
59
58
  # get master key
@@ -67,7 +66,7 @@ module Tapyrus
67
66
  # @return [Tapyrus::ExtKey]
68
67
  def derive(path)
69
68
  derived_key = key
70
- parse_key_path(path).each{|num| derived_key = derived_key.derive(num)}
69
+ parse_key_path(path).each { |num| derived_key = derived_key.derive(num) }
71
70
  derived_key
72
71
  end
73
72
 
@@ -105,7 +104,6 @@ module Tapyrus
105
104
  key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(passphrase, salt, 2000, enc.key_len + enc.iv_len)
106
105
  [key_iv[0, enc.key_len], key_iv[enc.key_len, enc.iv_len]]
107
106
  end
108
-
109
107
  end
110
108
  end
111
109
  end
data/tapyrusrb.gemspec CHANGED
@@ -4,21 +4,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'tapyrus/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
+ spec.name = 'tapyrus'
8
+ spec.version = Tapyrus::VERSION
9
+ spec.authors = ['azuchi']
10
+ spec.email = ['azuchi@chaintope.com']
7
11
 
8
- spec.name = "tapyrus"
9
- spec.version = Tapyrus::VERSION
10
- spec.authors = ["azuchi"]
11
- spec.email = ["azuchi@chaintope.com"]
12
+ spec.summary = 'The implementation of Tapyrus Protocol for Ruby.'
13
+ spec.description = 'The implementation of Tapyrus Protocol for Ruby.'
14
+ spec.homepage = 'https://github.com/chaintope/tapyrusrb'
15
+ spec.license = 'MIT'
12
16
 
13
- spec.summary = %q{[WIP]The implementation of Tapyrus Protocol for Ruby.}
14
- spec.description = %q{[WIP]The implementation of Tapyrus Protocol for Ruby.}
15
- spec.homepage = 'https://github.com/chaintope/tapyrusrb'
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
22
21
 
23
22
  spec.add_runtime_dependency 'ecdsa'
24
23
  spec.add_runtime_dependency 'eventmachine'
@@ -30,8 +29,6 @@ Gem::Specification.new do |spec|
30
29
  spec.add_runtime_dependency 'eventmachine_httpserver'
31
30
  spec.add_runtime_dependency 'iniparse'
32
31
  spec.add_runtime_dependency 'siphash'
33
- spec.add_runtime_dependency 'protobuf', '3.8.5'
34
- spec.add_runtime_dependency 'scrypt'
35
32
  spec.add_runtime_dependency 'activesupport', '>= 5.2.3'
36
33
  spec.add_runtime_dependency 'json_pure', '>= 2.3.1'
37
34
 
@@ -39,9 +36,9 @@ Gem::Specification.new do |spec|
39
36
  spec.add_development_dependency 'leveldb-native'
40
37
 
41
38
  spec.add_development_dependency 'bundler'
39
+ spec.add_development_dependency 'prettier'
42
40
  spec.add_development_dependency 'rake', '>= 12.3.3'
43
41
  spec.add_development_dependency 'rspec', '~> 3.0'
44
42
  spec.add_development_dependency 'timecop'
45
43
  spec.add_development_dependency 'webmock', '~> 3.0'
46
-
47
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapyrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -151,63 +151,49 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: protobuf
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - '='
158
- - !ruby/object:Gem::Version
159
- version: 3.8.5
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - '='
165
- - !ruby/object:Gem::Version
166
- version: 3.8.5
167
- - !ruby/object:Gem::Dependency
168
- name: scrypt
154
+ name: activesupport
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
157
  - - ">="
172
158
  - !ruby/object:Gem::Version
173
- version: '0'
159
+ version: 5.2.3
174
160
  type: :runtime
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
164
  - - ">="
179
165
  - !ruby/object:Gem::Version
180
- version: '0'
166
+ version: 5.2.3
181
167
  - !ruby/object:Gem::Dependency
182
- name: activesupport
168
+ name: json_pure
183
169
  requirement: !ruby/object:Gem::Requirement
184
170
  requirements:
185
171
  - - ">="
186
172
  - !ruby/object:Gem::Version
187
- version: 5.2.3
173
+ version: 2.3.1
188
174
  type: :runtime
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - ">="
193
179
  - !ruby/object:Gem::Version
194
- version: 5.2.3
180
+ version: 2.3.1
195
181
  - !ruby/object:Gem::Dependency
196
- name: json_pure
182
+ name: leveldb-native
197
183
  requirement: !ruby/object:Gem::Requirement
198
184
  requirements:
199
185
  - - ">="
200
186
  - !ruby/object:Gem::Version
201
- version: 2.3.1
202
- type: :runtime
187
+ version: '0'
188
+ type: :development
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
192
  - - ">="
207
193
  - !ruby/object:Gem::Version
208
- version: 2.3.1
194
+ version: '0'
209
195
  - !ruby/object:Gem::Dependency
210
- name: leveldb-native
196
+ name: bundler
211
197
  requirement: !ruby/object:Gem::Requirement
212
198
  requirements:
213
199
  - - ">="
@@ -221,7 +207,7 @@ dependencies:
221
207
  - !ruby/object:Gem::Version
222
208
  version: '0'
223
209
  - !ruby/object:Gem::Dependency
224
- name: bundler
210
+ name: prettier
225
211
  requirement: !ruby/object:Gem::Requirement
226
212
  requirements:
227
213
  - - ">="
@@ -290,7 +276,7 @@ dependencies:
290
276
  - - "~>"
291
277
  - !ruby/object:Gem::Version
292
278
  version: '3.0'
293
- description: "[WIP]The implementation of Tapyrus Protocol for Ruby."
279
+ description: The implementation of Tapyrus Protocol for Ruby.
294
280
  email:
295
281
  - azuchi@chaintope.com
296
282
  executables:
@@ -299,11 +285,13 @@ executables:
299
285
  extensions: []
300
286
  extra_rdoc_files: []
301
287
  files:
288
+ - ".github/workflows/ruby.yml"
302
289
  - ".gitignore"
290
+ - ".prettierignore"
291
+ - ".prettierrc.yaml"
303
292
  - ".rspec"
304
293
  - ".ruby-gemset"
305
294
  - ".ruby-version"
306
- - ".travis.yml"
307
295
  - CODE_OF_CONDUCT.md
308
296
  - Gemfile
309
297
  - LICENSE.txt
@@ -318,9 +306,11 @@ files:
318
306
  - lib/openassets/payload.rb
319
307
  - lib/openassets/util.rb
320
308
  - lib/schnorr.rb
309
+ - lib/schnorr/sign_to_contract.rb
321
310
  - lib/schnorr/signature.rb
322
311
  - lib/tapyrus.rb
323
312
  - lib/tapyrus/base58.rb
313
+ - lib/tapyrus/bip175.rb
324
314
  - lib/tapyrus/block.rb
325
315
  - lib/tapyrus/block_header.rb
326
316
  - lib/tapyrus/bloom_filter.rb
@@ -418,6 +408,7 @@ files:
418
408
  - lib/tapyrus/store/db/level_db.rb
419
409
  - lib/tapyrus/store/spv_chain.rb
420
410
  - lib/tapyrus/tx.rb
411
+ - lib/tapyrus/tx_builder.rb
421
412
  - lib/tapyrus/tx_in.rb
422
413
  - lib/tapyrus/tx_out.rb
423
414
  - lib/tapyrus/util.rb
@@ -452,5 +443,5 @@ requirements: []
452
443
  rubygems_version: 3.0.3
453
444
  signing_key:
454
445
  specification_version: 4
455
- summary: "[WIP]The implementation of Tapyrus Protocol for Ruby."
446
+ summary: The implementation of Tapyrus Protocol for Ruby.
456
447
  test_files: []
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.6
4
- - 2.5.5
5
- - 2.6.3
6
- addons:
7
- apt:
8
- packages:
9
- - libleveldb-dev
10
- bundler_args: --jobs=2
11
- script:
12
- - bundle exec rake spec