tapyrus 0.2.10 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cf211d0ab36f04dbc16d8ee2c60c1f86bc33b5b2d8c68378c7c550e7c0697db
4
- data.tar.gz: 831801fc796432c6c61ee167dd6acc4778ef49853699babb95614a7765e37fd0
3
+ metadata.gz: 9619b8bb901abe7085cedda9ca2ed29efb41281125bca6cfe2fd68facf7fc280
4
+ data.tar.gz: a1f1d5544976189606b024ce064bdf794d01f646c4ae9b727ff278d071ddb4ce
5
5
  SHA512:
6
- metadata.gz: 84092b5fd80adc5a7121d3923c9fa4350dde4b271b19df1ed1b39579b0589862087e9c73916650948231c4bd3f1ad9b0d58c38711bad7be2e571466f2f46b2e4
7
- data.tar.gz: 14389a4e0df4fc5eb78c5ae9c63de6aab4a2a10fe52dcc8e655fe17fa6d6056422c6f0a9233dfc452a14f95480af7081570307124203ec1cbbbb11e77a5731ef
6
+ metadata.gz: '05187916624701c58d88d53bc78ddc576de97ddb1b5b3c5a9066093a57256bad53f8f86c2b126e74db36af4ae5a5ddfd3eb6f9a966672c48f45571e2c60aec61'
7
+ data.tar.gz: db6dc58cc66b4a5e754a21a26738d37af025f81f8c3c1b29635218ec685636250a22d55bc9d953e62203289524fd89640bf5951fba245712c6ba8a2b2fb7673c
@@ -14,7 +14,7 @@ module Tapyrus
14
14
  class BIP175
15
15
  PURPOSE_TYPE = 175
16
16
 
17
- attr_accessor :payment_base
17
+ attr_accessor :master_ext_key, :payment_base
18
18
 
19
19
  def initialize
20
20
  @contracts = []
@@ -25,6 +25,7 @@ module Tapyrus
25
25
  raise ArgumentError, 'key should be Tapyrus::ExtKey' unless key.is_a?(Tapyrus::ExtKey)
26
26
  raise ArgumentError, 'key should be master private extended key' unless key.master?
27
27
  new.tap do |bip175|
28
+ bip175.master_ext_key = key
28
29
  bip175.payment_base =
29
30
  key.derive(PURPOSE_TYPE, true).derive(Tapyrus.chain_params.bip44_coin_type, true).ext_pubkey
30
31
  end
@@ -52,6 +53,16 @@ module Tapyrus
52
53
  Tapyrus.sha256(concatenated_hash)
53
54
  end
54
55
 
56
+ # Return pay-to-contract extended private key
57
+ # @return [Tapyrus::ExtKey] extended private key
58
+ def priv_key
59
+ key = master_ext_key.derive(PURPOSE_TYPE, true).derive(Tapyrus.chain_params.bip44_coin_type, true)
60
+
61
+ # Split every 2 bytes
62
+ paths = combined_hash.unpack('S>*')
63
+ paths.inject(key) { |key, p| key.derive(p) }
64
+ end
65
+
55
66
  # Return pay-to-contract extended public key
56
67
  # @return [Tapyrus::ExtPubkey] extended public key
57
68
  def pubkey
@@ -47,32 +47,29 @@ module Tapyrus
47
47
 
48
48
  # Returns connected peer information.
49
49
  def getpeerinfo
50
- node
51
- .pool
52
- .peers
53
- .map do |peer|
54
- local_addr = "#{peer.remote_version.remote_addr.ip}:18333"
55
- {
56
- id: peer.id,
57
- addr: "#{peer.host}:#{peer.port}",
58
- addrlocal: local_addr,
59
- services: peer.remote_version.services.to_even_length_hex.rjust(16, '0'),
60
- relaytxes: peer.remote_version.relay,
61
- lastsend: peer.last_send,
62
- lastrecv: peer.last_recv,
63
- bytessent: peer.bytes_sent,
64
- bytesrecv: peer.bytes_recv,
65
- conntime: peer.conn_time,
66
- pingtime: peer.ping_time,
67
- minping: peer.min_ping,
68
- version: peer.remote_version.version,
69
- subver: peer.remote_version.user_agent,
70
- inbound: !peer.outbound?,
71
- startingheight: peer.remote_version.start_height,
72
- best_hash: peer.best_hash,
73
- best_height: peer.best_height
74
- }
75
- end
50
+ node.pool.peers.map do |peer|
51
+ local_addr = "#{peer.remote_version.remote_addr.ip}:18333"
52
+ {
53
+ id: peer.id,
54
+ addr: "#{peer.host}:#{peer.port}",
55
+ addrlocal: local_addr,
56
+ services: peer.remote_version.services.to_even_length_hex.rjust(16, '0'),
57
+ relaytxes: peer.remote_version.relay,
58
+ lastsend: peer.last_send,
59
+ lastrecv: peer.last_recv,
60
+ bytessent: peer.bytes_sent,
61
+ bytesrecv: peer.bytes_recv,
62
+ conntime: peer.conn_time,
63
+ pingtime: peer.ping_time,
64
+ minping: peer.min_ping,
65
+ version: peer.remote_version.version,
66
+ subver: peer.remote_version.user_agent,
67
+ inbound: !peer.outbound?,
68
+ startingheight: peer.remote_version.start_height,
69
+ best_hash: peer.best_hash,
70
+ best_height: peer.best_height
71
+ }
72
+ end
76
73
  end
77
74
 
78
75
  # broadcast transaction
@@ -212,14 +212,10 @@ module Tapyrus
212
212
  l, r = ems[0...(ems.length / 2)].htb, ems[(ems.length / 2)..-1].htb
213
213
  salt = get_salt(id)
214
214
  e = (Tapyrus::SLIP39::BASE_ITERATION_COUNT << exp) / Tapyrus::SLIP39::ROUND_COUNT
215
- Tapyrus::SLIP39::ROUND_COUNT
216
- .times
217
- .to_a
218
- .reverse
219
- .each do |i|
220
- f = OpenSSL::PKCS5.pbkdf2_hmac((i.itb + passphrase), salt + r, e, r.bytesize, 'sha256')
221
- l, r = padding_zero(r, r.bytesize), padding_zero((l.bti ^ f.bti).itb, r.bytesize)
222
- end
215
+ Tapyrus::SLIP39::ROUND_COUNT.times.to_a.reverse.each do |i|
216
+ f = OpenSSL::PKCS5.pbkdf2_hmac((i.itb + passphrase), salt + r, e, r.bytesize, 'sha256')
217
+ l, r = padding_zero(r, r.bytesize), padding_zero((l.bti ^ f.bti).itb, r.bytesize)
218
+ end
223
219
  (r + l).bth
224
220
  end
225
221
 
@@ -234,13 +230,10 @@ module Tapyrus
234
230
  l, r = s[0...(s.bytesize / 2)], s[(s.bytesize / 2)..-1]
235
231
  salt = get_salt(id)
236
232
  e = (Tapyrus::SLIP39::BASE_ITERATION_COUNT << exp) / Tapyrus::SLIP39::ROUND_COUNT
237
- Tapyrus::SLIP39::ROUND_COUNT
238
- .times
239
- .to_a
240
- .each do |i|
241
- f = OpenSSL::PKCS5.pbkdf2_hmac((i.itb + passphrase), salt + r, e, r.bytesize, 'sha256')
242
- l, r = padding_zero(r, r.bytesize), padding_zero((l.bti ^ f.bti).itb, r.bytesize)
243
- end
233
+ Tapyrus::SLIP39::ROUND_COUNT.times.to_a.each do |i|
234
+ f = OpenSSL::PKCS5.pbkdf2_hmac((i.itb + passphrase), salt + r, e, r.bytesize, 'sha256')
235
+ l, r = padding_zero(r, r.bytesize), padding_zero((l.bti ^ f.bti).itb, r.bytesize)
236
+ end
244
237
  (r + l).bth
245
238
  end
246
239
 
@@ -31,6 +31,8 @@ module Tapyrus
31
31
  # .build
32
32
  #
33
33
  class TxBuilder
34
+ attr_reader :outputs, :utxos
35
+
34
36
  def initialize
35
37
  @utxos = []
36
38
  @incomings = {}
@@ -1,3 +1,3 @@
1
1
  module Tapyrus
2
- VERSION = '0.2.10'
2
+ VERSION = '0.2.12'
3
3
  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.10
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa