zold 0.31.10 → 0.32.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.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +2 -19
  3. data/.github/typos.toml +11 -0
  4. data/.github/workflows/actionlint.yml +5 -21
  5. data/.github/workflows/bashate.yml +25 -0
  6. data/.github/workflows/codecov.yml +11 -24
  7. data/.github/workflows/copyrights.yml +6 -21
  8. data/.github/workflows/hadolint.yml +14 -0
  9. data/.github/workflows/markdown-lint.yml +19 -0
  10. data/.github/workflows/pdd.yml +5 -20
  11. data/.github/workflows/rake.yml +8 -22
  12. data/.github/workflows/reuse.yml +19 -0
  13. data/.github/workflows/shellcheck.yml +19 -0
  14. data/.github/workflows/typos.yml +21 -0
  15. data/.github/workflows/xcop.yml +5 -20
  16. data/.github/workflows/yamllint.yml +5 -20
  17. data/.gitignore +9 -6
  18. data/.rubocop.yml +16 -20
  19. data/.ruby-version +1 -1
  20. data/.rultor.yml +6 -22
  21. data/Dockerfile +11 -27
  22. data/Gemfile +21 -33
  23. data/Gemfile.lock +181 -126
  24. data/Guardfile +0 -0
  25. data/INSTALL.md +80 -59
  26. data/LICENSE.txt +1 -1
  27. data/LICENSES/MIT.txt +21 -0
  28. data/README.md +183 -154
  29. data/REUSE.toml +40 -0
  30. data/Rakefile +4 -38
  31. data/bin/zold +7 -37
  32. data/cucumber.yml +2 -19
  33. data/deploy.sh +4 -22
  34. data/features/cli.feature +2 -0
  35. data/features/gem_package.feature +2 -0
  36. data/features/step_definitions/steps.rb +2 -19
  37. data/features/support/env.rb +2 -19
  38. data/fixtures/merge/asserts.rb +3 -19
  39. data/fixtures/merge/into_no_wallet/assert.rb +2 -19
  40. data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -19
  41. data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/scores.zc +1 -1
  42. data/fixtures/merge/missed_wallets/0123456789abcdef.z +0 -2
  43. data/fixtures/merge/missed_wallets/assert.rb +2 -19
  44. data/fixtures/merge/missed_wallets/copies/0123456789abcdef/scores.zc +1 -1
  45. data/fixtures/merge/negative_overwriting/assert.rb +2 -19
  46. data/fixtures/merge/negatives_in_between/0123456789abcdef.z +0 -1
  47. data/fixtures/merge/negatives_in_between/assert.rb +2 -19
  48. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/2.zc +0 -1
  49. data/fixtures/merge/negatives_in_between/opts +1 -1
  50. data/fixtures/merge/random_expenses/assert.rb +2 -19
  51. data/fixtures/merge/random_expenses/opts +1 -1
  52. data/fixtures/merge/simple_case/assert.rb +2 -19
  53. data/fixtures/merge/simple_case/opts +1 -1
  54. data/fixtures/merge/unconfirmed_income/assert.rb +2 -19
  55. data/fixtures/scripts/_head.sh +16 -33
  56. data/fixtures/scripts/calculate-scores.sh +3 -20
  57. data/fixtures/scripts/distribute-wallet.sh +26 -43
  58. data/fixtures/scripts/print-helps.sh +5 -23
  59. data/fixtures/scripts/pull-on-start.sh +12 -29
  60. data/fixtures/scripts/push-and-pull.sh +10 -27
  61. data/fixtures/scripts/redeploy-on-upgrade.sh +18 -34
  62. data/fixtures/scripts/spread-wallets.sh +24 -40
  63. data/lib/zold/age.rb +3 -20
  64. data/lib/zold/amount.rb +3 -20
  65. data/lib/zold/cached_wallets.rb +3 -20
  66. data/lib/zold/commands/alias.rb +4 -21
  67. data/lib/zold/commands/args.rb +4 -21
  68. data/lib/zold/commands/calculate.rb +5 -22
  69. data/lib/zold/commands/clean.rb +6 -23
  70. data/lib/zold/commands/create.rb +5 -22
  71. data/lib/zold/commands/diff.rb +5 -22
  72. data/lib/zold/commands/fetch.rb +6 -23
  73. data/lib/zold/commands/invoice.rb +5 -22
  74. data/lib/zold/commands/list.rb +5 -22
  75. data/lib/zold/commands/merge.rb +7 -24
  76. data/lib/zold/commands/next.rb +5 -22
  77. data/lib/zold/commands/node.rb +4 -21
  78. data/lib/zold/commands/pay.rb +6 -23
  79. data/lib/zold/commands/propagate.rb +5 -22
  80. data/lib/zold/commands/pull.rb +5 -22
  81. data/lib/zold/commands/push.rb +5 -22
  82. data/lib/zold/commands/remote.rb +7 -24
  83. data/lib/zold/commands/remove.rb +5 -22
  84. data/lib/zold/commands/routines/audit.rb +4 -21
  85. data/lib/zold/commands/routines/gc.rb +6 -23
  86. data/lib/zold/commands/routines/reconcile.rb +5 -22
  87. data/lib/zold/commands/routines/reconnect.rb +4 -21
  88. data/lib/zold/commands/routines/retire.rb +4 -21
  89. data/lib/zold/commands/routines/spread.rb +5 -22
  90. data/lib/zold/commands/routines.rb +3 -20
  91. data/lib/zold/commands/show.rb +5 -22
  92. data/lib/zold/commands/taxes.rb +5 -22
  93. data/lib/zold/commands/thread_badge.rb +3 -20
  94. data/lib/zold/copies.rb +6 -25
  95. data/lib/zold/dir_items.rb +3 -20
  96. data/lib/zold/endless.rb +5 -22
  97. data/lib/zold/gem.rb +3 -20
  98. data/lib/zold/hands.rb +6 -23
  99. data/lib/zold/head.rb +4 -21
  100. data/lib/zold/hexnum.rb +3 -20
  101. data/lib/zold/http.rb +3 -20
  102. data/lib/zold/hungry_wallets.rb +6 -23
  103. data/lib/zold/id.rb +3 -20
  104. data/lib/zold/json_page.rb +5 -22
  105. data/lib/zold/key.rb +3 -20
  106. data/lib/zold/metronome.rb +5 -22
  107. data/lib/zold/node/async_entrance.rb +6 -23
  108. data/lib/zold/node/entrance.rb +7 -24
  109. data/lib/zold/node/farm.rb +5 -22
  110. data/lib/zold/node/farmers.rb +15 -32
  111. data/lib/zold/node/front.rb +6 -23
  112. data/lib/zold/node/journaled_pipeline.rb +8 -25
  113. data/lib/zold/node/nodup_entrance.rb +6 -23
  114. data/lib/zold/node/nospam_entrance.rb +6 -23
  115. data/lib/zold/node/pipeline.rb +6 -23
  116. data/lib/zold/node/safe_entrance.rb +4 -22
  117. data/lib/zold/node/soft_error.rb +3 -20
  118. data/lib/zold/node/spread_entrance.rb +5 -22
  119. data/lib/zold/node/sync_entrance.rb +5 -22
  120. data/lib/zold/node/trace.rb +3 -20
  121. data/lib/zold/patch.rb +6 -23
  122. data/lib/zold/prefixes.rb +3 -20
  123. data/lib/zold/remotes.rb +5 -22
  124. data/lib/zold/signature.rb +3 -20
  125. data/lib/zold/size.rb +3 -20
  126. data/lib/zold/sync_wallets.rb +5 -22
  127. data/lib/zold/tax.rb +4 -21
  128. data/lib/zold/thread_pool.rb +4 -21
  129. data/lib/zold/tree_wallets.rb +3 -20
  130. data/lib/zold/txn.rb +4 -21
  131. data/lib/zold/txns.rb +4 -21
  132. data/lib/zold/upgrades.rb +4 -21
  133. data/lib/zold/verbose_thread.rb +5 -22
  134. data/lib/zold/version.rb +4 -21
  135. data/lib/zold/version_file.rb +4 -21
  136. data/lib/zold/wallet.rb +6 -23
  137. data/lib/zold/wallets.rb +5 -23
  138. data/lib/zold.rb +3 -21
  139. data/resources/banned-wallets.log +6 -6
  140. data/test/commands/routines/test_audit.rb +3 -21
  141. data/test/commands/routines/test_gc.rb +3 -21
  142. data/test/commands/routines/test_reconcile.rb +3 -21
  143. data/test/commands/routines/test_reconnect.rb +3 -21
  144. data/test/commands/routines/test_retire.rb +3 -21
  145. data/test/commands/test_alias.rb +2 -20
  146. data/test/commands/test_calculate.rb +5 -23
  147. data/test/commands/test_clean.rb +5 -23
  148. data/test/commands/test_create.rb +6 -24
  149. data/test/commands/test_diff.rb +4 -22
  150. data/test/commands/test_fetch.rb +3 -21
  151. data/test/commands/test_invoice.rb +3 -21
  152. data/test/commands/test_list.rb +3 -21
  153. data/test/commands/test_merge.rb +12 -35
  154. data/test/commands/test_node.rb +3 -21
  155. data/test/commands/test_pay.rb +5 -23
  156. data/test/commands/test_propagate.rb +6 -24
  157. data/test/commands/test_pull.rb +4 -22
  158. data/test/commands/test_push.rb +3 -21
  159. data/test/commands/test_remote.rb +10 -28
  160. data/test/commands/test_remove.rb +7 -25
  161. data/test/commands/test_show.rb +3 -21
  162. data/test/commands/test_taxes.rb +5 -23
  163. data/test/fake_home.rb +5 -22
  164. data/test/node/fake_entrance.rb +3 -20
  165. data/test/node/fake_node.rb +5 -22
  166. data/test/node/test_async_entrance.rb +3 -21
  167. data/test/node/test_entrance.rb +7 -25
  168. data/test/node/test_farm.rb +15 -33
  169. data/test/node/test_farmers.rb +3 -21
  170. data/test/node/test_front.rb +22 -42
  171. data/test/node/test_nodup_entrance.rb +4 -22
  172. data/test/node/test_nospam_entrance.rb +6 -24
  173. data/test/node/test_safe_entrance.rb +3 -21
  174. data/test/node/test_spread_entrance.rb +4 -22
  175. data/test/node/test_sync_entrance.rb +4 -22
  176. data/test/node/test_trace.rb +4 -22
  177. data/test/test__helper.rb +32 -31
  178. data/test/test_age.rb +5 -23
  179. data/test/test_amount.rb +15 -34
  180. data/test/test_cached_wallets.rb +3 -21
  181. data/test/test_copies.rb +10 -28
  182. data/test/test_dir_items.rb +4 -22
  183. data/test/test_gem.rb +3 -21
  184. data/test/test_hands.rb +3 -21
  185. data/test/test_hexnum.rb +3 -21
  186. data/test/test_http.rb +9 -27
  187. data/test/test_hungry_wallets.rb +6 -24
  188. data/test/test_id.rb +10 -28
  189. data/test/test_json_page.rb +3 -21
  190. data/test/test_key.rb +5 -23
  191. data/test/test_metronome.rb +6 -24
  192. data/test/test_patch.rb +10 -28
  193. data/test/test_prefixes.rb +3 -21
  194. data/test/test_remotes.rb +17 -35
  195. data/test/test_signature.rb +3 -21
  196. data/test/test_size.rb +3 -21
  197. data/test/test_sync_wallets.rb +3 -21
  198. data/test/test_tax.rb +6 -24
  199. data/test/test_thread_pool.rb +6 -24
  200. data/test/test_tree_wallets.rb +4 -22
  201. data/test/test_txn.rb +3 -21
  202. data/test/test_upgrades.rb +3 -21
  203. data/test/test_verbose_thread.rb +6 -24
  204. data/test/test_version.rb +2 -20
  205. data/test/test_wallet.rb +15 -33
  206. data/test/test_wallets.rb +4 -22
  207. data/test/test_zold.rb +7 -25
  208. data/test/upgrades/test_delete_banned_wallets.rb +4 -22
  209. data/test/upgrades/test_protocol_up.rb +3 -21
  210. data/upgrades/2.rb +3 -20
  211. data/upgrades/delete_banned_wallets.rb +3 -20
  212. data/upgrades/move_wallets_into_tree.rb +3 -20
  213. data/upgrades/protocol_up.rb +3 -20
  214. data/upgrades/rename_foreign_wallets.rb +3 -20
  215. data/views/journal.haml +25 -0
  216. data/views/layout.haml +25 -0
  217. data/views/wallet.haml +25 -0
  218. data/zold.gemspec +5 -21
  219. metadata +33 -15
  220. data/.simplecov +0 -36
  221. data/lib/zold/log.rb +0 -139
  222. data/test/test_log.rb +0 -49
