bitcoinrb 0.2.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -2
  4. data/README.md +7 -6
  5. data/bitcoinrb.gemspec +4 -4
  6. data/exe/bitcoinrbd +5 -0
  7. data/lib/bitcoin.rb +33 -1
  8. data/lib/bitcoin/bip85_entropy.rb +111 -0
  9. data/lib/bitcoin/block_header.rb +2 -0
  10. data/lib/bitcoin/chain_params.rb +0 -8
  11. data/lib/bitcoin/chainparams/regtest.yml +1 -1
  12. data/lib/bitcoin/chainparams/testnet.yml +1 -1
  13. data/lib/bitcoin/constants.rb +3 -10
  14. data/lib/bitcoin/descriptor.rb +147 -0
  15. data/lib/bitcoin/ext.rb +5 -0
  16. data/lib/bitcoin/ext/json_parser.rb +46 -0
  17. data/lib/bitcoin/ext_key.rb +19 -4
  18. data/lib/bitcoin/key.rb +9 -5
  19. data/lib/bitcoin/key_path.rb +12 -5
  20. data/lib/bitcoin/message.rb +7 -0
  21. data/lib/bitcoin/message/base.rb +1 -0
  22. data/lib/bitcoin/message/cf_parser.rb +16 -0
  23. data/lib/bitcoin/message/cfcheckpt.rb +36 -0
  24. data/lib/bitcoin/message/cfheaders.rb +40 -0
  25. data/lib/bitcoin/message/cfilter.rb +35 -0
  26. data/lib/bitcoin/message/get_cfcheckpt.rb +29 -0
  27. data/lib/bitcoin/message/get_cfheaders.rb +24 -0
  28. data/lib/bitcoin/message/get_cfilters.rb +25 -0
  29. data/lib/bitcoin/message/network_addr.rb +31 -12
  30. data/lib/bitcoin/message/version.rb +14 -22
  31. data/lib/bitcoin/mnemonic.rb +5 -5
  32. data/lib/bitcoin/network/peer.rb +12 -11
  33. data/lib/bitcoin/network/peer_discovery.rb +3 -1
  34. data/lib/bitcoin/node/cli.rb +14 -10
  35. data/lib/bitcoin/node/spv.rb +1 -1
  36. data/lib/bitcoin/out_point.rb +14 -7
  37. data/lib/bitcoin/payment_code.rb +92 -0
  38. data/lib/bitcoin/psbt.rb +3 -1
  39. data/lib/bitcoin/psbt/input.rb +7 -16
  40. data/lib/bitcoin/psbt/tx.rb +18 -12
  41. data/lib/bitcoin/rpc/bitcoin_core_client.rb +22 -12
  42. data/lib/bitcoin/rpc/request_handler.rb +3 -3
  43. data/lib/bitcoin/script/script.rb +18 -10
  44. data/lib/bitcoin/script/script_interpreter.rb +3 -5
  45. data/lib/bitcoin/secp256k1.rb +1 -0
  46. data/lib/bitcoin/secp256k1/rfc6979.rb +43 -0
  47. data/lib/bitcoin/secp256k1/ruby.rb +4 -35
  48. data/lib/bitcoin/slip39.rb +93 -0
  49. data/lib/bitcoin/slip39/share.rb +122 -0
  50. data/lib/bitcoin/slip39/sss.rb +245 -0
  51. data/lib/bitcoin/slip39/wordlist/english.txt +1024 -0
  52. data/lib/bitcoin/store.rb +2 -1
  53. data/lib/bitcoin/store/chain_entry.rb +1 -0
  54. data/lib/bitcoin/store/db/level_db.rb +2 -2
  55. data/lib/bitcoin/store/utxo_db.rb +226 -0
  56. data/lib/bitcoin/tx.rb +6 -10
  57. data/lib/bitcoin/tx_in.rb +4 -5
  58. data/lib/bitcoin/util.rb +29 -1
  59. data/lib/bitcoin/version.rb +1 -1
  60. data/lib/bitcoin/wallet.rb +1 -0
  61. data/lib/bitcoin/wallet/account.rb +1 -0
  62. data/lib/bitcoin/wallet/base.rb +3 -3
  63. data/lib/bitcoin/wallet/db.rb +1 -1
  64. data/lib/bitcoin/wallet/master_key.rb +1 -0
  65. data/lib/bitcoin/wallet/utxo.rb +37 -0
  66. metadata +45 -26
