zold 0.23.5 → 0.23.6

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: 8067a4751084cd631f09a99d4ce58f8cae3ee3d7186662bcaae2b871ad4922a5
4
- data.tar.gz: d7ca7a6de3956c40b6f1c9a2c0b5512f44ab26737e02725a2b9895e9673b21e1
3
+ metadata.gz: a34afacddd1a7754e904735a1260ae2502c12fd814bcc99df8b2f473442b1d67
4
+ data.tar.gz: 17cfee268ef91e6e2cfdbdf0b8a9a221c9728baedb9daaf93244fc3a85a7b9d0
5
5
  SHA512:
6
- metadata.gz: a37b34395f2bd295a58ca9a87ed52a1a6b156e3ce5cba27431e597003a067ffc204d6409e955aa6a6590abb3ca66579820f1ebcef4879c712d8090e2465f994f
7
- data.tar.gz: 89dee647bf855e393aa19d22790dd76b25903ff84b3513e6118708b3393e74f9e9958f6a704d39e22b4322586ca004bf54597e81826ca6d3b35d3bc7f795d453
6
+ metadata.gz: 41b0e2d1c097cbb41588659b5baa5c0025bec91ae2f5fbb66a38678902bdbcff70dddc4194fb6c5ddad12ff83b024cc48d74802aebc948292f11d2f303181c2b
7
+ data.tar.gz: 07dd8014a170aa39ca0536564b66a4a7b2ea5321f6319d76d83c2f5ee3f4656cc66667a1a4ca58fc336e9b341844539626045bca631c7b1616ed6c2043dda322
data/README.md CHANGED
@@ -127,19 +127,23 @@ If you are lost, run this:
127
127
  $ zold node --help
128
128
  ```
129
129
 
130
- You can run a node in a docker container also.
130
+ You can run a node in a docker container also, using [yegor256/zold](https://hub.docker.com/r/yegor256/zold)
131
+ built from this [Dockerfile](https://github.com/zold-io/zold/blob/master/Dockerfile).
131
132
 
132
133
  ```bash
133
- docker run -d -p 4096:4096 zold/zold:latest /node.sh --host=<your host IP> --invoice=5f96e731e48ae21f
134
+ docker run -d -p 4096:4096 yegor256/zold /node.sh --host=<your host IP> --invoice=5f96e731e48ae21f
134
135
  ```
135
136
 
136
- To store zold data between container restarts create a volume or bind a directory from host
137
+ To store zold data between container restarts create a volume or bind a directory from host:
137
138
 
138
139
  ```bash
