sibit 0.21.3 → 0.21.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +1 -1
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/Rakefile +1 -1
- data/bin/sibit +1 -1
- data/features/step_definitions/steps.rb +1 -1
- data/features/support/env.rb +1 -1
- data/lib/sibit.rb +20 -4
- data/lib/sibit/bestof.rb +4 -2
- data/lib/sibit/bitcoinchain.rb +3 -2
- data/lib/sibit/blockchain.rb +3 -2
- data/lib/sibit/blockchair.rb +2 -2
- data/lib/sibit/btc.rb +4 -3
- data/lib/sibit/cex.rb +2 -2
- data/lib/sibit/cryptoapis.rb +3 -2
- data/lib/sibit/earn.rb +2 -2
- data/lib/sibit/error.rb +2 -2
- data/lib/sibit/fake.rb +3 -2
- data/lib/sibit/firstof.rb +4 -2
- data/lib/sibit/http.rb +2 -2
- data/lib/sibit/json.rb +4 -2
- data/lib/sibit/log.rb +2 -2
- data/lib/sibit/version.rb +3 -3
- data/sibit.gemspec +1 -1
- data/test/test__helper.rb +1 -1
- data/test/test_bestof.rb +2 -2
- data/test/test_bitcoinchain.rb +2 -2
- data/test/test_blockchain.rb +2 -2
- data/test/test_blockchair.rb +2 -2
- data/test/test_btc.rb +2 -2
- data/test/test_cex.rb +2 -2
- data/test/test_cryptoapis.rb +2 -2
- data/test/test_fake.rb +3 -3
- data/test/test_firstof.rb +2 -2
- data/test/test_json.rb +2 -2
- data/test/test_live.rb +2 -2
- data/test/test_sibit.rb +4 -3
- 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: 683996e02ea2ff93aa4bb8e97d369bcd087ba8eb5ebac2cdb8e7df21965c01b1
|
4
|
+
data.tar.gz: bbb58ae9442fc83a81a2008e0812959bd0d5895e454519fee13566c1663a51e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec3ace5b68abc1eefbbf6f3e86067c83c48d709ff418b956a3032bb8c0c5482a01e8f1ba258d640e975a67ab95bd1c805eb9e3308b1416f83e8f77fd2fc5d05d
|
7
|
+
data.tar.gz: cc63682837655ec6f790b4d108fd13d35d07eff5c72b40da164c791e5b39f4b8ef799310ff221843da7803773353cacd9dbfeeb9088a9fee4e22194ddea3dd16
|
data/.simplecov
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/bin/sibit
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Copyright (c) 2019-
|
4
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/features/support/env.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/lib/sibit.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative 'sibit/blockchain'
|
|
28
28
|
# Sibit main class.
|
29
29
|
#
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class Sibit
|
34
34
|
# Constructor.
|
@@ -55,6 +55,7 @@ class Sibit
|
|
55
55
|
|
56
56
|
# Current price of 1 BTC in USD (or another currency), float returned.
|
57
57
|
def price(currency = 'USD')
|
58
|
+
raise Error, "Invalid currency #{currency.inspect}" unless /^[A-Z]{3}$/.match?(currency)
|
58
59
|
@api.price(currency)
|
59
60
|
end
|
60
61
|
|
@@ -74,16 +75,19 @@ class Sibit
|
|
74
75
|
|
75
76
|
# Gets the balance of the address, in satoshi.
|
76
77
|
def balance(address)
|
78
|
+
raise Error, "Invalid address #{address.inspect}" unless /^[0-9a-zA-Z]+$/.match?(address)
|
77
79
|
@api.balance(address)
|
78
80
|
end
|
79
81
|
|
80
82
|
# Get the height of the block.
|
81
83
|
def height(hash)
|
84
|
+
raise Error, "Invalid block hash #{hash.inspect}" unless /^[0-9a-f]{64}$/.match?(hash)
|
82
85
|
@api.height(hash)
|
83
86
|
end
|
84
87
|
|
85
88
|
# Get the hash of the next block.
|
86
89
|
def next_of(hash)
|
90
|
+
raise Error, "Invalid block hash #{hash.inspect}" unless /^[0-9a-f]{64}$/.match?(hash)
|
87
91
|
@api.next_of(hash)
|
88
92
|
end
|
89
93
|
|
@@ -182,6 +186,8 @@ class Sibit
|
|
182
186
|
# in satoshi. The callback should return non-false if the transaction
|
183
187
|
# found was useful.
|
184
188
|
def scan(start, max: 4)
|
189
|
+
raise Error, "Invalid block hash #{start.inspect}" unless /^[0-9a-f]{64}$/.match?(start)
|
190
|
+
raise Error, "The max number must be above zero: #{max}" if max < 1
|
185
191
|
block = start
|
186
192
|
count = 0
|
187
193
|
wrong = []
|
@@ -215,10 +221,20 @@ class Sibit
|
|
215
221
|
checked += 1
|
216
222
|
end
|
217
223
|
count += 1
|
218
|
-
@log.info("We checked #{checked} txns and #{checked_outputs} outputs
|
224
|
+
@log.info("We checked #{checked} txns and #{checked_outputs} outputs \
|
225
|
+
in block #{block} (by #{json[:provider]})")
|
219
226
|
block = json[:next]
|
227
|
+
begin
|
228
|
+
if block.nil?
|
229
|
+
@log.info("The next_block is empty in #{json[:hash]}, this may be the end...")
|
230
|
+
block = @api.next_of(json[:hash])
|
231
|
+
end
|
232
|
+
rescue Sibit::Error => e
|
233
|
+
@log.info("Failed to get the next_of(#{json[:hash]}), quitting: #{e.message}")
|
234
|
+
break
|
235
|
+
end
|
220
236
|
if block.nil?
|
221
|
-
@log.info("The
|
237
|
+
@log.info("The block #{json[:hash]} is definitely the end of Blockchain, we stop.")
|
222
238
|
break
|
223
239
|
end
|
224
240
|
if count > max
|
data/lib/sibit/bestof.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative 'log'
|
|
27
27
|
# API best of.
|
28
28
|
#
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
30
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class Sibit
|
33
33
|
# Best of API.
|
@@ -107,6 +107,8 @@ class Sibit
|
|
107
107
|
errors = []
|
108
108
|
@list.each do |api|
|
109
109
|
results << yield(api)
|
110
|
+
rescue Sibit::NotSupportedError
|
111
|
+
# Just ignore it
|
110
112
|
rescue Sibit::Error => e
|
111
113
|
errors << e
|
112
114
|
@log.info("The API #{api.class.name} failed at #{method}(): #{e.message}") if @verbose
|
data/lib/sibit/bitcoinchain.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -32,7 +32,7 @@ require_relative 'version'
|
|
32
32
|
# Bitcoinchain.com API.
|
33
33
|
#
|
34
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
|
-
# Copyright:: Copyright (c) 2019-
|
35
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
36
36
|
# License:: MIT
|
37
37
|
class Sibit
|
38
38
|
# Btc.com API.
|
@@ -121,6 +121,7 @@ class Sibit
|
|
121
121
|
nxt = head['next_block']
|
122
122
|
nxt = nil if nxt == '0000000000000000000000000000000000000000000000000000000000000000'
|
123
123
|
{
|
124
|
+
provider: self.class.name,
|
124
125
|
hash: head['hash'],
|
125
126
|
orphan: !head['is_main'],
|
126
127
|
next: nxt,
|
data/lib/sibit/blockchain.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -35,7 +35,7 @@ require_relative 'version'
|
|
35
35
|
# https://www.blockchain.com/api/blockchain_api
|
36
36
|
#
|
37
37
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
38
|
-
# Copyright:: Copyright (c) 2019-
|
38
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
39
39
|
# License:: MIT
|
40
40
|
class Sibit
|
41
41
|
# Blockchain.info API.
|
@@ -139,6 +139,7 @@ class Sibit
|
|
139
139
|
Iri.new('https://blockchain.info/rawblock').append(hash)
|
140
140
|
)
|
141
141
|
{
|
142
|
+
provider: self.class.name,
|
142
143
|
hash: json['hash'],
|
143
144
|
orphan: !json['main_chain'],
|
144
145
|
next: json['next_block'][0],
|
data/lib/sibit/blockchair.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -33,7 +33,7 @@ require_relative 'version'
|
|
33
33
|
# Blockchair.com API.
|
34
34
|
#
|
35
35
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
36
|
-
# Copyright:: Copyright (c) 2019-
|
36
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
37
37
|
# License:: MIT
|
38
38
|
class Sibit
|
39
39
|
# Btc.com API.
|
data/lib/sibit/btc.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -34,7 +34,7 @@ require_relative 'version'
|
|
34
34
|
# Here: https://btc.com/api-doc
|
35
35
|
#
|
36
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
|
-
# Copyright:: Copyright (c) 2019-
|
37
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
38
38
|
# License:: MIT
|
39
39
|
class Sibit
|
40
40
|
# Btc.com API.
|
@@ -74,7 +74,7 @@ class Sibit
|
|
74
74
|
balance
|
75
75
|
end
|
76
76
|
|
77
|
-
# Get hash of the block after this one.
|
77
|
+
# Get hash of the block after this one, or NIL if it's the last one in Blockchain.
|
78
78
|
def next_of(hash)
|
79
79
|
head = Sibit::Json.new(http: @http, log: @log).get(
|
80
80
|
Iri.new('https://chain.api.btc.com/v3/block').append(hash)
|
@@ -162,6 +162,7 @@ class Sibit
|
|
162
162
|
nxt = data['next_block_hash']
|
163
163
|
nxt = nil if nxt == '0000000000000000000000000000000000000000000000000000000000000000'
|
164
164
|
{
|
165
|
+
provider: self.class.name,
|
165
166
|
hash: data['hash'],
|
166
167
|
orphan: data['is_orphan'],
|
167
168
|
next: nxt,
|
data/lib/sibit/cex.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -30,7 +30,7 @@ require_relative 'json'
|
|
30
30
|
# Cex.io API.
|
31
31
|
#
|
32
32
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
33
|
-
# Copyright:: Copyright (c) 2019-
|
33
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
34
34
|
# License:: MIT
|
35
35
|
class Sibit
|
36
36
|
# Btc.com API.
|
data/lib/sibit/cryptoapis.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -32,7 +32,7 @@ require_relative 'version'
|
|
32
32
|
# Cryptoapis.io API.
|
33
33
|
#
|
34
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
|
-
# Copyright:: Copyright (c) 2019-
|
35
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
36
36
|
# License:: MIT
|
37
37
|
class Sibit
|
38
38
|
# Btc.com API.
|
@@ -119,6 +119,7 @@ class Sibit
|
|
119
119
|
headers: headers
|
120
120
|
)['payload']
|
121
121
|
{
|
122
|
+
provider: self.class.name,
|
122
123
|
hash: head['hash'],
|
123
124
|
orphan: false,
|
124
125
|
next: head['nextblockhash'],
|
data/lib/sibit/earn.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -31,7 +31,7 @@ require_relative 'version'
|
|
31
31
|
# Earn.com API.
|
32
32
|
#
|
33
33
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
34
|
-
# Copyright:: Copyright (c) 2019-
|
34
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
35
35
|
# License:: MIT
|
36
36
|
class Sibit
|
37
37
|
# Blockchain.info API.
|
data/lib/sibit/error.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -23,7 +23,7 @@
|
|
23
23
|
# The error.
|
24
24
|
#
|
25
25
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
-
# Copyright:: Copyright (c) 2019-
|
26
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
27
27
|
# License:: MIT
|
28
28
|
class Sibit
|
29
29
|
# The error.
|
data/lib/sibit/fake.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@ require_relative 'version'
|
|
25
25
|
# Fake API.
|
26
26
|
#
|
27
27
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
28
|
-
# Copyright:: Copyright (c) 2019-
|
28
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
29
29
|
# License:: MIT
|
30
30
|
class Sibit
|
31
31
|
# Fake API
|
@@ -64,6 +64,7 @@ class Sibit
|
|
64
64
|
|
65
65
|
def block(hash)
|
66
66
|
{
|
67
|
+
provider: self.class.name,
|
67
68
|
hash: hash,
|
68
69
|
orphan: false,
|
69
70
|
next: hash,
|
data/lib/sibit/firstof.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative 'log'
|
|
27
27
|
# API first of.
|
28
28
|
#
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
30
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class Sibit
|
33
33
|
# First of API.
|
@@ -112,6 +112,8 @@ class Sibit
|
|
112
112
|
result = yield api
|
113
113
|
done = true
|
114
114
|
break
|
115
|
+
rescue Sibit::NotSupportedError
|
116
|
+
# Just ignore it
|
115
117
|
rescue Sibit::Error => e
|
116
118
|
errors << e
|
117
119
|
@log.info("The API #{api.class.name} failed at #{method}(): #{e.message}") if @verbose
|
data/lib/sibit/http.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@ require 'net/http'
|
|
25
25
|
# HTTP interface.
|
26
26
|
#
|
27
27
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
28
|
-
# Copyright:: Copyright (c) 2019-
|
28
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
29
29
|
# License:: MIT
|
30
30
|
class Sibit
|
31
31
|
# This HTTP client will be used by default.
|
data/lib/sibit/json.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -34,7 +34,7 @@ require_relative 'log'
|
|
34
34
|
# https://www.blockchain.com/api/blockchain_api
|
35
35
|
#
|
36
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
|
-
# Copyright:: Copyright (c) 2019-
|
37
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
38
38
|
# License:: MIT
|
39
39
|
class Sibit
|
40
40
|
# JSON processing.
|
@@ -65,6 +65,8 @@ class Sibit
|
|
65
65
|
end
|
66
66
|
@log.info("GET #{uri}: #{res.code}/#{length(res.body.length)} in #{age(start)}")
|
67
67
|
JSON.parse(res.body)
|
68
|
+
rescue JSON::ParserError => e
|
69
|
+
raise Sibit::Error, "Can't parse JSON: #{e.message}"
|
68
70
|
end
|
69
71
|
|
70
72
|
def post(address, body, headers: {})
|
data/lib/sibit/log.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -23,7 +23,7 @@
|
|
23
23
|
# The log.
|
24
24
|
#
|
25
25
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
-
# Copyright:: Copyright (c) 2019-
|
26
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
27
27
|
# License:: MIT
|
28
28
|
class Sibit
|
29
29
|
# Log.
|
data/lib/sibit/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
# Sibit main class.
|
24
24
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
25
|
-
# Copyright:: Copyright (c) 2019-
|
25
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
26
26
|
# License:: MIT
|
27
27
|
class Sibit
|
28
28
|
# Current version of the library.
|
29
|
-
VERSION = '0.21.
|
29
|
+
VERSION = '0.21.8'
|
30
30
|
end
|
data/sibit.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/test__helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/test_bestof.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative '../lib/sibit/bestof'
|
|
27
27
|
|
28
28
|
# Sibit::BestOf test.
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
30
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class TestBestOf < Minitest::Test
|
33
33
|
def test_not_array
|
data/test/test_bitcoinchain.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit/bitcoinchain'
|
|
28
28
|
|
29
29
|
# Sibit::Bitcoinchain test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestBitcoinchain < Minitest::Test
|
34
34
|
def test_fetch_hash
|
data/test/test_blockchain.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit/blockchain'
|
|
28
28
|
|
29
29
|
# Sibit::Blockchain test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestBlockchain < Minitest::Test
|
34
34
|
def test_fetch_block
|
data/test/test_blockchair.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit/blockchair'
|
|
28
28
|
|
29
29
|
# Sibit::Blockchair test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestBlockchair < Minitest::Test
|
34
34
|
def test_fetch_balance
|
data/test/test_btc.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit/btc'
|
|
28
28
|
|
29
29
|
# Sibit::Btc test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestBtc < Minitest::Test
|
34
34
|
def test_get_zero_balance
|
data/test/test_cex.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit/cex'
|
|
28
28
|
|
29
29
|
# Sibit::Cex test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestBtc < Minitest::Test
|
34
34
|
def test_get_price
|
data/test/test_cryptoapis.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit/cryptoapis'
|
|
28
28
|
|
29
29
|
# Sibit::Cryptoapis test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestCryptoapis < Minitest::Test
|
34
34
|
def test_fetch_block
|
data/test/test_fake.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative '../lib/sibit/fake'
|
|
27
27
|
|
28
28
|
# Sibit::Fake test.
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
30
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class TestFake < Minitest::Test
|
33
33
|
def test_fake_object_works
|
@@ -41,7 +41,7 @@ class TestFake < Minitest::Test
|
|
41
41
|
|
42
42
|
def test_scan_works
|
43
43
|
sibit = Sibit.new(api: Sibit::Fake.new)
|
44
|
-
hash = '
|
44
|
+
hash = '00000000000000000008df8a6e1b61d1136803ac9791b8725235c9f780b4ed71'
|
45
45
|
found = false
|
46
46
|
tail = sibit.scan(hash) do |addr, tx, satoshi|
|
47
47
|
assert_equal(1000, satoshi)
|
data/test/test_firstof.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative '../lib/sibit/firstof'
|
|
27
27
|
|
28
28
|
# Sibit::FirstOf test.
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
30
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class TestFirstOf < Minitest::Test
|
33
33
|
def test_not_array
|
data/test/test_json.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative '../lib/sibit/json'
|
|
27
27
|
|
28
28
|
# Sibit::Json test.
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
30
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class TestJson < Minitest::Test
|
33
33
|
def test_loads_hash
|
data/test/test_live.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/sibit'
|
|
28
28
|
|
29
29
|
# Live tests.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2019-
|
31
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class TestLive < Minitest::Test
|
34
34
|
def test_block
|
data/test/test_sibit.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
3
|
+
# Copyright (c) 2019-2021 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -32,7 +32,7 @@ require_relative '../lib/sibit/bestof'
|
|
32
32
|
|
33
33
|
# Sibit.
|
34
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
|
-
# Copyright:: Copyright (c) 2019-
|
35
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
36
36
|
# License:: MIT
|
37
37
|
class TestSibit < Minitest::Test
|
38
38
|
def test_loads_fees
|
@@ -196,7 +196,8 @@ class TestSibit < Minitest::Test
|
|
196
196
|
end
|
197
197
|
sibit = Sibit.new(api: api)
|
198
198
|
found = false
|
199
|
-
|
199
|
+
start = '00000000000000000008df8a6e1b61d1136803ac9791b8725235c9f780b4ed71'
|
200
|
+
tail = sibit.scan(start) do |addr, tx, satoshi|
|
200
201
|
assert_equal(123, satoshi)
|
201
202
|
assert_equal('addr', addr)
|
202
203
|
assert_equal('hash:0', tx)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sibit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.
|
4
|
+
version: 0.21.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|