sibit 0.32.8 → 0.34.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 +4 -5
- data/Gemfile.lock +76 -56
- data/README.md +16 -2
- data/Rakefile +1 -1
- data/bin/sibit +6 -4
- data/cross/alpine.df +6 -0
- data/cross/centos.df +13 -0
- data/cross/debian.df +9 -0
- data/cross/fedora.df +7 -0
- data/cross/opensuse.df +9 -0
- data/cross/rocky.df +13 -0
- data/cross/ubuntu.df +9 -0
- data/features/cli.feature +1 -0
- data/features/step_definitions/steps.rb +5 -5
- data/features/support/env.rb +1 -1
- data/lib/sibit/base58.rb +3 -6
- data/lib/sibit/bech32.rb +9 -14
- data/lib/sibit/bestof.rb +7 -4
- data/lib/sibit/bin.rb +65 -51
- data/lib/sibit/bitcoinchain.rb +8 -8
- data/lib/sibit/blockchain.rb +5 -19
- data/lib/sibit/blockchair.rb +14 -24
- data/lib/sibit/btc.rb +39 -45
- data/lib/sibit/cex.rb +12 -11
- data/lib/sibit/cryptoapis.rb +30 -27
- data/lib/sibit/firstof.rb +8 -5
- data/lib/sibit/httpproxy.rb +1 -1
- data/lib/sibit/json.rb +7 -7
- data/lib/sibit/key.rb +39 -41
- data/lib/sibit/script.rb +3 -6
- data/lib/sibit/sochain.rb +177 -0
- data/lib/sibit/tx.rb +48 -32
- data/lib/sibit/txbuilder.rb +3 -3
- data/lib/sibit/version.rb +1 -2
- data/lib/sibit.rb +71 -56
- data/sibit.gemspec +11 -11
- metadata +9 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9835f6fa0e5abbd809c650561dc79b4bddd69281bcc6f34c28d703c1ff7e27e
|
|
4
|
+
data.tar.gz: f64fa06396983ea189f42d7d1028842831f082c6c12660858916111b62f6be28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc3cc86f77d6418d88c327f87758de829b98644adf439f736c4c6a8db24e7f0f15a1faad58dc3f36a45b3ac5693995dcda0bb117ece14178fc0d437131139ab8
|
|
7
|
+
data.tar.gz: 49982a64fedb0281e093d4dd2176e649bc721f56b8743819c536ab28ac324e230097c5e4d741553da6a7b25e248b32f0933a14b8052d2fd705afc1222feec53e
|
data/Gemfile
CHANGED
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
source 'https://rubygems.org'
|
|
7
7
|
gemspec
|
|
8
8
|
|
|
9
|
-
# gem 'debase', '0.2.4.1', require: false
|
|
10
|
-
|
|
11
9
|
gem 'aruba', '~>2.2', require: false
|
|
12
|
-
gem 'cucumber', '~>
|
|
10
|
+
gem 'cucumber', '~>11.0', require: false
|
|
13
11
|
gem 'donce', '~>0.2', require: false
|
|
14
12
|
gem 'logger', '~>1.7', require: false
|
|
15
13
|
gem 'minitest', '~>6.0', require: false
|
|
@@ -18,8 +16,9 @@ gem 'nokogiri', '~>1.18', require: false
|
|
|
18
16
|
gem 'os', '~>1.1', require: false
|
|
19
17
|
gem 'qbash', '~>0.0', require: false
|
|
20
18
|
gem 'rake', '~>13.2', require: false
|
|
21
|
-
gem 'rdoc', '~>
|
|
22
|
-
gem 'rubocop', '~>1.
|
|
19
|
+
gem 'rdoc', '~>8.0', require: false
|
|
20
|
+
gem 'rubocop', '~>1.72', require: false
|
|
21
|
+
gem 'rubocop-elegant', '~>0.5', require: false
|
|
23
22
|
gem 'rubocop-minitest', '~>0.38', require: false
|
|
24
23
|
gem 'rubocop-performance', '~>1.25', require: false
|
|
25
24
|
gem 'rubocop-rake', '~>0.7', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -16,133 +16,152 @@ PATH
|
|
|
16
16
|
GEM
|
|
17
17
|
remote: https://rubygems.org/
|
|
18
18
|
specs:
|
|
19
|
-
addressable (2.
|
|
19
|
+
addressable (2.9.0)
|
|
20
20
|
public_suffix (>= 2.0.2, < 8.0)
|
|
21
|
-
ansi (1.
|
|
22
|
-
aruba (2.
|
|
21
|
+
ansi (1.6.0)
|
|
22
|
+
aruba (2.4.1)
|
|
23
23
|
bundler (>= 1.17)
|
|
24
24
|
contracts (>= 0.16.0, < 0.18.0)
|
|
25
|
-
cucumber (>= 8.0, <
|
|
25
|
+
cucumber (>= 8.0, < 12.0)
|
|
26
|
+
irb (~> 1.16)
|
|
26
27
|
rspec-expectations (>= 3.4, < 5.0)
|
|
27
28
|
thor (~> 1.0)
|
|
28
29
|
ast (2.4.3)
|
|
29
30
|
backtrace (0.4.1)
|
|
30
31
|
base64 (0.3.0)
|
|
31
|
-
bigdecimal (4.
|
|
32
|
+
bigdecimal (4.1.2)
|
|
32
33
|
builder (3.3.0)
|
|
33
34
|
contracts (0.17.3)
|
|
34
35
|
crack (1.0.1)
|
|
35
36
|
bigdecimal
|
|
36
37
|
rexml
|
|
37
|
-
cucumber (
|
|
38
|
+
cucumber (11.1.1)
|
|
38
39
|
base64 (~> 0.2)
|
|
39
40
|
builder (~> 3.2)
|
|
40
41
|
cucumber-ci-environment (> 9, < 12)
|
|
41
|
-
cucumber-core (
|
|
42
|
+
cucumber-core (>= 16.2.0, < 17)
|
|
42
43
|
cucumber-cucumber-expressions (> 17, < 20)
|
|
43
|
-
cucumber-html-formatter (> 21, <
|
|
44
|
+
cucumber-html-formatter (> 21, < 24)
|
|
44
45
|
diff-lcs (~> 1.5)
|
|
45
46
|
logger (~> 1.6)
|
|
46
47
|
mini_mime (~> 1.1)
|
|
47
48
|
multi_test (~> 1.1)
|
|
48
|
-
sys-uname (~> 1.
|
|
49
|
+
sys-uname (~> 1.5)
|
|
49
50
|
cucumber-ci-environment (11.0.0)
|
|
50
|
-
cucumber-core (16.
|
|
51
|
+
cucumber-core (16.2.0)
|
|
51
52
|
cucumber-gherkin (> 36, < 40)
|
|
52
53
|
cucumber-messages (> 31, < 33)
|
|
53
54
|
cucumber-tag-expressions (> 6, < 9)
|
|
54
|
-
cucumber-cucumber-expressions (
|
|
55
|
+
cucumber-cucumber-expressions (19.0.1)
|
|
55
56
|
bigdecimal
|
|
56
|
-
cucumber-gherkin (
|
|
57
|
-
cucumber-messages (>= 31, <
|
|
58
|
-
cucumber-html-formatter (
|
|
57
|
+
cucumber-gherkin (39.1.0)
|
|
58
|
+
cucumber-messages (>= 31, < 33)
|
|
59
|
+
cucumber-html-formatter (23.1.0)
|
|
59
60
|
cucumber-messages (> 23, < 33)
|
|
60
|
-
cucumber-messages (
|
|
61
|
+
cucumber-messages (32.3.1)
|
|
61
62
|
cucumber-tag-expressions (8.1.0)
|
|
62
|
-
date (3.5.1)
|
|
63
63
|
decoor (0.1.0)
|
|
64
64
|
diff-lcs (1.6.2)
|
|
65
65
|
docile (1.4.1)
|
|
66
|
-
donce (0.
|
|
66
|
+
donce (0.7.0)
|
|
67
67
|
backtrace (~> 0.3)
|
|
68
68
|
os (~> 1.1)
|
|
69
69
|
qbash (~> 0.3)
|
|
70
|
-
|
|
70
|
+
drb (2.2.3)
|
|
71
|
+
elapsed (0.3.1)
|
|
71
72
|
loog (~> 0.6)
|
|
72
73
|
tago (~> 0.1)
|
|
73
74
|
ellipsized (0.3.0)
|
|
74
|
-
erb (6.0.
|
|
75
|
-
ffi (1.17.
|
|
76
|
-
ffi (1.17.
|
|
75
|
+
erb (6.0.4)
|
|
76
|
+
ffi (1.17.4-arm64-darwin)
|
|
77
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
77
78
|
hashdiff (1.2.1)
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
io-console (0.8.2)
|
|
80
|
+
irb (1.18.0)
|
|
81
|
+
pp (>= 0.6.0)
|
|
82
|
+
prism (>= 1.3.0)
|
|
83
|
+
rdoc (>= 4.0.0)
|
|
84
|
+
reline (>= 0.4.2)
|
|
85
|
+
iri (0.11.8)
|
|
86
|
+
json (2.19.9)
|
|
80
87
|
language_server-protocol (3.17.0.5)
|
|
81
88
|
lint_roller (1.1.0)
|
|
82
89
|
logger (1.7.0)
|
|
83
|
-
loog (0.
|
|
90
|
+
loog (0.8.0)
|
|
91
|
+
ellipsized
|
|
84
92
|
logger (~> 1.0)
|
|
85
93
|
memoist3 (1.0.0)
|
|
86
94
|
mini_mime (1.1.5)
|
|
87
|
-
minitest (6.0.
|
|
95
|
+
minitest (6.0.6)
|
|
96
|
+
drb (~> 2.0)
|
|
88
97
|
prism (~> 1.5)
|
|
89
|
-
minitest-reporters (1.
|
|
98
|
+
minitest-reporters (1.8.0)
|
|
90
99
|
ansi
|
|
91
100
|
builder
|
|
92
|
-
minitest (>= 5.0)
|
|
101
|
+
minitest (>= 5.0, < 7)
|
|
93
102
|
ruby-progressbar
|
|
94
103
|
multi_test (1.1.0)
|
|
95
|
-
nokogiri (1.19.
|
|
104
|
+
nokogiri (1.19.4-arm64-darwin)
|
|
96
105
|
racc (~> 1.4)
|
|
97
|
-
nokogiri (1.19.
|
|
106
|
+
nokogiri (1.19.4-x86_64-linux-gnu)
|
|
98
107
|
racc (~> 1.4)
|
|
99
|
-
openssl (3.3.
|
|
108
|
+
openssl (3.3.3)
|
|
100
109
|
os (1.1.4)
|
|
101
|
-
parallel (1.
|
|
102
|
-
parser (3.3.
|
|
110
|
+
parallel (2.1.0)
|
|
111
|
+
parser (3.3.11.1)
|
|
103
112
|
ast (~> 2.4.1)
|
|
104
113
|
racc
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
public_suffix (7.0.
|
|
110
|
-
qbash (0.
|
|
114
|
+
pp (0.6.3)
|
|
115
|
+
prettyprint
|
|
116
|
+
prettyprint (0.2.0)
|
|
117
|
+
prism (1.9.0)
|
|
118
|
+
public_suffix (7.0.5)
|
|
119
|
+
qbash (0.8.4)
|
|
111
120
|
backtrace (> 0)
|
|
112
121
|
elapsed (> 0)
|
|
113
122
|
loog (> 0)
|
|
114
123
|
tago (> 0)
|
|
115
124
|
racc (1.8.1)
|
|
116
125
|
rainbow (3.1.1)
|
|
117
|
-
rake (13.
|
|
118
|
-
|
|
126
|
+
rake (13.4.2)
|
|
127
|
+
rbs (4.0.3)
|
|
128
|
+
logger
|
|
129
|
+
prism (>= 1.6.0)
|
|
130
|
+
tsort
|
|
131
|
+
rdoc (8.0.0)
|
|
119
132
|
erb
|
|
120
|
-
|
|
133
|
+
prism (>= 1.6.0)
|
|
134
|
+
rbs (>= 4.0.0)
|
|
121
135
|
tsort
|
|
122
|
-
regexp_parser (2.
|
|
123
|
-
|
|
136
|
+
regexp_parser (2.12.0)
|
|
137
|
+
reline (0.6.3)
|
|
138
|
+
io-console (~> 0.5)
|
|
139
|
+
retriable (3.8.0)
|
|
124
140
|
retriable_proxy (1.0.2)
|
|
125
141
|
retriable (>= 2.0, < 4.0)
|
|
126
142
|
rexml (3.4.4)
|
|
127
143
|
rspec-expectations (3.13.5)
|
|
128
144
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
129
145
|
rspec-support (~> 3.13.0)
|
|
130
|
-
rspec-support (3.13.
|
|
131
|
-
rubocop (1.
|
|
146
|
+
rspec-support (3.13.7)
|
|
147
|
+
rubocop (1.88.0)
|
|
132
148
|
json (~> 2.3)
|
|
133
149
|
language_server-protocol (~> 3.17.0.2)
|
|
134
150
|
lint_roller (~> 1.1.0)
|
|
135
|
-
parallel (
|
|
151
|
+
parallel (>= 1.10)
|
|
136
152
|
parser (>= 3.3.0.2)
|
|
137
153
|
rainbow (>= 2.2.2, < 4.0)
|
|
138
154
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
139
|
-
rubocop-ast (>= 1.
|
|
155
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
140
156
|
ruby-progressbar (~> 1.7)
|
|
141
157
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
142
|
-
rubocop-ast (1.49.
|
|
158
|
+
rubocop-ast (1.49.1)
|
|
143
159
|
parser (>= 3.3.7.2)
|
|
144
160
|
prism (~> 1.7)
|
|
145
|
-
rubocop-
|
|
161
|
+
rubocop-elegant (0.6.0)
|
|
162
|
+
lint_roller (~> 1.1)
|
|
163
|
+
rubocop (~> 1.75)
|
|
164
|
+
rubocop-minitest (0.39.1)
|
|
146
165
|
lint_roller (~> 1.1)
|
|
147
166
|
rubocop (>= 1.75.0, < 2.0)
|
|
148
167
|
rubocop-ast (>= 1.38.0, < 2.0)
|
|
@@ -163,17 +182,16 @@ GEM
|
|
|
163
182
|
simplecov (~> 0.19)
|
|
164
183
|
simplecov-html (0.13.2)
|
|
165
184
|
simplecov_json_formatter (0.1.4)
|
|
166
|
-
|
|
167
|
-
sys-uname (1.4.1)
|
|
185
|
+
sys-uname (1.5.1)
|
|
168
186
|
ffi (~> 1.1)
|
|
169
187
|
memoist3 (~> 1.0.0)
|
|
170
|
-
tago (0.
|
|
188
|
+
tago (0.7.0)
|
|
171
189
|
thor (1.5.0)
|
|
172
190
|
tsort (0.2.0)
|
|
173
191
|
unicode-display_width (3.2.0)
|
|
174
192
|
unicode-emoji (~> 4.1)
|
|
175
193
|
unicode-emoji (4.2.0)
|
|
176
|
-
webmock (3.26.
|
|
194
|
+
webmock (3.26.2)
|
|
177
195
|
addressable (>= 2.8.0)
|
|
178
196
|
crack (>= 0.3.2)
|
|
179
197
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
@@ -182,11 +200,12 @@ PLATFORMS
|
|
|
182
200
|
arm64-darwin-22
|
|
183
201
|
arm64-darwin-23
|
|
184
202
|
arm64-darwin-24
|
|
203
|
+
arm64-darwin-25
|
|
185
204
|
x86_64-linux
|
|
186
205
|
|
|
187
206
|
DEPENDENCIES
|
|
188
207
|
aruba (~> 2.2)
|
|
189
|
-
cucumber (~>
|
|
208
|
+
cucumber (~> 11.0)
|
|
190
209
|
donce (~> 0.2)
|
|
191
210
|
logger (~> 1.7)
|
|
192
211
|
minitest (~> 6.0)
|
|
@@ -195,8 +214,9 @@ DEPENDENCIES
|
|
|
195
214
|
os (~> 1.1)
|
|
196
215
|
qbash (~> 0.0)
|
|
197
216
|
rake (~> 13.2)
|
|
198
|
-
rdoc (~>
|
|
199
|
-
rubocop (~> 1.
|
|
217
|
+
rdoc (~> 8.0)
|
|
218
|
+
rubocop (~> 1.72)
|
|
219
|
+
rubocop-elegant (~> 0.5)
|
|
200
220
|
rubocop-minitest (~> 0.38)
|
|
201
221
|
rubocop-performance (~> 1.25)
|
|
202
222
|
rubocop-rake (~> 0.7)
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/yegor256/sibit/actions/workflows/rake.yml)
|
|
8
8
|
[](https://www.0pdd.com/p?name=yegor256/sibit)
|
|
9
9
|
[](https://badge.fury.io/rb/sibit)
|
|
10
|
-
[](https://github.com/yegor256/
|
|
10
|
+
[](https://github.com/yegor256/sibit/blob/master/LICENSE.txt)
|
|
11
11
|
[](https://codecov.io/github/yegor256/sibit?branch=master)
|
|
12
12
|
[](https://hitsofcode.com/view/github/yegor256/sibit)
|
|
13
13
|
|
|
@@ -80,7 +80,7 @@ Not all [UTXOs] may be used, but only the necessary amount of them.
|
|
|
80
80
|
|
|
81
81
|
By default, the fee is paid on top of the payment amount you are sending.
|
|
82
82
|
Say, you are sending 0.5 BTC and the fee is 0.0001 BTC.
|
|
83
|
-
|
|
83
|
+
In total, you spend 0.5001 BTC.
|
|
84
84
|
However, you can make Sibit deduct the fee from the payment amount.
|
|
85
85
|
In this case you should provide a negative amount
|
|
86
86
|
of the fee or one of `S-`, `M-`, `L-`, `XL-`.
|
|
@@ -91,6 +91,18 @@ It is recommended to run it with `--dry --verbose` options first,
|
|
|
91
91
|
If everything looks correct, remove the `--dry` and run again,
|
|
92
92
|
the transaction is pushed to the network.
|
|
93
93
|
|
|
94
|
+
To require a minimum number of confirmations on every UTXO before it is
|
|
95
|
+
spent, or before it counts toward the reported balance, pass `--trust`:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
sibit --trust=6 balance 1PfsYNygsuVL8fvBarJNQnHytkg4rGih1U
|
|
99
|
+
sibit --trust=6 pay 10000 S P1,P2 TARGET CHANGE
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The default is `0`, which preserves the existing behavior.
|
|
103
|
+
The same option is available from the Ruby SDK via the `trust:` keyword
|
|
104
|
+
argument on `Sibit#balance` and `Sibit#pay`.
|
|
105
|
+
|
|
94
106
|
To use an HTTPS proxy for all requests:
|
|
95
107
|
|
|
96
108
|
```bash
|
|
@@ -135,6 +147,7 @@ At the moment we work with the following APIs:
|
|
|
135
147
|
* [Bitcoinchain.com] - `Sibit::Bitcoinchain`
|
|
136
148
|
* [Blockchair.com] - `Sibit::Blockchair`
|
|
137
149
|
* [Cex.io] - `Sibit::Cex`
|
|
150
|
+
* [SoChain] - `Sibit::Sochain`
|
|
138
151
|
|
|
139
152
|
The first one in this list is used by default.
|
|
140
153
|
If you want to use a different one,
|
|
@@ -211,6 +224,7 @@ If it's clean and you don't see any error messages, submit your pull request.
|
|
|
211
224
|
[Cex.io]: https://cex.io/rest-api
|
|
212
225
|
[Cryptoapis.io]: https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index
|
|
213
226
|
[Electrum]: https://electrum.org/
|
|
227
|
+
[SoChain]: https://sochain.com/api
|
|
214
228
|
[miner fee]: https://en.bitcoin.it/wiki/Miner_fees
|
|
215
229
|
[private key]: https://en.bitcoin.it/wiki/Private_key
|
|
216
230
|
[Ruby]: https://www.ruby-lang.org/en/
|
data/Rakefile
CHANGED
|
@@ -35,7 +35,7 @@ task :picks do
|
|
|
35
35
|
next if OS.windows?
|
|
36
36
|
%w[lib].each do |d|
|
|
37
37
|
Dir["#{d}/**/*.rb"].each do |f|
|
|
38
|
-
qbash("bundle exec ruby #{Shellwords.escape(f)}",
|
|
38
|
+
qbash("bundle exec ruby #{Shellwords.escape(f)}", stdout: $stdout, env: { 'PICKS' => 'yes' })
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
end
|
data/bin/sibit
CHANGED
|
@@ -10,23 +10,25 @@ require 'backtrace'
|
|
|
10
10
|
require 'loog'
|
|
11
11
|
require_relative '../lib/sibit'
|
|
12
12
|
require_relative '../lib/sibit/bin'
|
|
13
|
-
require_relative '../lib/sibit/http'
|
|
14
|
-
require_relative '../lib/sibit/httpproxy'
|
|
15
13
|
require_relative '../lib/sibit/bitcoinchain'
|
|
16
14
|
require_relative '../lib/sibit/blockchain'
|
|
17
15
|
require_relative '../lib/sibit/blockchair'
|
|
18
16
|
require_relative '../lib/sibit/btc'
|
|
19
17
|
require_relative '../lib/sibit/cex'
|
|
18
|
+
require_relative '../lib/sibit/cryptoapis'
|
|
20
19
|
require_relative '../lib/sibit/dry'
|
|
21
20
|
require_relative '../lib/sibit/fake'
|
|
22
21
|
require_relative '../lib/sibit/firstof'
|
|
22
|
+
require_relative '../lib/sibit/http'
|
|
23
|
+
require_relative '../lib/sibit/httpproxy'
|
|
24
|
+
require_relative '../lib/sibit/sochain'
|
|
23
25
|
require_relative '../lib/sibit/version'
|
|
24
26
|
|
|
25
27
|
begin
|
|
26
28
|
Sibit::Bin.start(ARGV)
|
|
27
29
|
rescue StandardError => e
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
wants = ARGV.include?('--verbose') || ENV.fetch('SIBIT_VERBOSE', nil)
|
|
31
|
+
verbose = !ARGV.include?('--quiet') && wants
|
|
30
32
|
log = verbose ? Loog::VERBOSE : Loog::REGULAR
|
|
31
33
|
if verbose
|
|
32
34
|
log.error(Backtrace.new(e))
|
data/cross/alpine.df
ADDED
data/cross/centos.df
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
FROM quay.io/centos/centos:stream9
|
|
5
|
+
|
|
6
|
+
RUN dnf install -y epel-release && \
|
|
7
|
+
dnf config-manager --set-enabled crb && \
|
|
8
|
+
dnf install -y gcc make openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel tar && \
|
|
9
|
+
curl -fsSL https://github.com/rbenv/ruby-build/archive/refs/heads/master.tar.gz | tar -xz && \
|
|
10
|
+
PREFIX=/usr/local ./ruby-build-master/install.sh && \
|
|
11
|
+
ruby-build 3.2.6 /usr/local && \
|
|
12
|
+
rm -rf ruby-build-master && \
|
|
13
|
+
dnf clean all
|
data/cross/debian.df
ADDED
data/cross/fedora.df
ADDED
data/cross/opensuse.df
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
FROM opensuse/tumbleweed
|
|
5
|
+
|
|
6
|
+
RUN zypper --non-interactive install ruby ruby-devel gcc make libopenssl-devel bash && \
|
|
7
|
+
zypper clean --all && \
|
|
8
|
+
gem update --system --no-document && \
|
|
9
|
+
sed -i '/format.executable/d' /etc/gemrc
|
data/cross/rocky.df
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
FROM rockylinux:9
|
|
5
|
+
|
|
6
|
+
RUN dnf install -y epel-release && \
|
|
7
|
+
dnf config-manager --set-enabled crb && \
|
|
8
|
+
dnf install -y gcc make openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel tar && \
|
|
9
|
+
curl -fsSL https://github.com/rbenv/ruby-build/archive/refs/heads/master.tar.gz | tar -xz && \
|
|
10
|
+
PREFIX=/usr/local ./ruby-build-master/install.sh && \
|
|
11
|
+
ruby-build 3.2.6 /usr/local && \
|
|
12
|
+
rm -rf ruby-build-master && \
|
|
13
|
+
dnf clean all
|
data/cross/ubuntu.df
ADDED
data/features/cli.feature
CHANGED
|
@@ -44,6 +44,7 @@ Feature: Command Line Processing
|
|
|
44
44
|
When I run bin/sibit with "pay --help"
|
|
45
45
|
Then Exit code is zero
|
|
46
46
|
And Stdout contains "--skip-utxo"
|
|
47
|
+
And Stdout contains "--price"
|
|
47
48
|
|
|
48
49
|
Scenario: Unknown option shows error message
|
|
49
50
|
When I run bin/sibit with "generate --foo"
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
# SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
|
+
require 'English'
|
|
6
7
|
require 'nokogiri'
|
|
7
8
|
require 'tmpdir'
|
|
8
|
-
require 'English'
|
|
9
9
|
require_relative '../../lib/sibit'
|
|
10
10
|
|
|
11
11
|
Before do
|
|
@@ -32,19 +32,19 @@ When(%r{^I run bin/sibit with "([^"]*)"$}) do |arg|
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
Then(/^Stdout contains "([^"]*)"$/) do |txt|
|
|
35
|
-
raise "STDOUT doesn't contain '#{txt}':\n#{@stdout}" unless @stdout.include?(txt)
|
|
35
|
+
raise(StandardError, "STDOUT doesn't contain '#{txt}':\n#{@stdout}") unless @stdout.include?(txt)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
Then(/^Stdout is empty$/) do
|
|
39
|
-
raise "STDOUT is not empty:\n#{@stdout}" unless @stdout == ''
|
|
39
|
+
raise(StandardError, "STDOUT is not empty:\n#{@stdout}") unless @stdout == ''
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
Then(/^Exit code is zero$/) do
|
|
43
|
-
raise "Non-zero exit #{@exitstatus}:\n#{@stdout}" unless @exitstatus.zero?
|
|
43
|
+
raise(StandardError, "Non-zero exit #{@exitstatus}:\n#{@stdout}") unless @exitstatus.zero?
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
Then(/^Exit code is not zero$/) do
|
|
47
|
-
raise 'Zero exit code' if @exitstatus.zero?
|
|
47
|
+
raise(StandardError, 'Zero exit code') if @exitstatus.zero?
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
When(/^I run bash with "([^"]*)"$/) do |text|
|
data/features/support/env.rb
CHANGED
data/lib/sibit/base58.rb
CHANGED
|
@@ -23,28 +23,25 @@ class Sibit
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def encode
|
|
26
|
-
bytes = [@data].pack('H*')
|
|
27
|
-
leading = bytes.match(/^\x00*/)[0].length
|
|
28
26
|
num = @data.to_i(16)
|
|
29
27
|
result = ''
|
|
30
28
|
while num.positive?
|
|
31
29
|
num, remainder = num.divmod(58)
|
|
32
30
|
result = ALPHABET[remainder] + result
|
|
33
31
|
end
|
|
34
|
-
('1' *
|
|
32
|
+
('1' * [@data].pack('H*').match(/^\x00*/)[0].length) + result
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
def decode
|
|
38
|
-
leading = @data.match(/^1*/)[0].length
|
|
39
36
|
num = 0
|
|
40
37
|
@data.each_char do |c|
|
|
41
38
|
idx = ALPHABET.index(c)
|
|
42
|
-
raise
|
|
39
|
+
raise(Sibit::Error, "Invalid Base58 character '#{c}' in address '#{@data}'") if idx.nil?
|
|
43
40
|
num = (num * 58) + idx
|
|
44
41
|
end
|
|
45
42
|
hex = num.zero? ? '' : num.to_s(16)
|
|
46
43
|
hex = "0#{hex}" if hex.length.odd?
|
|
47
|
-
('00' *
|
|
44
|
+
('00' * @data.match(/^1*/)[0].length) + hex
|
|
48
45
|
end
|
|
49
46
|
|
|
50
47
|
def check
|
data/lib/sibit/bech32.rb
CHANGED
|
@@ -19,15 +19,13 @@ class Sibit
|
|
|
19
19
|
GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3].freeze
|
|
20
20
|
|
|
21
21
|
def self.encode(hrp, ver, prog)
|
|
22
|
-
|
|
23
|
-
data = [ver] + bits(bytes, 8, 5, true)
|
|
22
|
+
data = [ver] + bits([prog].pack('H*').bytes, 8, 5, true)
|
|
24
23
|
chk = checksum(hrp, data)
|
|
25
24
|
"#{hrp}1#{(data + chk).map { |d| CHARSET[d] }.join}"
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def self.checksum(hrp, data)
|
|
29
|
-
|
|
30
|
-
poly = pm(values) ^ 1
|
|
28
|
+
poly = pm(expanded(hrp) + data + [0, 0, 0, 0, 0, 0]) ^ 1
|
|
31
29
|
(0..5).map { |i| (poly >> (5 * (5 - i))) & 31 }
|
|
32
30
|
end
|
|
33
31
|
|
|
@@ -68,9 +66,8 @@ class Sibit
|
|
|
68
66
|
|
|
69
67
|
def witness
|
|
70
68
|
hrp, data = parse
|
|
71
|
-
raise
|
|
72
|
-
|
|
73
|
-
prog.pack('C*').unpack1('H*')
|
|
69
|
+
raise(Sibit::Error, "Invalid Bech32 checksum in '#{@addr}'") unless verified?(hrp, data)
|
|
70
|
+
convert(data[1..-7], 5, 8, false).pack('C*').unpack1('H*')
|
|
74
71
|
end
|
|
75
72
|
|
|
76
73
|
def version
|
|
@@ -82,18 +79,16 @@ class Sibit
|
|
|
82
79
|
|
|
83
80
|
def parse
|
|
84
81
|
pos = @addr.rindex('1')
|
|
85
|
-
raise
|
|
86
|
-
hrp = @addr[0...pos]
|
|
82
|
+
raise(Sibit::Error, "Invalid Bech32 address '#{@addr}': no separator") if pos.nil? || pos < 1
|
|
87
83
|
rest = @addr[(pos + 1)..]
|
|
88
|
-
raise
|
|
84
|
+
raise(Sibit::Error, "Invalid Bech32 address '#{@addr}': data too short") if rest.length < 6
|
|
89
85
|
data = rest.chars.map { |c| CHARSET.index(c) }
|
|
90
|
-
raise
|
|
91
|
-
[
|
|
86
|
+
raise(Sibit::Error, "Invalid Bech32 character in '#{@addr}'") if data.include?(nil)
|
|
87
|
+
[@addr[0...pos], data]
|
|
92
88
|
end
|
|
93
89
|
|
|
94
90
|
def verified?(hrp, data)
|
|
95
|
-
|
|
96
|
-
[1, 0x2bc830a3].include?(chk)
|
|
91
|
+
[1, 0x2bc830a3].include?(polymod(expand(hrp) + data))
|
|
97
92
|
end
|
|
98
93
|
|
|
99
94
|
def expand(hrp)
|
data/lib/sibit/bestof.rb
CHANGED
|
@@ -83,21 +83,24 @@ class Sibit::BestOf
|
|
|
83
83
|
private
|
|
84
84
|
|
|
85
85
|
def best_of(method)
|
|
86
|
-
return yield
|
|
86
|
+
return yield(@list) unless @list.is_a?(Array)
|
|
87
87
|
results = []
|
|
88
88
|
errors = []
|
|
89
89
|
@list.each do |api|
|
|
90
90
|
results << yield(api)
|
|
91
91
|
rescue Sibit::NotSupportedError
|
|
92
|
-
|
|
92
|
+
nil
|
|
93
93
|
rescue Sibit::Error => e
|
|
94
94
|
errors << e
|
|
95
95
|
@log.debug("The API #{api.class.name} failed at #{method}(): #{e.message}") if @verbose
|
|
96
96
|
end
|
|
97
97
|
if results.empty?
|
|
98
98
|
errors.each { |e| @log.debug(Backtrace.new(e).to_s) }
|
|
99
|
-
raise
|
|
100
|
-
|
|
99
|
+
raise(
|
|
100
|
+
Sibit::Error,
|
|
101
|
+
"No APIs out of #{@list.length} managed to succeed at #{method}(): " \
|
|
102
|
+
"#{@list.map { |a| a.class.name }.join(', ')}"
|
|
103
|
+
)
|
|
101
104
|
end
|
|
102
105
|
results.group_by(&:to_s).values.max_by(&:size)[0]
|
|
103
106
|
end
|