@@ -3,6 +3,7 @@ module Bitcoin
3
3
 
4
4
  # HD Wallet master seed
5
5
  class MasterKey
6
+ include Bitcoin::HexConverter
6
7
  extend Bitcoin::Util
7
8
  include Bitcoin::Util
8
9
  include Bitcoin::KeyPath
@@ -0,0 +1,37 @@
1
+ module Bitcoin
2
+ module Wallet
3
+ class Utxo
4
+ attr_reader :tx_hash
5
+ attr_reader :index
6
+ attr_reader :block_height
7
+ attr_reader :value
8
+ attr_reader :script_pubkey
9
+
10
+ def initialize(tx_hash, index, value, script_pubkey, block_height = nil)
11
+ @tx_hash = tx_hash
12
+ @index = index
13
+ @block_height = block_height
14
+ @value = value
15
+ @script_pubkey = script_pubkey
16
+ end
17
+
18
+ def self.parse_from_payload(payload)
19
+ return nil if payload.nil?
20
+
21
+ tx_hash, index, block_height, value, payload = payload.unpack('H64VVQa*')
22
+
23
+ buf = StringIO.new(payload)
24
+ script_size = Bitcoin.unpack_var_int_from_io(buf)
25
+ script_pubkey = Bitcoin::Script.parse_from_payload(buf.read(script_size));
26
+ new(tx_hash, index, value, script_pubkey, block_height == 0 ? nil : block_height )
27
+ end
28
+
29
+ def to_payload
30
+ payload = [tx_hash, index, block_height.nil? ? 0 : block_height, value].pack('H64VVQ')
31
+ s = script_pubkey.to_payload
32
+ payload << Bitcoin.pack_var_int(s.length) << s
33
+ payload
34
+ end
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitcoinrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-02 00:00:00.000000000 Z
11
+ date: 2020-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rest-client
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: iniparse
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -207,21 +193,21 @@ dependencies:
207
193
  - !ruby/object:Gem::Version
208
194
  version: '0'
209
195
  - !ruby/object:Gem::Dependency
210
- name: activesupport
196
+ name: json_pure
211
197
  requirement: !ruby/object:Gem::Requirement
212
198
  requirements:
213
- - - "~>"
199
+ - - ">="
214
200
  - !ruby/object:Gem::Version
215
- version: 5.2.3
201
+ version: 2.3.1
216
202
  type: :runtime
217
203
  prerelease: false
218
204
  version_requirements: !ruby/object:Gem::Requirement
219
205
  requirements:
220
- - - "~>"
206
+ - - ">="
221
207
  - !ruby/object:Gem::Version
222
- version: 5.2.3
208
+ version: 2.3.1
223
209
  - !ruby/object:Gem::Dependency
224
- name: leveldb-ruby
210
+ name: leveldb-native
225
211
  requirement: !ruby/object:Gem::Requirement
226
212
  requirements:
227
213
  - - ">="
@@ -252,16 +238,16 @@ dependencies:
252
238
  name: rake
253
239
  requirement: !ruby/object:Gem::Requirement
254
240
  requirements:
255
- - - "~>"
241
+ - - ">="
256
242
  - !ruby/object:Gem::Version
257
- version: '10.0'
243
+ version: 12.3.3
258
244
  type: :development
259
245
  prerelease: false
260
246
  version_requirements: !ruby/object:Gem::Requirement
261
247
  requirements:
262
- - - "~>"
248
+ - - ">="
263
249
  - !ruby/object:Gem::Version
264
- version: '10.0'
250
+ version: 12.3.3
265
251
  - !ruby/object:Gem::Dependency
266
252
  name: rspec
267
253
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +276,20 @@ dependencies:
290
276
  - - ">="
291
277
  - !ruby/object:Gem::Version
292
278
  version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: webmock
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '3.0'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '3.0'
293
293
  description: "[WIP]The implementation of Bitcoin Protocol for Ruby."
294
294
  email:
295
295
  - azuchi@chaintope.com
@@ -317,6 +317,7 @@ files:
317
317
  - exe/bitcoinrbd
318
318
  - lib/bitcoin.rb
