sibit 0.32.5 → 0.32.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/sibit/bin.rb +8 -5
- data/lib/sibit/version.rb +1 -1
- data/lib/sibit.rb +16 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 759028cb2cfe895ec5f71b65a19b0cf2ea6e4cf190b8754196a9b62366095ff8
|
|
4
|
+
data.tar.gz: 49129fb0e16c0554ef74d9a94b2d40a6eb08e4e8c92b41c8079887ee180b0cbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4ef5e308449ad6342a3df1834fdd2d14511d3bcaaac4f180af4ac9d2a424493abc90c6660b119b5e688994f09db6d5393b88f710ad4f261711ca7bac4f0eeec
|
|
7
|
+
data.tar.gz: a38f706880d1e63ac4264926199152aae8e5aab401754f58f20f301227bbdecb89ef01327f9837605f9f5ee1d0c4b276ff4f109fb1e28e151544b390b4ebc704
|
data/Gemfile.lock
CHANGED
|
@@ -57,7 +57,7 @@ GEM
|
|
|
57
57
|
cucumber-messages (>= 31, < 32)
|
|
58
58
|
cucumber-html-formatter (22.3.0)
|
|
59
59
|
cucumber-messages (> 23, < 33)
|
|
60
|
-
cucumber-messages (31.
|
|
60
|
+
cucumber-messages (31.2.0)
|
|
61
61
|
cucumber-tag-expressions (8.1.0)
|
|
62
62
|
date (3.5.1)
|
|
63
63
|
decoor (0.1.0)
|
|
@@ -67,7 +67,7 @@ GEM
|
|
|
67
67
|
backtrace (~> 0.3)
|
|
68
68
|
os (~> 1.1)
|
|
69
69
|
qbash (~> 0.3)
|
|
70
|
-
elapsed (0.2.
|
|
70
|
+
elapsed (0.2.2)
|
|
71
71
|
loog (~> 0.6)
|
|
72
72
|
tago (~> 0.1)
|
|
73
73
|
ellipsized (0.3.0)
|
data/lib/sibit/bin.rb
CHANGED
|
@@ -22,13 +22,16 @@ class Sibit
|
|
|
22
22
|
class Bin < Thor
|
|
23
23
|
stop_on_unknown_option!
|
|
24
24
|
|
|
25
|
-
class_option :proxy, type: :string,
|
|
25
|
+
class_option :proxy, type: :string,
|
|
26
|
+
desc: 'HTTPS proxy for all requests, e.g. "localhost:3128"'
|
|
26
27
|
class_option :attempts, type: :numeric, default: 1,
|
|
27
28
|
desc: 'How many times should we try before failing'
|
|
28
29
|
class_option :dry, type: :boolean, default: false,
|
|
29
30
|
desc: "Don't send a real payment, run in a read-only mode"
|
|
30
|
-
class_option :verbose, type: :boolean, default: false,
|
|
31
|
-
|
|
31
|
+
class_option :verbose, type: :boolean, default: false,
|
|
32
|
+
desc: 'Print all possible debug messages'
|
|
33
|
+
class_option :quiet, type: :boolean, default: false,
|
|
34
|
+
desc: 'Print only informative messages'
|
|
32
35
|
class_option :api, type: :array, default: %w[blockchain btc bitcoinchain blockchair cex],
|
|
33
36
|
desc: 'Ordered List of APIs to use, e.g. "blockchain,btc,bitcoinchain"'
|
|
34
37
|
class_option :base58, type: :boolean, default: false,
|
|
@@ -125,8 +128,8 @@ class Sibit
|
|
|
125
128
|
|
|
126
129
|
def log
|
|
127
130
|
@log ||= begin
|
|
128
|
-
verbose = !
|
|
129
|
-
(
|
|
131
|
+
verbose = !options[:quiet] &&
|
|
132
|
+
(options[:verbose] || ENV.fetch('SIBIT_VERBOSE', nil))
|
|
130
133
|
verbose ? Loog::VERBOSE : Loog::REGULAR
|
|
131
134
|
end
|
|
132
135
|
end
|
data/lib/sibit/version.rb
CHANGED
data/lib/sibit.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
|
+
require 'ellipsized'
|
|
6
7
|
require 'loog'
|
|
7
8
|
require_relative 'sibit/base58'
|
|
8
9
|
require_relative 'sibit/key'
|
|
@@ -58,7 +59,7 @@ class Sibit
|
|
|
58
59
|
|
|
59
60
|
# Creates Bitcoin address using the private key in Hash160 format.
|
|
60
61
|
def create(pvt)
|
|
61
|
-
raise Error, 'Invalid private key (must be 64 chars)' unless /^[0-9a-f]{64}$/.match?(pvt)
|
|
62
|
+
raise Error, 'Invalid private key (must be 64 hex chars)' unless /^[0-9a-f]{64}$/.match?(pvt)
|
|
62
63
|
Key.new(pvt).bech32
|
|
63
64
|
end
|
|
64
65
|
|
|
@@ -104,8 +105,21 @@ class Sibit
|
|
|
104
105
|
# +change+: the address where the change has to be sent to
|
|
105
106
|
# +network+: optional network override (:mainnet, :testnet, :regtest)
|
|
106
107
|
def pay(amount, fee, sources, target, change, skip_utxo: [], network: nil, base58: false)
|
|
108
|
+
unless amount.is_a?(Integer) || amount.is_a?(String)
|
|
109
|
+
raise Error, "The amount #{amount.inspect} must be Integer or String"
|
|
110
|
+
end
|
|
111
|
+
raise Error, 'The amount must be positive' if amount.is_a?(Integer) && amount.negative?
|
|
112
|
+
raise Error, 'The sources must be an Array' unless sources.is_a?(Array)
|
|
113
|
+
raise Error, 'The target must be a String' unless target.is_a?(String)
|
|
114
|
+
raise Error, 'The change must be a String' unless change.is_a?(String)
|
|
107
115
|
p = price('USD')
|
|
108
|
-
keys = sources.map
|
|
116
|
+
keys = sources.map do |k|
|
|
117
|
+
raise Error, 'Each source private key must be a String' unless k.is_a?(String)
|
|
118
|
+
hex = /^[0-9a-f]{64}$/i.match?(k)
|
|
119
|
+
wif = /^[5KLc][1-9A-HJ-NP-Za-km-z]{50,51}$/.match?(k)
|
|
120
|
+
raise Error, "Invalid private key format: #{k.inspect.ellipsized(8)}" unless hex || wif
|
|
121
|
+
Key.new(k, network: network)
|
|
122
|
+
end
|
|
109
123
|
network = keys.first&.network || :mainnet
|
|
110
124
|
sources = keys.to_h do |k|
|
|
111
125
|
pub =
|