zold 0.31.0 → 0.31.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaf97f12668652e8dea6097810416c2440e331366963239e3f2a2610bda97cef
4
- data.tar.gz: 771ed9e0c1457455b88ea7d9acfbfb5f7bd42682839080ba19a302e89378a682
3
+ metadata.gz: a6c2e0650ee2719c29b2be5d2a89e2d8df6a5fe5eec198ded0b2a2406bc7c0d0
4
+ data.tar.gz: f2759aa84462712e1351288c315b9c13021beb5c0c9eb69e5a78f9974e1b7a5e
5
5
  SHA512:
6
- metadata.gz: e39d881c991fe021ecee054683f598b93cda07cb968c999699ddb61d9ec0d56848ce7e345d914e466065533f541eb60335bfe9d43c115c5d3809d9b5e565911c
7
- data.tar.gz: cbe18090d252ee05c8aa16d0445fff773d1479086e187649593bc268f70de328e2dba6f7c4eed40ee974adf68c062dd50e1f08a9cec456d870fa066a00c3866d
6
+ metadata.gz: 9109e7e7cd1afe84a2dcddcf74ff24a6489049fd99c75d556e8ec58f75fe4556775e5ca860f2ae58a40e6bfa1df71d5850781d385709d40466a045af7329bc82
7
+ data.tar.gz: bcd96058d3dc22767340e39862cd6e5d0aa5100ab666ef68bac48fbea937b44a2561ca773c7a88dfa88ac3177231a7a7eb29736338184a0ff8e49dfe9dad3355
@@ -17,6 +17,7 @@ module Zold
17
17
  end
18
18
 
19
19
  def run(args = [])
20
+ @log.debug("Alias.run(#{args.join(' ')})")
20
21
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
21
22
  o.banner = "Usage: zold alias [args]
22
23
  #{Rainbow('alias set <wallet> <alias>').green}
@@ -39,6 +39,7 @@ module Zold
39
39
  end
40
40
 
41
41
  def run(args = [])
42
+ @log.debug("Calculate.run(#{args.join(' ')})")
42
43
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
43
44
  o.banner = "Usage: zold score [options]
44
45
  Available options:"
@@ -50,6 +50,7 @@ module Zold
50
50
  end
51
51
 
52
52
  def run(args = [])
53
+ @log.debug("Clean.run(#{args.join(' ')})")
53
54
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
54
55
  o.banner = "Usage: zold clean [ID...] [options]
55
56
  Available options:"
@@ -44,6 +44,7 @@ module Zold
44
44
  end
45
45
 
46
46
  def run(args = [])
47
+ @log.debug("Create.run(#{args.join(' ')})")
47
48
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
48
49
  o.banner = "Usage: zold create [options]
49
50
  Available options:"
@@ -46,6 +46,7 @@ module Zold
46
46
  end
47
47
 
48
48
  def run(args = [])
49
+ @log.debug("Diff.run(#{args.join(' ')})")
49
50
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
50
51
  o.banner = "Usage: zold diff [ID...] [options]
51
52
  Available options:"
@@ -70,6 +70,7 @@ module Zold
70
70
  end
71
71
 
72
72
  def run(args = [])
73
+ @log.debug("Fetch.run(#{args.join(' ')})")
73
74
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
74
75
  o.banner = "Usage: zold fetch [ID...] [options]
75
76
  Available options:"
@@ -44,6 +44,7 @@ module Zold
44
44
  end
45
45
 
46
46
  def run(args = [])
47
+ @log.debug("Invoice.run(#{args.join(' ')})")
47
48
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
48
49
  o.banner = "Usage: zold invoice ID [options]
49
50
  Where:
@@ -51,6 +51,7 @@ module Zold
51
51
 
52
52
  # Returns the array of modified wallets (IDs)
53
53
  def run(args = [])
54
+ @log.debug("Merge.run(#{args.join(' ')})")
54
55
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
55
56
  o.banner = "Usage: zold merge [ID...] [options]
56
57
  Available options:"
@@ -39,6 +39,7 @@ module Zold
39
39
  end
40
40
 
41
41
  def run(args = [])
42
+ @log.debug("Next.run(#{args.join(' ')})")
42
43
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
43
44
  o.banner = "Usage: zold next [options] score
44
45
  Available options:"
@@ -73,6 +73,7 @@ module Zold
73
73
  end
74
74
 
75
75
  def run(args = [])
76
+ @log.debug("Node.run(#{args.join(' ')})")
76
77
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
77
78
  o.banner = 'Usage: zold node [options]'
78
79
  o.string '--invoice',
@@ -48,6 +48,7 @@ module Zold
48
48
  # Sends a payment and returns the transaction just created in the
49
49
  # paying wallet, an instance of Zold::Txn
50
50
  def run(args = [])
51
+ @log.debug("Pay.run(#{args.join(' ')})")
51
52
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
52
53
  o.banner = "Usage: zold pay wallet target amount [details] [options]
53
54
  Where:
@@ -84,6 +85,9 @@ Available options:"
84
85
  o.bool '--dont-pay-taxes',
85
86
  'Don\'t pay taxes even if the wallet is in debt',
86
87
  default: false
88
+ o.bool '--pay-taxes-anyway',
89
+ 'Pay taxes even if the wallet is not in debt',
90
+ default: false
87
91
  o.bool '--skip-propagate',
88
92
  'Don\'t propagate the paying wallet after successful pay',
89
93
  default: false
@@ -128,17 +132,18 @@ Available options:"
128
132
  raise "Wallet #{id} doesn't exist, do 'zold pull' first" unless wallet.exists?
129
133
  Tax.new(wallet).in_debt? && !opts['dont-pay-taxes']
130
134
  end
131
- return unless debt
135
+ return unless debt || opts['pay-taxes-anyway']
132
136
  require_relative 'taxes'
133
137
  Taxes.new(wallets: @wallets, remotes: @remotes, log: @log).run(
134
138
  [
135
139
  'taxes',
136
140
  'pay',
137
141
  "--private-key=#{Shellwords.escape(opts['private-key'])}",
142
+ opts['pay-taxes-anyway'] ? '--pay-anyway' : '',
138
143
  opts['ignore-score-weakness'] ? '--ignore-score-weakness' : '',
139
144
  id.to_s,
140
145
  "--keygap=#{Shellwords.escape(opts['keygap'])}"
141
- ]
146
+ ].reject(&:empty?)
142
147
  )
143
148
  end
144
149
 
@@ -46,6 +46,7 @@ module Zold
46
46
 
47
47
  # Returns list of Wallet IDs which were affected
48
48
  def run(args = [])
49
+ @log.debug("Propagate.run(#{args.join(' ')})")
49
50
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
50
51
  o.banner = "Usage: zold propagate [ID...] [options]
51
52
  Available options:"
@@ -59,6 +59,7 @@ module Zold
59
59
  end
60
60
 
61
61
  def run(args = [])
62
+ @log.debug("Push.run(#{args.join(' ')})")
62
63
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
63
64
  o.banner = "Usage: zold push [ID...] [options]
64
65
  Available options:"
@@ -54,6 +54,7 @@ module Zold
54
54
  end
55
55
 
56
56
  def run(args = [])
57
+ @log.debug("Remote.run(#{args.join(' ')})")
57
58
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
58
59
  o.banner = "Usage: zold remote <command> [options]
59
60
  Available commands:
@@ -41,6 +41,7 @@ module Zold
41
41
  end
42
42
 
43
43
  def run(args = [])
44
+ @log.debug("Remove.run(#{args.join(' ')})")
44
45
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
45
46
  o.banner = "Usage: zold remove [ID...] [options]
46
47
  Available options:"
@@ -48,6 +48,7 @@ module Zold
48
48
  end
49
49
 
50
50
  def run(args = [])
51
+ @log.debug("Show.run(#{args.join(' ')})")
51
52
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
52
53
  o.banner = "Usage: zold show [ID...] [options]
53
54
  Available options:"
@@ -61,6 +61,7 @@ module Zold
61
61
  end
62
62
 
63
63
  def run(args = [])
64
+ @log.debug("Taxes.run(#{args.join(' ')})")
64
65
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
65
66
  o.banner = "Usage: zold taxes command [options]
66
67
  Available commands:
@@ -75,6 +76,9 @@ Available options:"
75
76
  'The location of RSA private key (default: ~/.ssh/id_rsa)',
76
77
  require: true,
77
78
  default: '~/.ssh/id_rsa'
79
+ o.bool '--pay-anyway',
80
+ 'Pay taxes anyway, even if the wallet is not in debt',
81
+ default: false
78
82
  o.bool '--ignore-score-weakness',
79
83
  'Don\'t complain when their score is too weak',
80
84
  default: false
@@ -123,7 +127,7 @@ Available options:"
123
127
  debt = total = tax.debt
124
128
  @log.info("The current debt of #{wallet.mnemo} is #{debt} (#{debt.to_i} zents), \
125
129
  the balance is #{wallet.balance}: #{tax.to_text}")
126
- unless tax.in_debt?
130
+ unless tax.in_debt? || opts['pay-anyway']
127
131
  @log.debug("No need to pay taxes yet, while the debt is less than #{Tax::TRIAL} (#{Tax::TRIAL.to_i} zents)")
128
132
  return
129
133
  end
data/lib/zold/version.rb CHANGED
@@ -25,7 +25,7 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.31.0'
28
+ VERSION = '0.31.1'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -172,6 +172,7 @@ class TestPay < Zold::Test
172
172
  Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: accumulating_log).run(
173
173
  [
174
174
  'pay', '--force', '--private-key=fixtures/id_rsa',
175
+ '--ignore-score-weakness', '--pay-taxes-anyway',
175
176
  source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
176
177
  ]
177
178
  )
@@ -179,4 +180,42 @@ class TestPay < Zold::Test
179
180
  'No info_messages notified user of tax debt'
180
181
  end
181
182
  end
183
+
184
+ def test_pays_and_taxes
185
+ FakeHome.new(log: test_log).run do |home|
186
+ wallet = home.create_wallet
187
+ fund = Zold::Amount.new(zld: 19.99)
188
+ 10.times do |i|
189
+ wallet.add(
190
+ Zold::Txn.new(
191
+ i + 1,
192
+ Time.now - 24 * 60 * 60 * 365 * 300,
193
+ fund,
194
+ 'NOPREFIX', Zold::Id.new, '-'
195
+ )
196
+ )
197
+ end
198
+ score = Zold::Score.new(host: 'localhost', port: 80, strength: 1, invoice: 'NOPREFIX@0000000000000000')
199
+ 10.times { score = score.next }
200
+ remotes = home.remotes
201
+ remotes.add(score.host, score.port)
202
+ stub_request(:get, "http://#{score.host}:#{score.port}/").to_return(
203
+ status: 200,
204
+ body: {
205
+ score: score.to_h
206
+ }.to_json
207
+ )
208
+ before = wallet.balance
209
+ target = home.create_wallet
210
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: remotes, log: test_log).run(
211
+ [
212
+ 'pay', '--force', '--private-key=fixtures/id_rsa',
213
+ '--ignore-score-weakness',
214
+ wallet.id.to_s, target.id.to_s, fund.to_zld, 'For the car'
215
+ ]
216
+ )
217
+ wallet.flush
218
+ assert(before.to_zld(6) != wallet.balance.to_zld(6))
219
+ end
220
+ end
182
221
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-04 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -823,7 +823,7 @@ licenses:
823
823
  - MIT
824
824
  metadata: {}
825
825
  post_install_message: |-
826
- Thanks for installing Zold 0.31.0!
826
+ Thanks for installing Zold 0.31.1!
827
827
  Study our White Paper: https://papers.zold.io/wp.pdf
828
828
  Read our blog posts: https://blog.zold.io
829
829
  Try ZLD online wallet at: https://wts.zold.io