319
319
  - lib/bitcoin/base58.rb
320
+ - lib/bitcoin/bip85_entropy.rb
320
321
  - lib/bitcoin/bit_stream.rb
321
322
  - lib/bitcoin/block.rb
322
323
  - lib/bitcoin/block_filter.rb
@@ -327,6 +328,9 @@ files:
327
328
  - lib/bitcoin/chainparams/regtest.yml
328
329
  - lib/bitcoin/chainparams/testnet.yml
329
330
  - lib/bitcoin/constants.rb
331
+ - lib/bitcoin/descriptor.rb
332
+ - lib/bitcoin/ext.rb
333
+ - lib/bitcoin/ext/json_parser.rb
330
334
  - lib/bitcoin/ext_key.rb
331
335
  - lib/bitcoin/gcs_filter.rb
332
336
  - lib/bitcoin/key.rb
@@ -340,6 +344,10 @@ files:
340
344
  - lib/bitcoin/message/block_transaction_request.rb
341
345
  - lib/bitcoin/message/block_transactions.rb
342
346
  - lib/bitcoin/message/block_txn.rb
347
+ - lib/bitcoin/message/cf_parser.rb
348
+ - lib/bitcoin/message/cfcheckpt.rb
349
+ - lib/bitcoin/message/cfheaders.rb
350
+ - lib/bitcoin/message/cfilter.rb
343
351
  - lib/bitcoin/message/cmpct_block.rb
344
352
  - lib/bitcoin/message/error.rb
345
353
  - lib/bitcoin/message/fee_filter.rb
@@ -349,6 +357,9 @@ files:
349
357
  - lib/bitcoin/message/get_addr.rb
350
358
  - lib/bitcoin/message/get_block_txn.rb
351
359
  - lib/bitcoin/message/get_blocks.rb
360
+ - lib/bitcoin/message/get_cfcheckpt.rb
361
+ - lib/bitcoin/message/get_cfheaders.rb
362
+ - lib/bitcoin/message/get_cfilters.rb
352
363
  - lib/bitcoin/message/get_data.rb
353
364
  - lib/bitcoin/message/get_headers.rb
354
365
  - lib/bitcoin/message/header_and_short_ids.rb
@@ -390,6 +401,7 @@ files:
390
401
  - lib/bitcoin/node/spv.rb
391
402
  - lib/bitcoin/opcodes.rb
392
403
  - lib/bitcoin/out_point.rb
404
+ - lib/bitcoin/payment_code.rb
393
405
  - lib/bitcoin/payments.rb
394
406
  - lib/bitcoin/payments/output.pb.rb
395
407
  - lib/bitcoin/payments/payment.pb.rb
@@ -415,12 +427,18 @@ files:
415
427
  - lib/bitcoin/script_witness.rb
416
428
  - lib/bitcoin/secp256k1.rb
417
429
  - lib/bitcoin/secp256k1/native.rb
430
+ - lib/bitcoin/secp256k1/rfc6979.rb
418
431
  - lib/bitcoin/secp256k1/ruby.rb
432
+ - lib/bitcoin/slip39.rb
433
+ - lib/bitcoin/slip39/share.rb
434
+ - lib/bitcoin/slip39/sss.rb
435
+ - lib/bitcoin/slip39/wordlist/english.txt
419
436
  - lib/bitcoin/store.rb
420
437
  - lib/bitcoin/store/chain_entry.rb
421
438
  - lib/bitcoin/store/db.rb
422
439
  - lib/bitcoin/store/db/level_db.rb
423
440
  - lib/bitcoin/store/spv_chain.rb
441
+ - lib/bitcoin/store/utxo_db.rb
424
442
  - lib/bitcoin/tx.rb
425
443
  - lib/bitcoin/tx_in.rb
426
444
  - lib/bitcoin/tx_out.rb
@@ -432,6 +450,7 @@ files:
432
450
  - lib/bitcoin/wallet/base.rb
433
451
  - lib/bitcoin/wallet/db.rb
434
452
  - lib/bitcoin/wallet/master_key.rb
453
+ - lib/bitcoin/wallet/utxo.rb
435
454
  - lib/openassets.rb
436
455
  - lib/openassets/marker_output.rb
437
456
  - lib/openassets/payload.rb