@@ -1,23 +1,6 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  set -e
23
6
  set -x
@@ -25,6 +8,7 @@ shopt -s expand_aliases
25
8
 
26
9
  export RUBYOPT="-W0"
27
10
 
11
+ # shellcheck disable=SC2139
28
12
  alias zold="$1 --ignore-this-stupid-option --halt-code=test --ignore-global-config --trace --network=test --no-colors --dump-errors"
29
13
 
30
14
  function reserve_port {
@@ -33,9 +17,9 @@ function reserve_port {
33
17
 
34
18
  function wait_for_url {
35
19
  i=0
36
- while ! curl --silent --fail $1 > /dev/null; do
37
- ((i++)) || sleep 0
38
- if ((i==30)); then
20
+ while ! curl --silent --fail "$1" > /dev/null; do
21
+ i=$((i + 1))
22
+ if [ "${i}" -eq 30 ]; then
39
23
  echo "URL $1 is not available after ${i} attempts"
40
24
  exit 12
41
25
  fi
@@ -45,9 +29,9 @@ function wait_for_url {
45
29
 
46
30
  function wait_for_port {
47
31
  i=0
48
- while ! nc -z localhost $1; do
49
- ((i++)) || sleep 0
50
- if ((i==30)); then
32
+ while ! nc -z localhost "$1"; do
33
+ i=$((i + 1))
34
+ if [ "${i}" -eq 30 ]; then
51
35
  echo "Port $1 is not available after ${i} attempts"
52
36
  exit 13
53
37
  fi
@@ -57,9 +41,9 @@ function wait_for_port {
57
41
 
58
42
  function wait_for_file {
59
43
  i=0
60
- while [ ! -f $1 ]; do
61
- ((i++)) || sleep 0
62
- if ((i==30)); then
44
+ while [ ! -f "$1" ]; do
45
+ i=$((i + 1))
46
+ if [ "${i}" -eq 30 ]; then
63
47
  echo "File $1 not found, giving up after ${i} attempts"
64
48
  exit 14
65
49
  fi
@@ -72,9 +56,9 @@ function halt_nodes {
72
56
  pid=$(curl --silent "http://127.0.0.1:$p/pid?halt=test" || echo 'absent')
73
57
  if [[ "${pid}" =~ ^[0-9]+$ ]]; then
74
58
  i=0
75
- while kill -0 ${pid}; do
76
- ((i++)) || sleep 0
77
- if ((i==30)); then
59
+ while kill -0 "${pid}"; do
60
+ i=$((i + 1))
61
+ if [ "${i}" -eq 30 ]; then
78
62
  echo "Process ${pid} didn't die, it's a bug"
79
63
  exit 15
80
64
  fi
@@ -86,4 +70,3 @@ function halt_nodes {
86
70
  echo "Node at TCP port ${p} stopped!"
87
71
  done
88
72
  }
89
-
@@ -1,22 +1,5 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  zold score --host=zold.io --port=4096 --invoice=CALCSCORE@ffffffffffffffff --strength=2 --max=5
@@ -1,51 +1,35 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  function start_node {
23
6
  port=$(reserve_port)
24
- mkdir ${port}
25
- cd ${port}
7
+ mkdir "${port}"
8
+ cd "${port}" || exit
26
9
  zold node --trace --invoice=DISTRWALLET@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
27
- --host=127.0.0.1 --port=${port} --bind-port=${port} \
10
+ --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
28
11
  --threads=0 --routine-immediately --never-reboot > log.txt 2>&1 &
29
12
  pid=$!
30
- echo ${pid} > pid
13
+ echo "${pid}" > pid
31
14
  cd ..
32
- wait_for_url http://127.0.0.1:${port}/
33
- echo ${port}
15
+ wait_for_url "http://127.0.0.1:${port}/"
16
+ echo "${port}"
34
17
  }
35
18
 
36
19
  # We start two nodes and kill them both at the end of the script. If we
37
20
  # don't do the TRAP for killing, the test will never end.
38
21
  first=$(start_node)
39
22
  second=$(start_node)
23
+ # shellcheck disable=SC2064
40
24
  trap "halt_nodes ${first} ${second}" EXIT
41
25
 
42
26
  # The first node is linked to the second one and the second one
43
27
  # is linked to the first one. The --home argument specifies their
44
28
  # locations.
45
- zold --home=${first} remote clean
46
- zold --home=${first} remote add 127.0.0.1 ${second}
47
- zold --home=${second} remote clean
48
- zold --home=${second} remote add 127.0.0.1 ${first}
29
+ zold --home="${first}" remote clean
30
+ zold --home="${first}" remote add 127.0.0.1 "${second}"
31
+ zold --home="${second}" remote clean
32
+ zold --home="${second}" remote add 127.0.0.1 "${first}"
49
33
 
50
34
  # Locally we create a new root wallet (to avoid negative balance checking)
51
35
  # and connect our local Zold home to the first remote node. Then, we push
@@ -54,10 +38,10 @@ zold --home=${second} remote add 127.0.0.1 ${first}
54
38
  zold --public-key=id_rsa.pub create 0000000000000000
55
39
  zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4.95 'For the book'
56
40
  zold remote clean
57
- zold remote add 127.0.0.1 ${first}
41
+ zold remote add 127.0.0.1 "${first}"
58
42
  zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
59
43
  zold remote clean
60
- zold remote add 127.0.0.1 ${second}
44
+ zold remote add 127.0.0.1 "${second}"
61
45
 
62
46
  # Here we fetch the wallet from the second remote node. The wallet has
63
47
  # to be visible there. We are doing a number of attempts with a small
@@ -66,9 +50,9 @@ zold remote add 127.0.0.1 ${second}
66
50
  i=0
67
51
  until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
68
52
  echo 'Failed to fetch, let us try again'
69
- ((i++)) || sleep 0
70
- if ((i==5)); then
71
- cat ${first}/log.txt
53
+ i=$((i + 1))
54
+ if [ "${i}" -eq 5 ]; then
55
+ cat "${first}/log.txt"
72
56
  echo "The wallet has not been distributed, after ${i} attempts"
73
57
  exit 9
74
58
  fi
@@ -77,12 +61,12 @@ done
77
61
 
78
62
  # Here we check the JSON of the first node to make sure all status
79
63
  # indicators are clean.
80
- json=$(curl --silent --show-error http://127.0.0.1:${first})
81
- if [ ! $(echo ${json} | jq -r '.entrance.queue') == "0" ]; then
64
+ json=$(curl --silent --show-error "http://127.0.0.1:${first}")
65
+ if [ ! "$(echo "${json}" | jq -r '.entrance.queue')" == "0" ]; then
82
66
  echo "The queue is not empty after PUSH, it's a bug"
83
67
  exit 5
84
68
  fi
85
- if [ $(echo ${json} | jq -r '.entrance.history_size') == "0" ]; then
69
+ if [ "$(echo "${json}" | jq -r '.entrance.history_size')" == "0" ]; then
86
70
  echo "The history doesn't have a wallet, it's a bug"
87
71
  exit 6
88
72
  fi
@@ -90,16 +74,15 @@ fi
90
74
  # Now, we remove the wallet from the second node and expect the first
91
75
  # one to "spread" it again, almost immediately. The second node should
92
76
  # have the wallet very soon.
93
- rm -f ${second}/**/*.z
77
+ rm -f "${second}"/**/*.z
94
78
  i=0
95
79
  until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
96
80
  echo 'Failed to fetch, let us try again'
97
- ((i++)) || sleep 0
98
- if ((i==5)); then
81
+ i=$((i + 1))
82
+ if [ "${i}" -eq 5 ]; then
99
83
  echo "The wallet 0000000000000000 has not been spread, after ${i} attempts, here is the log:"
100
- cat ${first}/log.txt
84
+ cat "${first}/log.txt"
101
85
  exit 8
102
86
  fi
103
87
  sleep 2
104
88
  done
105
-
@@ -1,27 +1,9 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  zold --help
23
6
  declare -a commands=(node create invoice remote pay show fetch clean diff merge propagate pull push taxes)
24
- for c in "${commands[@]}"
25
- do
26
- zold --ignore-global-config --trace $c --help
7
+ for c in "${commands[@]}"; do
8
+ zold --ignore-global-config --trace "$c" --help
27
9
  done
@@ -1,37 +1,20 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  port=$(reserve_port)
23
6
  mkdir server
24
- cd server
7
+ cd server || exit
25
8
  zold remote clean
26
9
  zold node --trace --invoice=PULLONSTART@ffffffffffffffff --no-metronome --tolerate-edges --tolerate-quorum=1 \
27
- --host=127.0.0.1 --port=${port} --bind-port=${port} \
10
+ --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
28
11
  --threads=0 --standalone --pretty=full 2>&1 &
29
12
  cd ..
30
13
 
31
- wait_for_port ${port}
14
+ wait_for_port "${port}"
32
15
 
33
16
  zold remote clean
34
- zold remote add 127.0.0.1 ${port}
17
+ zold remote add 127.0.0.1 "${port}"
35
18
 
36
19
  zold --public-key=id_rsa.pub create abcdabcdabcdabcd
37
20
  zold push abcdabcdabcdabcd --tolerate-edges --tolerate-quorum=1
@@ -40,13 +23,13 @@ zold invoice abcdabcdabcdabcd --tolerate-edges --tolerate-quorum=1
40
23
 
41
24
  second_port=$(reserve_port)
42
25
  mkdir second
43
- cd second
26
+ cd second || exit
44
27
  zold remote clean
45
- zold remote add 127.0.0.1 ${port}
28
+ zold remote add 127.0.0.1 "${port}"
46
29
  zold node --trace --invoice=abcdabcdabcdabcd --no-metronome --tolerate-edges --tolerate-quorum=1 \
47
- --host=127.0.0.1 --port=${second_port} --bind-port=${second_port} \
30
+ --host=127.0.0.1 --port="${second_port}" --bind-port="${second_port}" \
48
31
  --threads=0 &
49
32
 
50
- wait_for_port ${second_port}
33
+ wait_for_port "${second_port}"
51
34
 
52
- halt_nodes ${second_port} ${port}
35
+ halt_nodes "${second_port}" "${port}"
@@ -1,46 +1,29 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  port=$(reserve_port)
23
6
 
24
7
  mkdir server
25
- cd server
8
+ cd server || exit
26
9
  zold node --trace --invoice=PUSHNPULL@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
27
- --host=127.0.0.1 --port=${port} --bind-port=${port} \
10
+ --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
28
11
  --threads=0 --standalone 2>&1 &
29
- pid=$!
12
+ # shellcheck disable=SC2064
30
13
  trap "halt_nodes ${port}" EXIT
31
14
  cd ..
32
15
 
33
- wait_for_port ${port}
16
+ wait_for_port "${port}"
34
17
 
35
18
  zold remote clean
36
- zold remote add 127.0.0.1 ${port}
19
+ zold remote add 127.0.0.1 "${port}"
37
20
  zold remote trim
38
21
  zold remote show
39
22
 
40
23
  zold --public-key=id_rsa.pub create 0000000000000000
41
24
  target=$(zold create --public-key=id_rsa.pub)
42
- invoice=$(zold invoice ${target})
43
- zold pay --private-key=id_rsa 0000000000000000 ${invoice} 14.99Z 'To save the world!'
25
+ invoice=$(zold invoice "${target}")
26
+ zold pay --private-key=id_rsa 0000000000000000 "${invoice}" 14.99Z 'To save the world!'
44
27
  zold propagate
45
28
  zold propagate 0000000000000000
46
29
  zold show
@@ -1,56 +1,40 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  function start_node {
23
- mkdir $1
24
- cd $1
6
+ mkdir "$1"
7
+ cd "$1" || exit
25
8
  zold remote clean
26
- zold node $3 --nohup --nohup-command='touch restarted' --nohup-log=log --nohup-max-cycles=0 --nohup-log-truncate=10240 \
27
- --expose-version=$2 --save-pid=pid --routine-immediately --tolerate-edges --tolerate-quorum=1 \
9
+ zold node ${3:+"$3"} --nohup --nohup-command='touch restarted' --nohup-log=log --nohup-max-cycles=0 --nohup-log-truncate=10240 \
10
+ --expose-version="$2" --save-pid=pid --routine-immediately --tolerate-edges --tolerate-quorum=1 \
28
11
  --verbose --trace --invoice=REDEPLOY@ffffffffffffffff --ignore-empty-remotes \
29
- --host=127.0.0.1 --port=$1 --bind-port=$1 --threads=1 --strength=20 > /dev/null 2>&1
30
- wait_for_port $1
12
+ --host=127.0.0.1 --port="$1" --bind-port="$1" --threads=1 --strength=20 > /dev/null 2>&1
13
+ wait_for_port "$1"
31
14
  cat pid
32
15
  cd ..
33
16
  }
34
17
 
35
18
  high=$(reserve_port)
36
- primary=$(start_node ${high} 9.9.9 --standalone)
19
+ start_node "${high}" 9.9.9 --standalone
37
20
 
38
21
  low=$(reserve_port)
39
- secondary=$(start_node ${low} 1.1.1)
22
+ start_node "${low}" 1.1.1
40
23
 
41
24
  zold remote clean
42
- zold remote add 127.0.0.1 ${high} --home=${low} --skip-ping
25
+ zold remote add 127.0.0.1 "${high}" --home="${low}" --skip-ping
43
26
 
27
+ # shellcheck disable=SC2064
44
28
  trap "halt_nodes ${high}" EXIT
45
29
 
46
- wait_for_file ${low}/restarted
30
+ wait_for_file "${low}/restarted"
47
31
 
48
- if [ `ps ax | grep zold | grep "${low}"` -eq '' ]; then
32
+ if [ -n "$(pgrep -f "zold.*${low}")" ]; then
49
33
  echo "The score finder process is still there, it's a bug"
50
- exit -1
34
+ exit 1
51
35
  fi
52
36
 
53
37
  echo "High node logs (port ${high}):"
54
- cat ${high}/log
38
+ cat "${high}/log"
55
39
  echo "Low node logs (port ${low}):"
56
- cat ${low}/log
40
+ cat "${low}/log"
@@ -1,72 +1,56 @@
1
- #!/bin/bash
2
- # Copyright (c) 2018-2024 Zerocracy
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the 'Software'), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
+ # SPDX-License-Identifier: MIT
21
4
 
22
5
  function start_node {
23
6
  port=$(reserve_port)
24
- mkdir ${port}
25
- cd ${port}
7
+ mkdir "${port}"
8
+ cd "${port}" || exit
26
9
  zold remote clean
27
10
  zold node --trace --invoice=SPREADWALLETS@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
28
- --host=127.0.0.1 --port=${port} --bind-port=${port} \
29
- --threads=0 > log.txt 2>&1 &
11
+ --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
12
+ --threads=0 --never-reboot > log.txt 2>&1 &
30
13
  pid=$!
31
- echo ${pid} > pid
14
+ echo "${pid}" > pid
32
15
  cd ..
33
- wait_for_url http://localhost:${port}/
34
- echo ${port}
16
+ wait_for_url "http://localhost:${port}/"
17
+ echo "${port}"
35
18
  }
36
19
 
37
20
  first=$(start_node)
38
21
  second=$(start_node)
22
+ # shellcheck disable=SC2064
39
23
  trap "halt_nodes ${first} ${second}" EXIT
40
24
 
41
- zold --home=${first} remote add 127.0.0.1 ${second}
42
- zold --home=${second} remote add 127.0.0.1 ${first}
25
+ zold --home="${first}" remote add 127.0.0.1 "${second}"
26
+ zold --home="${second}" remote add 127.0.0.1 "${first}"
43
27
 
44
28
  zold --public-key=id_rsa.pub create 0000000000000000
45
29
  zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4000000z 'To help you, dude!'
46
30
  zold remote clean
47
- zold remote add 127.0.0.1 ${first}
31
+ zold remote add 127.0.0.1 "${first}"
48
32
  zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
49
33
  zold remote clean
50
- zold remote add 127.0.0.1 ${second}
34
+ zold remote add 127.0.0.1 "${second}"
51
35
 
52
36
  i=0
53
37
  until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
54
38
  echo 'Failed to fetch, let us try again'
55
- ((i++)) || sleep 0
56
- if ((i==5)); then
57
- cat ${first}/log.txt
39
+ i=$((i + 1))
40
+ if [ "${i}" -eq 5 ]; then
41
+ cat "${first}/log.txt"
58
42
  echo "The wallet has not been distributed, after ${i} attempts"
59
- exit -1
43
+ exit 1
60
44
  fi
61
45
  sleep 2
62
46
  done
63
47
 
64
- json=$(curl --silent --show-error http://127.0.0.1:${first})
65
- if [ ! $(echo ${json} | jq -r '.entrance.queue') == "0" ]; then
48
+ json=$(curl --silent --show-error "http://127.0.0.1:${first}")
49
+ if [ ! "$(echo "${json}" | jq -r '.entrance.queue')" == "0" ]; then
66
50
  echo "The queue is not empty after PUSH, it's a bug"
67
- exit -1
51
+ exit 1
68
52
  fi
69
- if [ ! $(echo ${json} | jq -r '.entrance.history_size') == "1" ]; then
53
+ if [ ! "$(echo "${json}" | jq -r '.entrance.history_size')" == "1" ]; then
70
54
  echo "The history doesn't have a wallet, it's a bug"
71
- exit -1
55
+ exit 1
72
56
  fi
data/lib/zold/age.rb CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  require 'time'
24
7
  require 'rainbow'
@@ -26,7 +9,7 @@ require_relative 'txn'
26
9
 
27
10
  # Age in seconds.
28
11
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
12
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
30
13
  # License:: MIT
31
14
  module Zold
32
15
  # Age
data/lib/zold/amount.rb CHANGED
@@ -1,30 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  require 'rainbow'
24
7
 
25
8
  # The amount.
26
9
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
10
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
28
11
  # License:: MIT
29
12
  module Zold
30
13
  # Amount