sibit 0.25.1 → 0.27.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 +18 -28
- data/Gemfile.lock +187 -0
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +80 -60
- data/REUSE.toml +35 -0
- data/Rakefile +3 -29
- data/bin/sibit +9 -28
- data/cucumber.yml +3 -0
- data/features/cli.feature +2 -0
- data/features/gem_package.feature +4 -1
- data/features/step_definitions/steps.rb +2 -19
- data/features/support/env.rb +2 -19
- data/lib/sibit/bestof.rb +5 -22
- data/lib/sibit/bitcoin/base58.rb +50 -0
- data/lib/sibit/bitcoin/key.rb +87 -0
- data/lib/sibit/bitcoin/script.rb +58 -0
- data/lib/sibit/bitcoin/tx.rb +212 -0
- data/lib/sibit/bitcoin/txbuilder.rb +120 -0
- data/lib/sibit/bitcoinchain.rb +5 -22
- data/lib/sibit/blockchain.rb +5 -22
- data/lib/sibit/blockchair.rb +5 -22
- data/lib/sibit/btc.rb +6 -23
- data/lib/sibit/cex.rb +5 -22
- data/lib/sibit/cryptoapis.rb +5 -22
- data/lib/sibit/error.rb +3 -20
- data/lib/sibit/fake.rb +3 -20
- data/lib/sibit/firstof.rb +5 -22
- data/lib/sibit/http.rb +3 -20
- data/lib/sibit/json.rb +6 -23
- data/lib/sibit/version.rb +4 -21
- data/lib/sibit.rb +31 -40
- data/logo.svg +1 -1
- data/sibit.gemspec +16 -32
- metadata +26 -48
- data/.0pdd.yml +0 -9
- data/.gitattributes +0 -7
- data/.github/workflows/codecov.yml +0 -21
- data/.github/workflows/pdd.yml +0 -15
- data/.github/workflows/rake.yml +0 -24
- data/.github/workflows/xcop.yml +0 -17
- data/.gitignore +0 -8
- data/.pdd +0 -7
- data/.rubocop.yml +0 -38
- data/.rultor.yml +0 -21
- data/.simplecov +0 -40
- data/lib/sibit/earn.rb +0 -102
- data/lib/sibit/log.rb +0 -49
- data/renovate.json +0 -6
- data/test/test__helper.rb +0 -29
- data/test/test_bestof.rb +0 -62
- data/test/test_bitcoinchain.rb +0 -73
- data/test/test_blockchain.rb +0 -58
- data/test/test_blockchair.rb +0 -43
- data/test/test_btc.rb +0 -117
- data/test/test_cex.rb +0 -43
- data/test/test_cryptoapis.rb +0 -51
- data/test/test_fake.rb +0 -55
- data/test/test_firstof.rb +0 -62
- data/test/test_json.rb +0 -40
- data/test/test_live.rb +0 -138
- data/test/test_sibit.rb +0 -209
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
require_relative 'tx'
|
|
7
|
+
require_relative 'key'
|
|
8
|
+
|
|
9
|
+
class Sibit
|
|
10
|
+
module Bitcoin
|
|
11
|
+
# Bitcoin Transaction Builder.
|
|
12
|
+
#
|
|
13
|
+
# Provides a similar interface to Bitcoin::Builder::TxBuilder for
|
|
14
|
+
# building and signing Bitcoin transactions.
|
|
15
|
+
#
|
|
16
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
17
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
18
|
+
# License:: MIT
|
|
19
|
+
class TxBuilder
|
|
20
|
+
def initialize
|
|
21
|
+
@inputs = []
|
|
22
|
+
@outputs = []
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def input
|
|
26
|
+
inp = InputBuilder.new
|
|
27
|
+
yield inp
|
|
28
|
+
@inputs << inp
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def output(value, address)
|
|
32
|
+
@outputs << { value: value, address: address }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def tx(input_value:, leave_fee:, extra_fee:, change_address:)
|
|
36
|
+
txn = Tx.new
|
|
37
|
+
@inputs.each do |inp|
|
|
38
|
+
txn.add_input(
|
|
39
|
+
hash: inp.prev_out_hash,
|
|
40
|
+
index: inp.prev_out_idx,
|
|
41
|
+
script: inp.script,
|
|
42
|
+
key: inp.key
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
total_out = @outputs.sum { |o| o[:value] }
|
|
46
|
+
@outputs.each { |o| txn.add_output(o[:value], o[:address]) }
|
|
47
|
+
if leave_fee
|
|
48
|
+
change = input_value - total_out - extra_fee
|
|
49
|
+
txn.add_output(change, change_address) if change.positive?
|
|
50
|
+
end
|
|
51
|
+
BuiltTx.new(txn, @inputs, @outputs)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Input builder for collecting input parameters.
|
|
56
|
+
class InputBuilder
|
|
57
|
+
attr_reader :prev_out_hash, :prev_out_idx, :script, :key
|
|
58
|
+
|
|
59
|
+
def prev_out(hash)
|
|
60
|
+
@prev_out_hash = hash
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def prev_out_index(idx)
|
|
64
|
+
@prev_out_idx = idx
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def prev_out_script=(scr)
|
|
68
|
+
@script = scr
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def signature_key(key)
|
|
72
|
+
@key = key
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Wrapper for built transaction with convenience methods.
|
|
77
|
+
class BuiltTx
|
|
78
|
+
def initialize(txn, inputs, outputs)
|
|
79
|
+
@tx = txn
|
|
80
|
+
@inputs_data = inputs
|
|
81
|
+
@outputs_data = outputs
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def hash
|
|
85
|
+
@tx.hash
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def in
|
|
89
|
+
@tx.in
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def out
|
|
93
|
+
@tx.out
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def inputs
|
|
97
|
+
@tx.inputs
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def outputs
|
|
101
|
+
@tx.outputs
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def to_payload
|
|
105
|
+
PayloadWrapper.new(@tx.payload)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Wrapper for payload with hex conversion.
|
|
110
|
+
class PayloadWrapper
|
|
111
|
+
def initialize(bytes)
|
|
112
|
+
@bytes = bytes
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def bth
|
|
116
|
+
@bytes.unpack1('H*')
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
data/lib/sibit/bitcoinchain.rb
CHANGED
|
@@ -1,44 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'iri'
|
|
24
7
|
require 'json'
|
|
25
8
|
require 'uri'
|
|
26
9
|
require_relative 'error'
|
|
27
10
|
require_relative 'http'
|
|
11
|
+
require 'loog'
|
|
28
12
|
require_relative 'json'
|
|
29
|
-
require_relative 'log'
|
|
30
13
|
require_relative 'version'
|
|
31
14
|
|
|
32
15
|
# Bitcoinchain.com API.
|
|
33
16
|
#
|
|
34
17
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
35
|
-
# Copyright:: Copyright (c) 2019-
|
|
18
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
36
19
|
# License:: MIT
|
|
37
20
|
class Sibit
|
|
38
21
|
# Btc.com API.
|
|
39
22
|
class Bitcoinchain
|
|
40
23
|
# Constructor.
|
|
41
|
-
def initialize(log:
|
|
24
|
+
def initialize(log: Loog::NULL, http: Sibit::Http.new, dry: false)
|
|
42
25
|
@http = http
|
|
43
26
|
@log = log
|
|
44
27
|
@dry = dry
|
data/lib/sibit/blockchain.rb
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
|
-
require 'bitcoin'
|
|
24
6
|
require 'iri'
|
|
25
7
|
require 'json'
|
|
8
|
+
require 'loog'
|
|
26
9
|
require 'uri'
|
|
27
10
|
require_relative 'error'
|
|
28
11
|
require_relative 'http'
|
|
@@ -35,13 +18,13 @@ require_relative 'version'
|
|
|
35
18
|
# https://www.blockchain.com/api/blockchain_api
|
|
36
19
|
#
|
|
37
20
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
38
|
-
# Copyright:: Copyright (c) 2019-
|
|
21
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
39
22
|
# License:: MIT
|
|
40
23
|
class Sibit
|
|
41
24
|
# Blockchain.info API.
|
|
42
25
|
class Blockchain
|
|
43
26
|
# Constructor.
|
|
44
|
-
def initialize(log:
|
|
27
|
+
def initialize(log: Loog::NULL, http: Sibit::Http.new, dry: false)
|
|
45
28
|
@http = http
|
|
46
29
|
@log = log
|
|
47
30
|
@dry = dry
|
data/lib/sibit/blockchair.rb
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'cgi'
|
|
24
7
|
require 'iri'
|
|
@@ -26,20 +9,20 @@ require 'json'
|
|
|
26
9
|
require 'uri'
|
|
27
10
|
require_relative 'error'
|
|
28
11
|
require_relative 'http'
|
|
12
|
+
require 'loog'
|
|
29
13
|
require_relative 'json'
|
|
30
|
-
require_relative 'log'
|
|
31
14
|
require_relative 'version'
|
|
32
15
|
|
|
33
16
|
# Blockchair.com API.
|
|
34
17
|
#
|
|
35
18
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
36
|
-
# Copyright:: Copyright (c) 2019-
|
|
19
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
37
20
|
# License:: MIT
|
|
38
21
|
class Sibit
|
|
39
22
|
# Btc.com API.
|
|
40
23
|
class Blockchair
|
|
41
24
|
# Constructor.
|
|
42
|
-
def initialize(key: nil, log:
|
|
25
|
+
def initialize(key: nil, log: Loog::NULL, http: Sibit::Http.new, dry: false)
|
|
43
26
|
@key = key
|
|
44
27
|
@http = http
|
|
45
28
|
@log = log
|
data/lib/sibit/btc.rb
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'iri'
|
|
24
7
|
require 'json'
|
|
25
8
|
require 'uri'
|
|
26
9
|
require_relative 'error'
|
|
27
10
|
require_relative 'http'
|
|
11
|
+
require 'loog'
|
|
28
12
|
require_relative 'json'
|
|
29
|
-
require_relative 'log'
|
|
30
13
|
require_relative 'version'
|
|
31
14
|
|
|
32
15
|
# Btc.com API.
|
|
@@ -34,13 +17,13 @@ require_relative 'version'
|
|
|
34
17
|
# Here: https://btc.com/api-doc
|
|
35
18
|
#
|
|
36
19
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
37
|
-
# Copyright:: Copyright (c) 2019-
|
|
20
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
38
21
|
# License:: MIT
|
|
39
22
|
class Sibit
|
|
40
23
|
# Btc.com API.
|
|
41
24
|
class Btc
|
|
42
25
|
# Constructor.
|
|
43
|
-
def initialize(log:
|
|
26
|
+
def initialize(log: Loog::NULL, http: Sibit::Http.new, dry: false)
|
|
44
27
|
@http = http
|
|
45
28
|
@log = log
|
|
46
29
|
@dry = dry
|
|
@@ -69,7 +52,7 @@ class Sibit
|
|
|
69
52
|
@log.info("The balance of #{address} is probably zero (not found)")
|
|
70
53
|
return 0
|
|
71
54
|
end
|
|
72
|
-
balance = txns.
|
|
55
|
+
balance = txns.sum { |tx| tx['value'] } || 0
|
|
73
56
|
@log.info("The balance of #{address} is #{balance}, total txns: #{txns.count}")
|
|
74
57
|
balance
|
|
75
58
|
end
|
data/lib/sibit/cex.rb
CHANGED
|
@@ -1,42 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'uri'
|
|
24
7
|
require 'json'
|
|
8
|
+
require 'loog'
|
|
25
9
|
require_relative 'error'
|
|
26
|
-
require_relative 'log'
|
|
27
10
|
require_relative 'http'
|
|
28
11
|
require_relative 'json'
|
|
29
12
|
|
|
30
13
|
# Cex.io API.
|
|
31
14
|
#
|
|
32
15
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
33
|
-
# Copyright:: Copyright (c) 2019-
|
|
16
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
34
17
|
# License:: MIT
|
|
35
18
|
class Sibit
|
|
36
19
|
# Btc.com API.
|
|
37
20
|
class Cex
|
|
38
21
|
# Constructor.
|
|
39
|
-
def initialize(log:
|
|
22
|
+
def initialize(log: Loog::NULL, http: Sibit::Http.new, dry: false)
|
|
40
23
|
@http = http
|
|
41
24
|
@log = log
|
|
42
25
|
@dry = dry
|
data/lib/sibit/cryptoapis.rb
CHANGED
|
@@ -1,44 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'iri'
|
|
24
7
|
require 'json'
|
|
25
8
|
require 'uri'
|
|
26
9
|
require_relative 'error'
|
|
27
10
|
require_relative 'http'
|
|
11
|
+
require 'loog'
|
|
28
12
|
require_relative 'json'
|
|
29
|
-
require_relative 'log'
|
|
30
13
|
require_relative 'version'
|
|
31
14
|
|
|
32
15
|
# Cryptoapis.io API.
|
|
33
16
|
#
|
|
34
17
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
35
|
-
# Copyright:: Copyright (c) 2019-
|
|
18
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
36
19
|
# License:: MIT
|
|
37
20
|
class Sibit
|
|
38
21
|
# Btc.com API.
|
|
39
22
|
class Cryptoapis
|
|
40
23
|
# Constructor.
|
|
41
|
-
def initialize(key, log:
|
|
24
|
+
def initialize(key, log: Loog::NULL, http: Sibit::Http.new, dry: false)
|
|
42
25
|
@key = key
|
|
43
26
|
@http = http
|
|
44
27
|
@log = log
|
data/lib/sibit/error.rb
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
# The error.
|
|
24
7
|
#
|
|
25
8
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
26
|
-
# Copyright:: Copyright (c) 2019-
|
|
9
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
27
10
|
# License:: MIT
|
|
28
11
|
class Sibit
|
|
29
12
|
# The error.
|
data/lib/sibit/fake.rb
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require_relative 'version'
|
|
24
7
|
|
|
25
8
|
# Fake API.
|
|
26
9
|
#
|
|
27
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
28
|
-
# Copyright:: Copyright (c) 2019-
|
|
11
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
29
12
|
# License:: MIT
|
|
30
13
|
class Sibit
|
|
31
14
|
# Fake API
|
data/lib/sibit/firstof.rb
CHANGED
|
@@ -1,39 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'backtrace'
|
|
7
|
+
require 'loog'
|
|
24
8
|
require_relative 'error'
|
|
25
|
-
require_relative 'log'
|
|
26
9
|
|
|
27
10
|
# API first of.
|
|
28
11
|
#
|
|
29
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
|
13
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
31
14
|
# License:: MIT
|
|
32
15
|
class Sibit
|
|
33
16
|
# First of API.
|
|
34
17
|
class FirstOf
|
|
35
18
|
# Constructor.
|
|
36
|
-
def initialize(list, log:
|
|
19
|
+
def initialize(list, log: Loog::NULL, verbose: false)
|
|
37
20
|
@list = list
|
|
38
21
|
@log = log
|
|
39
22
|
@verbose = verbose
|
data/lib/sibit/http.rb
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'net/http'
|
|
24
7
|
|
|
25
8
|
# HTTP interface.
|
|
26
9
|
#
|
|
27
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
28
|
-
# Copyright:: Copyright (c) 2019-
|
|
11
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
29
12
|
# License:: MIT
|
|
30
13
|
class Sibit
|
|
31
14
|
# This HTTP client will be used by default.
|
data/lib/sibit/json.rb
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'json'
|
|
24
7
|
require 'uri'
|
|
25
8
|
require 'cgi'
|
|
26
9
|
require_relative 'version'
|
|
27
10
|
require_relative 'error'
|
|
11
|
+
require 'loog'
|
|
28
12
|
require_relative 'http'
|
|
29
|
-
require_relative 'log'
|
|
30
13
|
|
|
31
14
|
# Json SDK.
|
|
32
15
|
#
|
|
@@ -34,13 +17,13 @@ require_relative 'log'
|
|
|
34
17
|
# https://www.blockchain.com/api/blockchain_api
|
|
35
18
|
#
|
|
36
19
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
37
|
-
# Copyright:: Copyright (c) 2019-
|
|
20
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
38
21
|
# License:: MIT
|
|
39
22
|
class Sibit
|
|
40
23
|
# JSON processing.
|
|
41
24
|
class Json
|
|
42
25
|
# Constructor.
|
|
43
|
-
def initialize(log:
|
|
26
|
+
def initialize(log: Loog::NULL, http: Sibit::Http.new)
|
|
44
27
|
@http = http
|
|
45
28
|
@log = log
|
|
46
29
|
end
|
|
@@ -52,7 +35,7 @@ class Sibit
|
|
|
52
35
|
start = Time.now
|
|
53
36
|
uri = URI(address.to_s)
|
|
54
37
|
res = @http.client(uri).get(
|
|
55
|
-
"#{uri.path.empty? ? '/' : uri.path}#{
|
|
38
|
+
"#{uri.path.empty? ? '/' : uri.path}#{"?#{uri.query}" if uri.query}",
|
|
56
39
|
{
|
|
57
40
|
'Accept' => 'application/json',
|
|
58
41
|
'User-Agent' => user_agent,
|
data/lib/sibit/version.rb
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
# Sibit main class.
|
|
24
7
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
25
|
-
# Copyright:: Copyright (c) 2019-
|
|
8
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
26
9
|
# License:: MIT
|
|
27
10
|
class Sibit
|
|
28
11
|
# Current version of the library.
|
|
29
|
-
VERSION = '0.
|
|
12
|
+
VERSION = '0.27.0'
|
|
30
13
|
end
|