139
- docker volume create zold
140
- docker run -d -p 4096:4096 -v zold:/zold zold/zold:latest /node.sh --host=<your host IP> --invoice=5f96e731e48ae21f
140
+ docker volume create zold
141
+ docker run -d -p 4096:4096 -v zold:/zold yegor256/zold /node.sh --host=<your host IP> --invoice=5f96e731e48ae21f
141
142
  ```
142
143
 
144
+ You may find this blog post useful:
145
+ [How to Run Zold Node?](https://blog.zold.io/2019/01/10/how-to-run-node.html)
146
+
143
147
  ## Frequently Asked Questions
144
148
 
145
149
  > Where are my RSA private/public keys?
@@ -21,7 +21,7 @@ zold remote show
21
21
  zold --public-key=id_rsa.pub create 0000000000000000
22
22
  target=$(zold create --public-key=id_rsa.pub)
23
23
  invoice=$(zold invoice ${target})
24
- zold pay --private-key=id_rsa 0000000000000000 ${invoice} 14.99 'To save the world!'
24
+ zold pay --private-key=id_rsa 0000000000000000 ${invoice} 14.99Z 'To save the world!'
25
25
  zold propagate
26
26
  zold propagate 0000000000000000
27
27
  zold show
@@ -23,7 +23,7 @@ zold --home=${first} remote add 127.0.0.1 ${second}
23
23
  zold --home=${second} remote add 127.0.0.1 ${first}
24
24
 
25
25
  zold --public-key=id_rsa.pub create 0000000000000000
26
- zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4.95 'To help you, dude!'
26
+ zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4000000z 'To help you, dude!'
27
27
  zold remote clean
28
28
  zold remote add 127.0.0.1 ${first}
29
29
  zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
@@ -50,7 +50,7 @@ module Zold
50
50
  Where:
51
51
  'wallet' is the sender's wallet ID
52
52
  'target' is the beneficiary (either wallet ID or invoice number)'
53
- 'amount' is the amount to pay, in ZLD, for example '14.95'
53
+ 'amount' is the amount to pay, for example: '14.95Z' (in ZLD) or '12345z' (in zents)
54
54
  'details' is the optional text to attach to the payment
55
55
  Available options:"
56
56
  o.string '--private-key',
@@ -93,7 +93,7 @@ Available options:"
93
93
  )
94
94
  end
95
95
  raise 'Amount is required (in ZLD) as the third argument' if mine[2].nil?
96
- amount = Amount.new(zld: mine[2].to_f)
96
+ amount = amount(mine[2].strip)
97
97
  details = mine[3] || '-'
98
98
  taxes(id, opts)
99
99
  @wallets.acq(id, exclusive: true) do |from|
@@ -106,6 +106,12 @@ Available options:"
106
106
 
107
107
  private
108
108
 
109
+ def amount(txt)
110
+ return Amount.new(zents: txt.gsub(/z$/, '').to_i) if txt.end_with?('z')
111
+ return Amount.new(zld: txt.gsub(/Z$/, '').to_f) if txt.end_with?('Z')
112
+ Amount.new(zld: txt.to_f)
113
+ end
114
+
109
115
  def taxes(id, opts)
110
116
  debt = @wallets.acq(id) do |wallet|
111
117
  raise "Wallet #{id} doesn't exist, do 'zold pull' first" unless wallet.exists?
@@ -123,7 +129,8 @@ Available options:"
123
129
  raise 'The amount can\'t be zero' if amount.zero?
124
130
  raise "The amount can't be negative: #{amount}" if amount.negative?
125
131
  if !from.root? && from.balance < amount
126
- raise "There is not enough funds in #{from} to send #{amount}, only #{from.balance} left"
132
+ raise "There is not enough funds in #{from} to send #{amount}, only #{from.balance} left; \
133
+ the difference is #{(amount - from.balance).to_i} zents"
127
134
  end
128
135
  end
129
136
  key = Zold::Key.new(file: opts['private-key'])
@@ -71,8 +71,11 @@ Available options:"
71
71
  @log.debug("Paying wallet #{txn.bnf} file is absent: #{txn.to_text}")
72
72
  false
73
73
  end
74
- patch.save(wallet.path, overwrite: true)
75
- @log.debug("Wallet #{wallet.mnemo} rebased in #{Age.new(start)}")
74
+ if patch.save(wallet.path, overwrite: true)
75
+ @log.info("Wallet #{wallet.mnemo} rebased and modified in #{Age.new(start)}")
76
+ else
77
+ @log.debug("There is nothing to rebase in #{wallet.mnemo}, took #{Age.new(start)}")
78
+ end
76
79
  end
77
80
  end
78
81
  end
data/lib/zold/patch.rb CHANGED
@@ -106,7 +106,7 @@ with a new one \"#{txn.to_text}\" from #{wallet.mnemo}")
106
106
  next
107
107
  end
108
108
  unless wallet.prefix?(txn.prefix)
109
- @log.error("Payment prefix '#{txn.prefix}' doesn't match with the key of #{wallet.id}: \"#{txn.to_text}\"")
109
+ @log.debug("Payment prefix '#{txn.prefix}' doesn't match with the key of #{wallet.id}: \"#{txn.to_text}\"")
110
110
  next
111
111
  end
112
112
  if !@wallets.acq(txn.bnf, &:exists?) && yield(txn)
@@ -115,7 +115,7 @@ with a new one \"#{txn.to_text}\" from #{wallet.mnemo}")
115
115
  next
116
116
  end
117
117
  unless @wallets.acq(txn.bnf) { |p| p.includes_negative?(txn.id, wallet.id) }
118
- @log.error("The beneficiary #{@wallets.acq(txn.bnf, &:mnemo)} of #{@id} \
118
+ @log.debug("The beneficiary #{@wallets.acq(txn.bnf, &:mnemo)} of #{@id} \
119
119
  doesn't have this transaction: \"#{txn.to_text}\"")
120
120
  next
121
121
  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.23.5'
28
+ VERSION = '0.23.6'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -49,6 +49,14 @@ class TestPay < Zold::Test
49
49
  ]
50
50
  )
51
51
  assert_equal(amount * -1, source.balance)
52
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
53
+ [
54
+ 'pay', '--private-key=fixtures/id_rsa',
55
+ target.id.to_s, source.id.to_s, amount.to_zld, 'Refund'
56
+ ]
57
+ )
58
+ source.flush
59
+ assert_equal(Zold::Amount::ZERO, source.balance)
52
60
  end
53
61
  end
54
62
 
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.23.5
4
+ version: 0.23.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-12 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -753,7 +753,7 @@ licenses:
753
753
  - MIT
754
754
  metadata: {}
755
755
  post_install_message: |-
756
- Thanks for installing Zold 0.23.5!
756
+ Thanks for installing Zold 0.23.6!
757
757
  Study our White Paper: https://papers.zold.io/wp.pdf
758
758
  Read our blog posts: https://blog.zold.io
759
759
  Try ZLD online wallet at: https://wts.zold.io