sibit 0.32.8 → 0.33.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/features/cli.feature +1 -0
- data/lib/sibit/bin.rb +3 -1
- data/lib/sibit/version.rb +1 -1
- data/lib/sibit.rb +4 -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: 7fc905f4a84df3f625583d1d3b628d1639e830daec2fb9f729a2361bdbc79443
|
|
4
|
+
data.tar.gz: 95957394b7411ce0140b765f3806d9869854666d5a882a00aa7b2a5f70b9fc4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68030b89ec041f142967f24f3d84ce481330ccb5828da88902aed944be0b26452f45fa361fb503b83feac2242ff4a284d2fa530cb6381da634258927a9ce06b4
|
|
7
|
+
data.tar.gz: 2d206f21e0129d28ef450c63afbf18b6d9c7a70a45a583d4b9554ead31fc598dab9af208bdced8744e3e92b9f56035451c6760f58df6d6152e935e18f491c93f
|
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"
|
data/lib/sibit/bin.rb
CHANGED
|
@@ -97,6 +97,8 @@ class Sibit
|
|
|
97
97
|
desc: 'List of UTXO that must be skipped while paying'
|
|
98
98
|
option :yes, type: :boolean, default: false,
|
|
99
99
|
desc: 'Skip confirmation prompt and send the payment immediately'
|
|
100
|
+
option :price, type: :numeric,
|
|
101
|
+
desc: 'BTC price in USD (skips API price fetch if provided)'
|
|
100
102
|
def pay(amount, fee, sources, target, change)
|
|
101
103
|
keys = sources.split(',')
|
|
102
104
|
if amount.upcase == 'MAX'
|
|
@@ -109,7 +111,7 @@ class Sibit
|
|
|
109
111
|
amount = amount.to_i if amount.is_a?(String) && /^[0-9]+$/.match?(amount)
|
|
110
112
|
fee = fee.to_i if /^[0-9]+$/.match?(fee)
|
|
111
113
|
args = [amount, fee, keys, target, change]
|
|
112
|
-
kwargs = { skip_utxo: options[:skip_utxo], base58: options[:base58] }
|
|
114
|
+
kwargs = { skip_utxo: options[:skip_utxo], base58: options[:base58], price: options[:price] }
|
|
113
115
|
unless options[:yes] || options[:dry]
|
|
114
116
|
client(dry: true).pay(*args, **kwargs)
|
|
115
117
|
print 'Do you confirm this payment? (yes/no): '
|
data/lib/sibit/version.rb
CHANGED
data/lib/sibit.rb
CHANGED
|
@@ -104,7 +104,9 @@ class Sibit
|
|
|
104
104
|
# +target+: the target address to send to
|
|
105
105
|
# +change+: the address where the change has to be sent to
|
|
106
106
|
# +network+: optional network override (:mainnet, :testnet, :regtest)
|
|
107
|
-
|
|
107
|
+
# +price+: optional BTC price in USD (skips API fetch if provided)
|
|
108
|
+
def pay(amount, fee, sources, target, change, skip_utxo: [], network: nil, base58: false,
|
|
109
|
+
price: nil)
|
|
108
110
|
unless amount.is_a?(Integer) || amount.is_a?(String)
|
|
109
111
|
raise Error, "The amount #{amount.inspect} must be Integer or String"
|
|
110
112
|
end
|
|
@@ -112,7 +114,7 @@ class Sibit
|
|
|
112
114
|
raise Error, 'The sources must be an Array' unless sources.is_a?(Array)
|
|
113
115
|
raise Error, 'The target must be a String' unless target.is_a?(String)
|
|
114
116
|
raise Error, 'The change must be a String' unless change.is_a?(String)
|
|
115
|
-
p = price('USD')
|
|
117
|
+
p = price || price('USD')
|
|
116
118
|
keys = sources.map do |k|
|
|
117
119
|
raise Error, 'Each source private key must be a String' unless k.is_a?(String)
|
|
118
120
|
hex = /^[0-9a-f]{64}$/i.match?(k)
|