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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dbaecce413d6a977eee8d4d440a066a666f2054ad7d2b4cec0b21c6da4efe8e
4
- data.tar.gz: 39431e80439522e9d000404ee29856f558ba3b4406976e9345e550f4efbf3974
3
+ metadata.gz: 7fc905f4a84df3f625583d1d3b628d1639e830daec2fb9f729a2361bdbc79443
4
+ data.tar.gz: 95957394b7411ce0140b765f3806d9869854666d5a882a00aa7b2a5f70b9fc4d
5
5
  SHA512:
6
- metadata.gz: dc62197de1ada4a3e155148fa09926ffd02861178f1049203b1212a363b60d01d11fe3881f3e61d86a57b666464084d511aec4b4664e8fd038904468b9fb315f
7
- data.tar.gz: f1ec0c729a1ccca0b2b9728ea23348db8cb5e5d80b22ec06dc33a682fb04a76c47cd0b487d578d8b19d2e62dfb7ac3c4f638aac03a9f8fa7a4c791f882e10259
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
@@ -9,5 +9,5 @@
9
9
  # License:: MIT
10
10
  class Sibit
11
11
  # Current version of the library.
12
- VERSION = '0.32.8' unless defined?(VERSION)
12
+ VERSION = '0.33.0' unless defined?(VERSION)
13
13
  end
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
- def pay(amount, fee, sources, target, change, skip_utxo: [], network: nil, base58: false)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.8
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko