sibit 0.32.0 → 0.32.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sibit +21 -23
  3. data/lib/sibit/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccc8435725361e992237efffbe4f53e4f6698e8217cbac39ce0f08f8b407cb68
4
- data.tar.gz: 8a787c829a4539a6b69be2764ef90b09e61b13797375b382e6a4df69826165cf
3
+ metadata.gz: c756b3d04936258f2bfa46b7a385fbb3f5f9ca696728dc2895504b1f5691e65c
4
+ data.tar.gz: 3d88e0ab75c369c989dfaf360a4b332ac0d5e7479f8e9657734d710e58b712ee
5
5
  SHA512:
6
- metadata.gz: 253013c5f6b978ea0db8ea3c2800aad241e2d277fbd743f21130dff952610b37fc27366ec8e67728dba64a97efbe1750c1dd7455faf991e856e8af5d06f52e88
7
- data.tar.gz: ce524cedb5ae7420113a0d9f6526792f9c47dee863724e64adf7909b94aca0ede25cee286f203063ff65166e00c58512b6310f6ced1ee52a28bd7516ab563e9c
6
+ metadata.gz: 4c385350b69515c9a92a32901afd99685dca40cfc38f85be613e7527421b29481a838eceb6cc21ec1bdce70deee2b8d295806118c8039f7bb78a3fd80547ac70
7
+ data.tar.gz: acba7a669a53cbb92918751723e9d09a690b1f4e927f275d97633d9e538317bd4c00a355326ee0aa0fbd11a873a41fdf721570f32d73d56ef40fdc489d132b10
data/bin/sibit CHANGED
@@ -24,7 +24,8 @@ require_relative '../lib/sibit/fake'
24
24
  require_relative '../lib/sibit/firstof'
25
25
  require_relative '../lib/sibit/version'
26
26
 
27
- VERBOSE = ARGV.include?('--verbose') || ENV.fetch('SIBIT_VERBOSE', nil)
27
+ VERBOSE = !ARGV.include?('--quiet') &&
28
+ (ARGV.include?('--verbose') || ENV.fetch('SIBIT_VERBOSE', nil))
28
29
  LOG = VERBOSE ? Loog::VERBOSE : Loog::REGULAR
29
30
 
30
31
  # Command-line interface for Sibit.
@@ -36,6 +37,7 @@ class Bin < Thor
36
37
  class_option :dry, type: :boolean, default: false,
37
38
  desc: "Don't send a real payment, run in a read-only mode"
38
39
  class_option :verbose, type: :boolean, default: false, desc: 'Print all possible debug messages'
40
+ class_option :quiet, type: :boolean, default: false, desc: 'Print only informative messages'
39
41
  class_option :api, type: :array, default: %w[blockchain btc bitcoinchain blockchair cex],
40
42
  desc: 'Ordered List of APIs to use, e.g. "blockchain,btc,bitcoinchain"'
41
43
 
@@ -50,7 +52,7 @@ class Bin < Thor
50
52
 
51
53
  desc 'price', 'Get current price of BTC in USD'
52
54
  def price
53
- log.info(client.price)
55
+ LOG.info(client.price)
54
56
  end
55
57
 
56
58
  desc 'fees', 'Get currently recommended transaction fees'
@@ -62,28 +64,28 @@ class Bin < Thor
62
64
  usd = sat * sibit.price / 100_000_000
63
65
  "#{m}: #{sat}sat / $#{format('%<usd>.02f', usd: usd)}"
64
66
  end.join("\n")
65
- log.info(text)
67
+ LOG.info(text)
66
68
  end
67
69
 
68
70
  desc 'latest', 'Get hash of the latest block'
69
71
  def latest
70
- log.info(client.latest)
72
+ LOG.info(client.latest)
71
73
  end
72
74
 
73
75
  desc 'generate', 'Generate a new private key'
74
76
  def generate
75
- log.info(client.generate)
77
+ LOG.info(client.generate)
76
78
  end
77
79
 
78
80
  desc 'create KEY', 'Create a public Bitcoin address from the private key'
79
81
  def create(key)
80
- log.debug("Private key provided: #{key.ellipsized(8).inspect}")
81
- log.info(client.create(key))
82
+ LOG.debug("Private key provided: #{key.ellipsized(8).inspect}")
83
+ LOG.info(client.create(key))
82
84
  end
83
85
 
84
86
  desc 'balance ADDRESS', 'Check the balance of the Bitcoin address'
85
87
  def balance(address)
86
- log.info(client.balance(address))
88
+ LOG.info(client.balance(address))
87
89
  end
88
90
 
89
91
  desc 'pay AMOUNT FEE SOURCES TARGET CHANGE',
@@ -108,46 +110,42 @@ class Bin < Thor
108
110
  answer = $stdin.gets&.strip&.downcase
109
111
  raise Sibit::Error, 'Payment cancelled by user' unless answer == 'yes'
110
112
  end
111
- log.info(client.pay(*args, **kwargs))
113
+ LOG.info(client.pay(*args, **kwargs))
112
114
  end
113
115
 
114
116
  desc 'version', 'Print program version'
115
117
  def version
116
- log.info(Sibit::VERSION)
118
+ LOG.info(Sibit::VERSION)
117
119
  end
118
120
 
119
121
  private
120
122
 
121
- def log
122
- LOG
123
- end
124
-
125
123
  def client(dry: false)
126
124
  proxy = options[:proxy] || ENV.fetch('SIBIT_PROXY', nil)
127
125
  http = proxy ? Sibit::HttpProxy.new(proxy) : Sibit::Http.new
128
- log.debug("Using proxy at #{http.host}") if proxy
126
+ LOG.debug("Using proxy at #{http.host}") if proxy
129
127
  apis = options[:api].flat_map { |a| a.split(',') }.map(&:downcase).map do |a|
130
128
  case a
131
129
  when 'blockchain'
132
- Sibit::Blockchain.new(http: http, log: log)
130
+ Sibit::Blockchain.new(http: http, log: LOG)
133
131
  when 'btc'
134
- Sibit::Btc.new(http: http, log: log)
132
+ Sibit::Btc.new(http: http, log: LOG)
135
133
  when 'bitcoinchain'
136
- Sibit::Bitcoinchain.new(http: http, log: log)
134
+ Sibit::Bitcoinchain.new(http: http, log: LOG)
137
135
  when 'blockchair'
138
- Sibit::Blockchair.new(http: http, log: log)
136
+ Sibit::Blockchair.new(http: http, log: LOG)
139
137
  when 'cex'
140
- Sibit::Cex.new(http: http, log: log)
138
+ Sibit::Cex.new(http: http, log: LOG)
141
139
  when 'fake'
142
140
  Sibit::Fake.new
143
141
  else
144
142
  raise Sibit::Error, "Unknown API \"#{a}\""
145
143
  end
146
144
  end
147
- api = Sibit::FirstOf.new(apis, log: log, verbose: true)
148
- api = Sibit::Dry.new(api, log: log) if options[:dry] || dry
145
+ api = Sibit::FirstOf.new(apis, log: LOG, verbose: true)
146
+ api = Sibit::Dry.new(api, log: LOG) if options[:dry] || dry
149
147
  api = RetriableProxy.for_object(api, on: Sibit::Error) if options[:attempts] > 1
150
- Sibit.new(log: log, api: api)
148
+ Sibit.new(log: LOG, api: api)
151
149
  end
152
150
  end
153
151
 
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.0' unless defined?(VERSION)
12
+ VERSION = '0.32.1' unless defined?(VERSION)
13
13
  end
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.0
4
+ version: 0.32.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko