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 +4 -4
- data/lib/tapyrus/bip175.rb +12 -1
- data/lib/tapyrus/rpc/request_handler.rb +23 -26
- data/lib/tapyrus/slip39/sss.rb +8 -15
- data/lib/tapyrus/tx_builder.rb +2 -0
- data/lib/tapyrus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9619b8bb901abe7085cedda9ca2ed29efb41281125bca6cfe2fd68facf7fc280
|
4
|
+
data.tar.gz: a1f1d5544976189606b024ce064bdf794d01f646c4ae9b727ff278d071ddb4ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '05187916624701c58d88d53bc78ddc576de97ddb1b5b3c5a9066093a57256bad53f8f86c2b126e74db36af4ae5a5ddfd3eb6f9a966672c48f45571e2c60aec61'
|
7
|
+
data.tar.gz: db6dc58cc66b4a5e754a21a26738d37af025f81f8c3c1b29635218ec685636250a22d55bc9d953e62203289524fd89640bf5951fba245712c6ba8a2b2fb7673c
|
data/lib/tapyrus/bip175.rb
CHANGED
@@ -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
|
-
.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
data/lib/tapyrus/slip39/sss.rb
CHANGED
@@ -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
|
-
.
|
217
|
-
.
|
218
|
-
|
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
|
-
.
|
239
|
-
.
|
240
|
-
|
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
|
|
data/lib/tapyrus/tx_builder.rb
CHANGED
data/lib/tapyrus/version.rb
CHANGED
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
|
+
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:
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa
|