zold 0.31.0 → 0.31.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.
- checksums.yaml +4 -4
- data/lib/zold/commands/alias.rb +1 -0
- data/lib/zold/commands/calculate.rb +1 -0
- data/lib/zold/commands/clean.rb +1 -0
- data/lib/zold/commands/create.rb +1 -0
- data/lib/zold/commands/diff.rb +1 -0
- data/lib/zold/commands/fetch.rb +1 -0
- data/lib/zold/commands/invoice.rb +1 -0
- data/lib/zold/commands/merge.rb +1 -0
- data/lib/zold/commands/next.rb +1 -0
- data/lib/zold/commands/node.rb +1 -0
- data/lib/zold/commands/pay.rb +7 -2
- data/lib/zold/commands/propagate.rb +1 -0
- data/lib/zold/commands/push.rb +1 -0
- data/lib/zold/commands/remote.rb +1 -0
- data/lib/zold/commands/remove.rb +1 -0
- data/lib/zold/commands/show.rb +1 -0
- data/lib/zold/commands/taxes.rb +5 -1
- data/lib/zold/version.rb +1 -1
- data/test/commands/test_pay.rb +39 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6c2e0650ee2719c29b2be5d2a89e2d8df6a5fe5eec198ded0b2a2406bc7c0d0
|
4
|
+
data.tar.gz: f2759aa84462712e1351288c315b9c13021beb5c0c9eb69e5a78f9974e1b7a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9109e7e7cd1afe84a2dcddcf74ff24a6489049fd99c75d556e8ec58f75fe4556775e5ca860f2ae58a40e6bfa1df71d5850781d385709d40466a045af7329bc82
|
7
|
+
data.tar.gz: bcd96058d3dc22767340e39862cd6e5d0aa5100ab666ef68bac48fbea937b44a2561ca773c7a88dfa88ac3177231a7a7eb29736338184a0ff8e49dfe9dad3355
|
data/lib/zold/commands/alias.rb
CHANGED
data/lib/zold/commands/clean.rb
CHANGED
data/lib/zold/commands/create.rb
CHANGED
data/lib/zold/commands/diff.rb
CHANGED
data/lib/zold/commands/fetch.rb
CHANGED
data/lib/zold/commands/merge.rb
CHANGED
@@ -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:"
|
data/lib/zold/commands/next.rb
CHANGED
data/lib/zold/commands/node.rb
CHANGED
data/lib/zold/commands/pay.rb
CHANGED
@@ -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:"
|
data/lib/zold/commands/push.rb
CHANGED
data/lib/zold/commands/remote.rb
CHANGED
data/lib/zold/commands/remove.rb
CHANGED
data/lib/zold/commands/show.rb
CHANGED
data/lib/zold/commands/taxes.rb
CHANGED
@@ -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
data/test/commands/test_pay.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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
|