sibit 0.32.6 → 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/lib/sibit/version.rb +1 -1
- data/lib/sibit.rb +15 -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/lib/sibit/version.rb
CHANGED
data/lib/sibit.rb
CHANGED
|
@@ -59,7 +59,7 @@ class Sibit
|
|
|
59
59
|
|
|
60
60
|
# Creates Bitcoin address using the private key in Hash160 format.
|
|
61
61
|
def create(pvt)
|
|
62
|
-
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)
|
|
63
63
|
Key.new(pvt).bech32
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -105,8 +105,21 @@ class Sibit
|
|
|
105
105
|
# +change+: the address where the change has to be sent to
|
|
106
106
|
# +network+: optional network override (:mainnet, :testnet, :regtest)
|
|
107
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)
|
|
108
115
|
p = price('USD')
|
|
109
|
-
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
|
|
110
123
|
network = keys.first&.network || :mainnet
|
|
111
124
|
sources = keys.to_h do |k|
|
|
112
125
|
pub =
|