peatio-bitgo 2.5.1 → 2.6.0
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 +4 -4
- data/Gemfile.lock +32 -32
- data/lib/peatio/bitgo/client.rb +1 -3
- data/lib/peatio/bitgo/version.rb +1 -1
- data/lib/peatio/bitgo/wallet.rb +19 -52
- 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: 274572ccfc7d17e3150b4271d2872fda747aff0684a50e21c8bb74382e0c437f
|
|
4
|
+
data.tar.gz: f90adec7c757956565af265400011033a73902348ee1a1d98393ea51e83e2ab1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58ec57b436b4e5d43d71d3b6db335e36cb4e0c49fac46a9495c2bfdfc1bcf3909577ba1367641bc3a3357adb2779bb515270d285662fdfa9ed0cef62526c49b7
|
|
7
|
+
data.tar.gz: 8fc3e3d276680e91140264bc3ab9d32648632598484dd23ddebdb36d4b79612eb14a585d902ac12585a8b92831e4db4712b3d6444e6ef0ed12c932fab98ae71a
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
peatio-bitgo (2.
|
|
4
|
+
peatio-bitgo (2.6.0)
|
|
5
5
|
activesupport (~> 5.2.3)
|
|
6
6
|
better-faraday (~> 1.0.5)
|
|
7
7
|
faraday (~> 0.17)
|
|
@@ -12,35 +12,35 @@ PATH
|
|
|
12
12
|
GEM
|
|
13
13
|
remote: https://rubygems.org/
|
|
14
14
|
specs:
|
|
15
|
-
activemodel (5.2.4.
|
|
16
|
-
activesupport (= 5.2.4.
|
|
17
|
-
activesupport (5.2.4.
|
|
15
|
+
activemodel (5.2.4.2)
|
|
16
|
+
activesupport (= 5.2.4.2)
|
|
17
|
+
activesupport (5.2.4.2)
|
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
19
19
|
i18n (>= 0.7, < 2)
|
|
20
20
|
minitest (~> 5.1)
|
|
21
21
|
tzinfo (~> 1.1)
|
|
22
22
|
addressable (2.7.0)
|
|
23
23
|
public_suffix (>= 2.0.2, < 5.0)
|
|
24
|
-
amq-protocol (2.3.
|
|
24
|
+
amq-protocol (2.3.1)
|
|
25
25
|
amqp (1.8.0)
|
|
26
26
|
amq-protocol (>= 2.2.0)
|
|
27
27
|
eventmachine
|
|
28
28
|
better-faraday (1.0.8)
|
|
29
29
|
activesupport (>= 4.0, < 6.0)
|
|
30
30
|
faraday (~> 0.12)
|
|
31
|
-
bunny (2.
|
|
31
|
+
bunny (2.15.0)
|
|
32
32
|
amq-protocol (~> 2.3, >= 2.3.1)
|
|
33
|
-
byebug (11.1.
|
|
34
|
-
clamp (1.3.
|
|
35
|
-
coderay (1.1.
|
|
36
|
-
concurrent-ruby (1.1.
|
|
37
|
-
connection_pool (2.2.
|
|
33
|
+
byebug (11.1.1)
|
|
34
|
+
clamp (1.3.1)
|
|
35
|
+
coderay (1.1.2)
|
|
36
|
+
concurrent-ruby (1.1.6)
|
|
37
|
+
connection_pool (2.2.2)
|
|
38
38
|
cookiejar (0.3.3)
|
|
39
39
|
crack (0.4.3)
|
|
40
40
|
safe_yaml (~> 1.0.0)
|
|
41
41
|
daemons (1.3.1)
|
|
42
|
-
diff-lcs (1.
|
|
43
|
-
em-http-request (1.1.
|
|
42
|
+
diff-lcs (1.3)
|
|
43
|
+
em-http-request (1.1.5)
|
|
44
44
|
addressable (>= 2.3.4)
|
|
45
45
|
cookiejar (!= 0.3.1)
|
|
46
46
|
em-socksify (>= 0.3)
|
|
@@ -58,32 +58,32 @@ GEM
|
|
|
58
58
|
multipart-post (>= 1.2, < 3)
|
|
59
59
|
faraday_middleware (0.13.1)
|
|
60
60
|
faraday (>= 0.7.4, < 1.0)
|
|
61
|
-
faye (1.
|
|
61
|
+
faye (1.2.5)
|
|
62
62
|
cookiejar (>= 0.3.0)
|
|
63
|
-
em-http-request (>=
|
|
63
|
+
em-http-request (>= 0.3.0)
|
|
64
64
|
eventmachine (>= 0.12.0)
|
|
65
|
-
faye-websocket (>= 0.
|
|
65
|
+
faye-websocket (>= 0.9.1)
|
|
66
66
|
multi_json (>= 1.0.0)
|
|
67
67
|
rack (>= 1.0.0)
|
|
68
68
|
websocket-driver (>= 0.5.1)
|
|
69
|
-
faye-websocket (0.
|
|
69
|
+
faye-websocket (0.10.9)
|
|
70
70
|
eventmachine (>= 0.12.0)
|
|
71
71
|
websocket-driver (>= 0.5.1)
|
|
72
72
|
hashdiff (1.0.1)
|
|
73
73
|
http_parser.rb (0.6.0)
|
|
74
|
-
i18n (1.8.
|
|
74
|
+
i18n (1.8.2)
|
|
75
75
|
concurrent-ruby (~> 1.0)
|
|
76
|
-
jwt (2.2.
|
|
76
|
+
jwt (2.2.1)
|
|
77
77
|
memoist (0.16.2)
|
|
78
78
|
method_source (1.0.0)
|
|
79
|
-
minitest (5.14.
|
|
79
|
+
minitest (5.14.0)
|
|
80
80
|
mocha (1.11.2)
|
|
81
|
-
multi_json (1.
|
|
81
|
+
multi_json (1.14.1)
|
|
82
82
|
multipart-post (2.1.1)
|
|
83
83
|
mysql2 (0.5.3)
|
|
84
84
|
net-http-persistent (3.0.1)
|
|
85
85
|
connection_pool (~> 2.2)
|
|
86
|
-
peatio (2.
|
|
86
|
+
peatio (2.4.4)
|
|
87
87
|
activemodel (> 5.2, <= 6.0.0)
|
|
88
88
|
amqp
|
|
89
89
|
bunny
|
|
@@ -97,29 +97,29 @@ GEM
|
|
|
97
97
|
mysql2
|
|
98
98
|
prometheus-client
|
|
99
99
|
thin
|
|
100
|
-
prometheus-client (2.
|
|
101
|
-
pry (0.13.
|
|
100
|
+
prometheus-client (2.0.0)
|
|
101
|
+
pry (0.13.0)
|
|
102
102
|
coderay (~> 1.1)
|
|
103
103
|
method_source (~> 1.0)
|
|
104
104
|
pry-byebug (3.9.0)
|
|
105
105
|
byebug (~> 11.0)
|
|
106
106
|
pry (~> 0.13.0)
|
|
107
|
-
public_suffix (4.0.
|
|
108
|
-
rack (2.2.
|
|
107
|
+
public_suffix (4.0.4)
|
|
108
|
+
rack (2.2.2)
|
|
109
109
|
rake (13.0.1)
|
|
110
110
|
rspec (3.9.0)
|
|
111
111
|
rspec-core (~> 3.9.0)
|
|
112
112
|
rspec-expectations (~> 3.9.0)
|
|
113
113
|
rspec-mocks (~> 3.9.0)
|
|
114
|
-
rspec-core (3.9.
|
|
115
|
-
rspec-support (~> 3.9.
|
|
116
|
-
rspec-expectations (3.9.
|
|
114
|
+
rspec-core (3.9.1)
|
|
115
|
+
rspec-support (~> 3.9.1)
|
|
116
|
+
rspec-expectations (3.9.1)
|
|
117
117
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
118
118
|
rspec-support (~> 3.9.0)
|
|
119
119
|
rspec-mocks (3.9.1)
|
|
120
120
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
121
121
|
rspec-support (~> 3.9.0)
|
|
122
|
-
rspec-support (3.9.
|
|
122
|
+
rspec-support (3.9.2)
|
|
123
123
|
safe_yaml (1.0.5)
|
|
124
124
|
thin (1.7.2)
|
|
125
125
|
daemons (~> 1.0, >= 1.0.9)
|
|
@@ -132,9 +132,9 @@ GEM
|
|
|
132
132
|
addressable (>= 2.3.6)
|
|
133
133
|
crack (>= 0.3.2)
|
|
134
134
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
135
|
-
websocket-driver (0.7.
|
|
135
|
+
websocket-driver (0.7.1)
|
|
136
136
|
websocket-extensions (>= 0.1.0)
|
|
137
|
-
websocket-extensions (0.1.
|
|
137
|
+
websocket-extensions (0.1.4)
|
|
138
138
|
|
|
139
139
|
PLATFORMS
|
|
140
140
|
ruby
|
data/lib/peatio/bitgo/client.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Peatio
|
|
|
5
5
|
module Bitgo
|
|
6
6
|
class Client
|
|
7
7
|
Error = Class.new(StandardError)
|
|
8
|
-
|
|
8
|
+
ConnectionError = Class.new(Error)
|
|
9
9
|
|
|
10
10
|
class ResponseError < Error
|
|
11
11
|
def initialize(msg)
|
|
@@ -48,8 +48,6 @@ module Peatio
|
|
|
48
48
|
else
|
|
49
49
|
raise ConnectionError, JSON.parse(e.response.body)['message']
|
|
50
50
|
end
|
|
51
|
-
rescue StandardError => e
|
|
52
|
-
raise Error, e
|
|
53
51
|
end
|
|
54
52
|
end
|
|
55
53
|
end
|
data/lib/peatio/bitgo/version.rb
CHANGED
data/lib/peatio/bitgo/wallet.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
module Peatio
|
|
2
2
|
module Bitgo
|
|
3
3
|
class Wallet < Peatio::Wallet::Abstract
|
|
4
|
-
TIME_DIFFERENCE_IN_MINUTES = 10
|
|
5
|
-
XLM_MEMO_TYPES = { 'memoId': 'id', 'memoText': 'text', 'memoHash': 'hash', 'memoReturn': 'return' }
|
|
6
4
|
|
|
7
5
|
def initialize(settings = {})
|
|
8
6
|
@settings = settings
|
|
@@ -26,14 +24,10 @@ module Peatio
|
|
|
26
24
|
def create_address!(options = {})
|
|
27
25
|
currency = erc20_currency_id
|
|
28
26
|
options.deep_symbolize_keys!
|
|
29
|
-
|
|
30
|
-
if options.dig(:pa_details, :address_id).present? &&
|
|
31
|
-
options.dig(:pa_details, :updated_at).present? &&
|
|
32
|
-
time_difference_in_minutes(options.dig(:pa_details, :updated_at)) >= TIME_DIFFERENCE_IN_MINUTES
|
|
33
|
-
|
|
27
|
+
if options.dig(:pa_details,:address_id).present?
|
|
34
28
|
response = client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{options.dig(:pa_details, :address_id)}")
|
|
35
29
|
{ address: response['address'], secret: bitgo_wallet_passphrase }
|
|
36
|
-
|
|
30
|
+
else
|
|
37
31
|
response = client.rest_api(:post, "#{currency}/wallet/#{wallet_id}/address")
|
|
38
32
|
{ address: response['address'], secret: bitgo_wallet_passphrase, details: { address_id: response['id'] }}
|
|
39
33
|
end
|
|
@@ -58,7 +52,7 @@ module Peatio
|
|
|
58
52
|
end
|
|
59
53
|
|
|
60
54
|
txid = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
|
|
61
|
-
address:
|
|
55
|
+
address: transaction.to_address.to_s,
|
|
62
56
|
amount: amount.to_s,
|
|
63
57
|
walletPassphrase: bitgo_wallet_passphrase,
|
|
64
58
|
memo: xlm_memo(transaction.to_address.to_s)
|
|
@@ -117,15 +111,14 @@ module Peatio
|
|
|
117
111
|
end
|
|
118
112
|
|
|
119
113
|
def trigger_webhook_event(event)
|
|
120
|
-
|
|
121
|
-
return unless
|
|
114
|
+
currency_id = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
|
|
115
|
+
return unless currency_id == event['coin'] && @wallet.fetch(:wallet_id) == event['wallet']
|
|
122
116
|
|
|
123
117
|
if event['type'] == 'transfer'
|
|
124
118
|
transactions = fetch_transfer!(event['transfer'])
|
|
125
119
|
return { transfers: transactions }
|
|
126
|
-
elsif event['
|
|
127
|
-
|
|
128
|
-
return { address_id: address_id, currency_id: currency_id }
|
|
120
|
+
elsif event['address_confirmation']
|
|
121
|
+
# TODO Add Address confirmation
|
|
129
122
|
end
|
|
130
123
|
end
|
|
131
124
|
|
|
@@ -134,14 +127,6 @@ module Peatio
|
|
|
134
127
|
address_confirmation_webhook(url)
|
|
135
128
|
end
|
|
136
129
|
|
|
137
|
-
def fetch_address_id(address)
|
|
138
|
-
currency = erc20_currency_id
|
|
139
|
-
client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{address}")
|
|
140
|
-
.fetch('id')
|
|
141
|
-
rescue Bitgo::Client::Error => e
|
|
142
|
-
raise Peatio::Wallet::ClientError, e
|
|
143
|
-
end
|
|
144
|
-
|
|
145
130
|
def fetch_transfer!(id)
|
|
146
131
|
# TODO: Add Rspecs for this one
|
|
147
132
|
response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
|
|
@@ -184,7 +169,7 @@ module Peatio
|
|
|
184
169
|
|
|
185
170
|
def address_confirmation_webhook(url)
|
|
186
171
|
client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
|
|
187
|
-
type: '
|
|
172
|
+
type: 'address_confirmation_webhook',
|
|
188
173
|
allToken: true,
|
|
189
174
|
url: url,
|
|
190
175
|
label: "webhook for #{url}",
|
|
@@ -222,25 +207,19 @@ module Peatio
|
|
|
222
207
|
end
|
|
223
208
|
|
|
224
209
|
def xlm_memo(address)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
when 'memoId'
|
|
231
|
-
memo_value_from(address, 'memoId')
|
|
232
|
-
when 'memoText'
|
|
233
|
-
memo_value_from(address, 'memoText')
|
|
234
|
-
when 'memoHash'
|
|
235
|
-
memo_value_from(address, 'memoHash')
|
|
236
|
-
when 'memoReturn'
|
|
237
|
-
memo_value_from(address, 'memoReturn')
|
|
210
|
+
if @currency.fetch(:id) == 'xlm'
|
|
211
|
+
{
|
|
212
|
+
type: "id",
|
|
213
|
+
value: "#{memo_id_from(address)}"
|
|
214
|
+
}
|
|
238
215
|
end
|
|
239
216
|
end
|
|
240
217
|
|
|
241
|
-
def
|
|
242
|
-
|
|
243
|
-
|
|
218
|
+
def memo_id_from(address)
|
|
219
|
+
memo_id = address.partition('memoId=').last
|
|
220
|
+
memo_id = 0 if memo_id.empty?
|
|
221
|
+
|
|
222
|
+
memo_id
|
|
244
223
|
end
|
|
245
224
|
|
|
246
225
|
def currency_id
|
|
@@ -255,14 +234,6 @@ module Peatio
|
|
|
255
234
|
@wallet.fetch(:wallet_id)
|
|
256
235
|
end
|
|
257
236
|
|
|
258
|
-
def normalize_address(address)
|
|
259
|
-
if @currency.fetch(:id) == 'xlm'
|
|
260
|
-
address.split('?').first
|
|
261
|
-
else
|
|
262
|
-
address
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
|
|
266
237
|
def normalize_txid(txid)
|
|
267
238
|
txid.downcase
|
|
268
239
|
end
|
|
@@ -281,13 +252,9 @@ module Peatio
|
|
|
281
252
|
x.to_i
|
|
282
253
|
end
|
|
283
254
|
|
|
284
|
-
def time_difference_in_minutes(updated_at)
|
|
285
|
-
(Time.now - updated_at)/60
|
|
286
|
-
end
|
|
287
|
-
|
|
288
255
|
def define_transaction_state(state)
|
|
289
256
|
case state
|
|
290
|
-
when '
|
|
257
|
+
when 'unconfrimed'
|
|
291
258
|
'pending'
|
|
292
259
|
when 'confirmed'
|
|
293
260
|
'success'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: peatio-bitgo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nadia Ch., Maksym N.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-05-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|