sibit 0.21.2 → 0.21.7
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 +15 -4
- data/lib/sibit/bestof.rb +4 -2
- data/lib/sibit/bitcoinchain.rb +12 -10
- data/lib/sibit/blockchain.rb +13 -11
- data/lib/sibit/blockchair.rb +9 -8
- data/lib/sibit/btc.rb +18 -15
- data/lib/sibit/cex.rb +3 -3
- data/lib/sibit/cryptoapis.rb +15 -17
- data/lib/sibit/earn.rb +5 -4
- 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 +8 -4
- data/lib/sibit/log.rb +2 -2
- data/lib/sibit/version.rb +3 -3
- data/sibit.gemspec +2 -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 +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50666b6edfe2a5cfe5020fe7e2457b2b79ef3675960d5f3d36f6fc977462d05b
|
4
|
+
data.tar.gz: 6abb381f5b710c959cecc339d1a0070b6925a14e4bb43652e3f7d9248ca5278e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce15881b3d8f273868c58edb6a95b75782115193ee0b96d6a621eb4df9d7df692c0bee5439f509ca76ee0e3305d55ed438d23b67edd4f5e49d6bf1227b747ba3
|
7
|
+
data.tar.gz: d299a4f555b8723176c78dbf47c97c7cd02e0cc6c85d51c72b1dc244745d4d6ad74c343cd93266eb805fc1a234ed75548ccc9ffdfee2e5825b857d61a4321514
|
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,15 @@ 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]
|
220
227
|
if block.nil?
|
221
|
-
@log.info("The next_block is empty in
|
228
|
+
@log.info("The next_block is empty in #{json[:hash]}, this may be the end of Blockchain...")
|
229
|
+
block = @api.next_of(json[:hash])
|
230
|
+
end
|
231
|
+
if block.nil?
|
232
|
+
@log.info("The block #{json[:hash]} is definitely the end of Blockchain, we stop.")
|
222
233
|
break
|
223
234
|
end
|
224
235
|
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
|
@@ -20,18 +20,19 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
require '
|
23
|
+
require 'iri'
|
24
24
|
require 'json'
|
25
|
-
|
25
|
+
require 'uri'
|
26
26
|
require_relative 'error'
|
27
|
-
require_relative 'log'
|
28
27
|
require_relative 'http'
|
29
28
|
require_relative 'json'
|
29
|
+
require_relative 'log'
|
30
|
+
require_relative 'version'
|
30
31
|
|
31
32
|
# Bitcoinchain.com API.
|
32
33
|
#
|
33
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
34
|
-
# Copyright:: Copyright (c) 2019-
|
35
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
35
36
|
# License:: MIT
|
36
37
|
class Sibit
|
37
38
|
# Btc.com API.
|
@@ -56,7 +57,7 @@ class Sibit
|
|
56
57
|
# Get hash of the block after this one.
|
57
58
|
def next_of(hash)
|
58
59
|
block = Sibit::Json.new(http: @http, log: @log).get(
|
59
|
-
|
60
|
+
Iri.new('https://api-r.bitcoinchain.com/v1/block').append(hash)
|
60
61
|
)[0]
|
61
62
|
raise Sibit::Error, "Block #{hash} not found" if block.nil?
|
62
63
|
nxt = block['next_block']
|
@@ -69,7 +70,7 @@ class Sibit
|
|
69
70
|
# Gets the balance of the address, in satoshi.
|
70
71
|
def balance(address)
|
71
72
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
72
|
-
|
73
|
+
Iri.new('https://api-r.bitcoinchain.com/v1/address').append(address),
|
73
74
|
accept: [200, 409]
|
74
75
|
)[0]
|
75
76
|
b = json['balance']
|
@@ -91,7 +92,7 @@ class Sibit
|
|
91
92
|
# Gets the hash of the latest block.
|
92
93
|
def latest
|
93
94
|
hash = Sibit::Json.new(http: @http, log: @log).get(
|
94
|
-
|
95
|
+
Iri.new('https://api-r.bitcoinchain.com/v1/status')
|
95
96
|
)['hash']
|
96
97
|
@log.info("The latest block hash is #{hash}")
|
97
98
|
hash
|
@@ -111,15 +112,16 @@ class Sibit
|
|
111
112
|
# an exception if the block is not found.
|
112
113
|
def block(hash)
|
113
114
|
head = Sibit::Json.new(http: @http, log: @log).get(
|
114
|
-
|
115
|
+
Iri.new('https://api-r.bitcoinchain.com/v1/block').append(hash)
|
115
116
|
)[0]
|
116
117
|
raise Sibit::Error, "The block #{hash} is not found" if head.nil?
|
117
118
|
txs = Sibit::Json.new(http: @http, log: @log).get(
|
118
|
-
|
119
|
+
Iri.new('https://api-r.bitcoinchain.com/v1/block/txs').append(hash)
|
119
120
|
)
|
120
121
|
nxt = head['next_block']
|
121
122
|
nxt = nil if nxt == '0000000000000000000000000000000000000000000000000000000000000000'
|
122
123
|
{
|
124
|
+
provider: self.class.name,
|
123
125
|
hash: head['hash'],
|
124
126
|
orphan: !head['is_main'],
|
125
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
|
@@ -21,12 +21,13 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'bitcoin'
|
24
|
+
require 'iri'
|
24
25
|
require 'json'
|
25
26
|
require 'uri'
|
26
|
-
require_relative 'version'
|
27
27
|
require_relative 'error'
|
28
28
|
require_relative 'http'
|
29
29
|
require_relative 'json'
|
30
|
+
require_relative 'version'
|
30
31
|
|
31
32
|
# Blockchain.info API.
|
32
33
|
#
|
@@ -34,7 +35,7 @@ require_relative 'json'
|
|
34
35
|
# https://www.blockchain.com/api/blockchain_api
|
35
36
|
#
|
36
37
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
|
-
# Copyright:: Copyright (c) 2019-
|
38
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
38
39
|
# License:: MIT
|
39
40
|
class Sibit
|
40
41
|
# Blockchain.info API.
|
@@ -49,7 +50,7 @@ class Sibit
|
|
49
50
|
# Current price of BTC in USD (float returned).
|
50
51
|
def price(currency = 'USD')
|
51
52
|
h = Sibit::Json.new(http: @http, log: @log).get(
|
52
|
-
|
53
|
+
Iri.new('https://blockchain.info/ticker')
|
53
54
|
)[currency]
|
54
55
|
raise Error, "Unrecognized currency #{currency}" if h.nil?
|
55
56
|
price = h['15m']
|
@@ -61,7 +62,7 @@ class Sibit
|
|
61
62
|
def next_of(_hash)
|
62
63
|
raise Sibit::NotSupportedError, 'next_of() in Blockchain API is broken, always returns NULL'
|
63
64
|
# json = Sibit::Json.new(http: @http, log: @log).get(
|
64
|
-
#
|
65
|
+
# Iri.new('https://blockchain.info/rawblock').append(hash)
|
65
66
|
# )
|
66
67
|
# nxt = json['next_block'][0]
|
67
68
|
# if nxt.nil?
|
@@ -75,7 +76,7 @@ class Sibit
|
|
75
76
|
# The height of the block.
|
76
77
|
def height(hash)
|
77
78
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
78
|
-
|
79
|
+
Iri.new('https://blockchain.info/rawblock').append(hash)
|
79
80
|
)
|
80
81
|
h = json['height']
|
81
82
|
@log.info("The height of #{hash} is #{h}")
|
@@ -85,7 +86,7 @@ class Sibit
|
|
85
86
|
# Gets the balance of the address, in satoshi.
|
86
87
|
def balance(address)
|
87
88
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
88
|
-
|
89
|
+
Iri.new('https://blockchain.info/rawaddr').append(address).add(limit: 0),
|
89
90
|
accept: [200, 500]
|
90
91
|
)
|
91
92
|
b = json['final_balance']
|
@@ -102,7 +103,7 @@ class Sibit
|
|
102
103
|
# of Bitcoin addresses.
|
103
104
|
def utxos(sources)
|
104
105
|
Sibit::Json.new(http: @http, log: @log).get(
|
105
|
-
|
106
|
+
Iri.new('https://blockchain.info/unspent').add(active: sources.join('|'), limit: 1000)
|
106
107
|
)['unspent_outputs'].map do |u|
|
107
108
|
{
|
108
109
|
value: u['value'],
|
@@ -118,7 +119,7 @@ class Sibit
|
|
118
119
|
def push(hex)
|
119
120
|
return if @dry
|
120
121
|
Sibit::Json.new(http: @http, log: @log).post(
|
121
|
-
|
122
|
+
Iri.new('https://blockchain.info/pushtx'),
|
122
123
|
hex
|
123
124
|
)
|
124
125
|
end
|
@@ -126,7 +127,7 @@ class Sibit
|
|
126
127
|
# Gets the hash of the latest block.
|
127
128
|
def latest
|
128
129
|
hash = Sibit::Json.new(http: @http, log: @log).get(
|
129
|
-
|
130
|
+
Iri.new('https://blockchain.info/latestblock')
|
130
131
|
)['hash']
|
131
132
|
@log.info("The latest block hash is #{hash}")
|
132
133
|
hash
|
@@ -135,9 +136,10 @@ class Sibit
|
|
135
136
|
# This method should fetch a Blockchain block and return as a hash.
|
136
137
|
def block(hash)
|
137
138
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
138
|
-
|
139
|
+
Iri.new('https://blockchain.info/rawblock').append(hash)
|
139
140
|
)
|
140
141
|
{
|
142
|
+
provider: self.class.name,
|
141
143
|
hash: json['hash'],
|
142
144
|
orphan: !json['main_chain'],
|
143
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
|
@@ -20,19 +20,20 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
require 'uri'
|
24
|
-
require 'json'
|
25
23
|
require 'cgi'
|
26
|
-
|
24
|
+
require 'iri'
|
25
|
+
require 'json'
|
26
|
+
require 'uri'
|
27
27
|
require_relative 'error'
|
28
|
-
require_relative 'log'
|
29
28
|
require_relative 'http'
|
30
29
|
require_relative 'json'
|
30
|
+
require_relative 'log'
|
31
|
+
require_relative 'version'
|
31
32
|
|
32
33
|
# Blockchair.com API.
|
33
34
|
#
|
34
35
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
|
-
# Copyright:: Copyright (c) 2019-
|
36
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
36
37
|
# License:: MIT
|
37
38
|
class Sibit
|
38
39
|
# Btc.com API.
|
@@ -64,7 +65,7 @@ class Sibit
|
|
64
65
|
# Gets the balance of the address, in satoshi.
|
65
66
|
def balance(address)
|
66
67
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
67
|
-
|
68
|
+
Iri.new('https://api.blockchair.com/bitcoin/dashboards/address').append(address).fragment(the_key)
|
68
69
|
)['data'][address]
|
69
70
|
if json.nil?
|
70
71
|
@log.info("Address #{address} not found")
|
@@ -94,7 +95,7 @@ class Sibit
|
|
94
95
|
# Push this transaction (in hex format) to the network.
|
95
96
|
def push(hex)
|
96
97
|
Sibit::Json.new(http: @http, log: @log).post(
|
97
|
-
|
98
|
+
Iri.new('https://api.blockchair.com/bitcoin/push/transaction').fragment(the_key),
|
98
99
|
"data=#{hex}"
|
99
100
|
)
|
100
101
|
@log.info("Transaction (#{hex.length} in hex) has been pushed to Blockchair")
|
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
|
@@ -20,20 +20,21 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
require '
|
23
|
+
require 'iri'
|
24
24
|
require 'json'
|
25
|
-
|
25
|
+
require 'uri'
|
26
26
|
require_relative 'error'
|
27
|
-
require_relative 'log'
|
28
27
|
require_relative 'http'
|
29
28
|
require_relative 'json'
|
29
|
+
require_relative 'log'
|
30
|
+
require_relative 'version'
|
30
31
|
|
31
32
|
# Btc.com API.
|
32
33
|
#
|
33
34
|
# Here: https://btc.com/api-doc
|
34
35
|
#
|
35
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
36
|
-
# Copyright:: Copyright (c) 2019-
|
37
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
37
38
|
# License:: MIT
|
38
39
|
class Sibit
|
39
40
|
# Btc.com API.
|
@@ -52,7 +53,7 @@ class Sibit
|
|
52
53
|
|
53
54
|
# Gets the balance of the address, in satoshi.
|
54
55
|
def balance(address)
|
55
|
-
uri =
|
56
|
+
uri = Iri.new('https://chain.api.btc.com/v3/address').append(address).append('unspent')
|
56
57
|
json = Sibit::Json.new(http: @http, log: @log).get(uri)
|
57
58
|
if json['err_no'] == 1
|
58
59
|
@log.info("The balance of #{address} is zero (not found)")
|
@@ -73,16 +74,16 @@ class Sibit
|
|
73
74
|
balance
|
74
75
|
end
|
75
76
|
|
76
|
-
# 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.
|
77
78
|
def next_of(hash)
|
78
79
|
head = Sibit::Json.new(http: @http, log: @log).get(
|
79
|
-
|
80
|
+
Iri.new('https://chain.api.btc.com/v3/block').append(hash)
|
80
81
|
)
|
81
82
|
data = head['data']
|
82
83
|
raise Sibit::Error, "The block #{hash} not found" if data.nil?
|
83
84
|
nxt = data['next_block_hash']
|
84
85
|
nxt = nil if nxt == '0000000000000000000000000000000000000000000000000000000000000000'
|
85
|
-
@log.info("
|
86
|
+
@log.info("In BTC.com the block #{hash} is the latest, there is no next block") if nxt.nil?
|
86
87
|
@log.info("The next block of #{hash} is #{nxt}") unless nxt.nil?
|
87
88
|
nxt
|
88
89
|
end
|
@@ -90,7 +91,7 @@ class Sibit
|
|
90
91
|
# The height of the block.
|
91
92
|
def height(hash)
|
92
93
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
93
|
-
|
94
|
+
Iri.new('https://chain.api.btc.com/v3/block').append(hash)
|
94
95
|
)
|
95
96
|
data = json['data']
|
96
97
|
raise Sibit::Error, "The block #{hash} not found" if data.nil?
|
@@ -107,7 +108,7 @@ class Sibit
|
|
107
108
|
|
108
109
|
# Gets the hash of the latest block.
|
109
110
|
def latest
|
110
|
-
uri =
|
111
|
+
uri = Iri.new('https://chain.api.btc.com/v3/block/latest')
|
111
112
|
json = Sibit::Json.new(http: @http, log: @log).get(uri)
|
112
113
|
data = json['data']
|
113
114
|
raise Sibit::Error, 'The latest block not found' if data.nil?
|
@@ -121,7 +122,7 @@ class Sibit
|
|
121
122
|
txns = []
|
122
123
|
sources.each do |hash|
|
123
124
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
124
|
-
|
125
|
+
Iri.new('https://chain.api.btc.com/v3/address').append(hash).append('unspent')
|
125
126
|
)
|
126
127
|
data = json['data']
|
127
128
|
raise Sibit::Error, "The address #{hash} not found" if data.nil?
|
@@ -129,7 +130,7 @@ class Sibit
|
|
129
130
|
next if txns.nil?
|
130
131
|
txns.each do |u|
|
131
132
|
outs = Sibit::Json.new(http: @http, log: @log).get(
|
132
|
-
|
133
|
+
Iri.new('https://chain.api.btc.com/v3/tx').append(u['tx_hash']).add(verbose: 3)
|
133
134
|
)['data']['outputs']
|
134
135
|
outs.each_with_index do |o, i|
|
135
136
|
next unless o['addresses'].include?(hash)
|
@@ -154,13 +155,14 @@ class Sibit
|
|
154
155
|
# This method should fetch a Blockchain block and return as a hash.
|
155
156
|
def block(hash)
|
156
157
|
head = Sibit::Json.new(http: @http, log: @log).get(
|
157
|
-
|
158
|
+
Iri.new('https://chain.api.btc.com/v3/block').append(hash)
|
158
159
|
)
|
159
160
|
data = head['data']
|
160
161
|
raise Sibit::Error, "The block #{hash} not found" if data.nil?
|
161
162
|
nxt = data['next_block_hash']
|
162
163
|
nxt = nil if nxt == '0000000000000000000000000000000000000000000000000000000000000000'
|
163
164
|
{
|
165
|
+
provider: self.class.name,
|
164
166
|
hash: data['hash'],
|
165
167
|
orphan: data['is_orphan'],
|
166
168
|
next: nxt,
|
@@ -177,7 +179,8 @@ class Sibit
|
|
177
179
|
all = []
|
178
180
|
loop do
|
179
181
|
data = Sibit::Json.new(http: @http, log: @log).get(
|
180
|
-
|
182
|
+
Iri.new('https://chain.api.btc.com/v3/block')
|
183
|
+
.append(hash).append('tx').add(page: page, pagesize: psize)
|
181
184
|
)['data']
|
182
185
|
raise Sibit::Error, "The block #{hash} has no data at page #{page}" if data.nil?
|
183
186
|
list = data['list']
|
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.
|
@@ -45,7 +45,7 @@ class Sibit
|
|
45
45
|
# Current price of BTC in USD (float returned).
|
46
46
|
def price(currency = 'USD')
|
47
47
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
48
|
-
|
48
|
+
Iri.new('https://cex.io/api/last_price/BTC').append(currency)
|
49
49
|
)
|
50
50
|
p = json['lprice'].to_f
|
51
51
|
@log.info("The price of BTC is #{p} #{currency}")
|
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
|
@@ -20,18 +20,19 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
require '
|
23
|
+
require 'iri'
|
24
24
|
require 'json'
|
25
|
-
|
25
|
+
require 'uri'
|
26
26
|
require_relative 'error'
|
27
|
-
require_relative 'log'
|
28
27
|
require_relative 'http'
|
29
28
|
require_relative 'json'
|
29
|
+
require_relative 'log'
|
30
|
+
require_relative 'version'
|
30
31
|
|
31
32
|
# Cryptoapis.io API.
|
32
33
|
#
|
33
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
34
|
-
# Copyright:: Copyright (c) 2019-
|
35
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
35
36
|
# License:: MIT
|
36
37
|
class Sibit
|
37
38
|
# Btc.com API.
|
@@ -52,7 +53,7 @@ class Sibit
|
|
52
53
|
# Get hash of the block after this one.
|
53
54
|
def next_of(hash)
|
54
55
|
nxt = Sibit::Json.new(http: @http, log: @log).get(
|
55
|
-
|
56
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks').append(hash),
|
56
57
|
headers: headers
|
57
58
|
)['payload']['hash']
|
58
59
|
@log.info("The block #{hash} is the latest, there is no next block") if nxt.nil?
|
@@ -63,7 +64,7 @@ class Sibit
|
|
63
64
|
# The height of the block.
|
64
65
|
def height(hash)
|
65
66
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
66
|
-
|
67
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks').append(hash),
|
67
68
|
headers: headers
|
68
69
|
)['payload']
|
69
70
|
h = json['height']
|
@@ -74,7 +75,7 @@ class Sibit
|
|
74
75
|
# Gets the balance of the address, in satoshi.
|
75
76
|
def balance(address)
|
76
77
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
77
|
-
|
78
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/mainnet/address').append(address),
|
78
79
|
headers: headers
|
79
80
|
)['payload']
|
80
81
|
b = (json['balance'].to_f * 100_000_000).to_i
|
@@ -90,7 +91,7 @@ class Sibit
|
|
90
91
|
# Gets the hash of the latest block.
|
91
92
|
def latest
|
92
93
|
hash = Sibit::Json.new(http: @http, log: @log).get(
|
93
|
-
|
94
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest'),
|
94
95
|
headers: headers
|
95
96
|
)['payload']['hash']
|
96
97
|
@log.info("The latest block hash is #{hash}")
|
@@ -105,7 +106,7 @@ class Sibit
|
|
105
106
|
# Push this transaction (in hex format) to the network.
|
106
107
|
def push(hex)
|
107
108
|
Sibit::Json.new(http: @http, log: @log).post(
|
108
|
-
|
109
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send'),
|
109
110
|
JSON.pretty_generate(hex: hex),
|
110
111
|
headers: headers
|
111
112
|
)
|
@@ -114,10 +115,11 @@ class Sibit
|
|
114
115
|
# This method should fetch a Blockchain block and return as a hash.
|
115
116
|
def block(hash)
|
116
117
|
head = Sibit::Json.new(http: @http, log: @log).get(
|
117
|
-
|
118
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks').append(hash),
|
118
119
|
headers: headers
|
119
120
|
)['payload']
|
120
121
|
{
|
122
|
+
provider: self.class.name,
|
121
123
|
hash: head['hash'],
|
122
124
|
orphan: false,
|
123
125
|
next: head['nextblockhash'],
|
@@ -141,12 +143,8 @@ class Sibit
|
|
141
143
|
all = []
|
142
144
|
loop do
|
143
145
|
txns = Sibit::Json.new(http: @http, log: @log).get(
|
144
|
-
|
145
|
-
|
146
|
-
'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/',
|
147
|
-
"#{hash}?index=#{index}&limit=#{limit}"
|
148
|
-
].join
|
149
|
-
),
|
146
|
+
Iri.new('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/')
|
147
|
+
.append(hash).add(index: index, limit: limit),
|
150
148
|
headers: headers
|
151
149
|
)['payload'].map do |t|
|
152
150
|
{
|
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
|
@@ -20,17 +20,18 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
+
require 'iri'
|
23
24
|
require 'json'
|
24
25
|
require 'uri'
|
25
|
-
require_relative 'version'
|
26
26
|
require_relative 'error'
|
27
27
|
require_relative 'http'
|
28
28
|
require_relative 'json'
|
29
|
+
require_relative 'version'
|
29
30
|
|
30
31
|
# Earn.com API.
|
31
32
|
#
|
32
33
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
33
|
-
# Copyright:: Copyright (c) 2019-
|
34
|
+
# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko
|
34
35
|
# License:: MIT
|
35
36
|
class Sibit
|
36
37
|
# Blockchain.info API.
|
@@ -66,7 +67,7 @@ class Sibit
|
|
66
67
|
# a hash: { S: 12, M: 45, L: 100, XL: 200 }
|
67
68
|
def fees
|
68
69
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
69
|
-
|
70
|
+
Iri.new('https://bitcoinfees.earn.com/api/v1/fees/recommended')
|
70
71
|
)
|
71
72
|
@log.info("Current recommended Bitcoin fees: \
|
72
73
|
#{json['hourFee']}/#{json['halfHourFee']}/#{json['fastestFee']} sat/byte")
|
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.
|
@@ -48,8 +48,9 @@ class Sibit
|
|
48
48
|
# Send GET request to the HTTP and return JSON response.
|
49
49
|
# This method will also log the process and will validate the
|
50
50
|
# response for correctness.
|
51
|
-
def get(
|
51
|
+
def get(address, headers: {}, accept: [200])
|
52
52
|
start = Time.now
|
53
|
+
uri = URI(address.to_s)
|
53
54
|
res = @http.client(uri).get(
|
54
55
|
"#{uri.path.empty? ? '/' : uri.path}#{uri.query ? "?#{uri.query}" : ''}",
|
55
56
|
{
|
@@ -64,10 +65,13 @@ class Sibit
|
|
64
65
|
end
|
65
66
|
@log.info("GET #{uri}: #{res.code}/#{length(res.body.length)} in #{age(start)}")
|
66
67
|
JSON.parse(res.body)
|
68
|
+
rescue JSON::ParserError => e
|
69
|
+
raise Sibit::Error, "Can't parse JSON: #{e.message}"
|
67
70
|
end
|
68
71
|
|
69
|
-
def post(
|
72
|
+
def post(address, body, headers: {})
|
70
73
|
start = Time.now
|
74
|
+
uri = URI(address.to_s)
|
71
75
|
res = @http.client(uri).post(
|
72
76
|
"#{uri.path}?#{uri.query}",
|
73
77
|
"tx=#{CGI.escape(body)}",
|
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.7'
|
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
|
@@ -50,6 +50,7 @@ and Ruby 2.3+.'
|
|
50
50
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
51
51
|
s.add_runtime_dependency 'backtrace', '~> 0.3'
|
52
52
|
s.add_runtime_dependency 'bitcoin-ruby', '0.0.19'
|
53
|
+
s.add_runtime_dependency 'iri', '~> 0.5'
|
53
54
|
s.add_runtime_dependency 'json', '~> 2'
|
54
55
|
s.add_runtime_dependency 'retriable_proxy', '1.0.2'
|
55
56
|
s.add_runtime_dependency 'slop', '~> 4.6'
|
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.7
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.0.19
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: iri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.5'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: json
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|