zold 0.26.12 → 0.26.13
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/README.md +3 -1
- data/bin/zold +1 -1
- data/lib/zold/commands/create.rb +20 -2
- data/lib/zold/node/async_entrance.rb +1 -1
- data/lib/zold/node/front.rb +0 -4
- data/lib/zold/patch.rb +5 -2
- data/lib/zold/version.rb +1 -1
- data/test/commands/test_create.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fea2bb24b6779c8bcf92b092ccdf770165f0dd26fabe8381c67428e8ed8c6b3
|
4
|
+
data.tar.gz: 2daa71cade79a0a8c6b047a5eab74ee58222da232fdc3fe465c625c21effa194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 487269eca1122c24548464355049b8507baf71a759e30f8063b4f4f629c47d563658233ac86c8feb30fc55f66b9e69fffce34d3f38683541c9f1ea1f30394f50
|
7
|
+
data.tar.gz: 1361b2c745f127b73f7b871808ebf1f13a3b17fa96f835703ea242775b134a62e7ff55f4b450746ff28d97f1c47ec4e11faf8cc5ad4270644e866c2d29eded3c
|
data/README.md
CHANGED
@@ -312,7 +312,9 @@ Now you are ready to create a wallet:
|
|
312
312
|
|
313
313
|
```ruby
|
314
314
|
require 'zold/commands/create'
|
315
|
-
Zold::Create.new(wallets: wallets).run(
|
315
|
+
Zold::Create.new(wallets: wallets, remotes: remotes).run(
|
316
|
+
['create', '--public-key=/tmp/id_rsa.pub', '--skip-test']
|
317
|
+
)
|
316
318
|
```
|
317
319
|
|
318
320
|
Here `--public-key=/tmp/id_rsa.pub` points to the absolute location of
|
data/bin/zold
CHANGED
@@ -212,7 +212,7 @@ cmd = lambda do
|
|
212
212
|
Zold::Node.new(wallets: wallets, remotes: remotes, copies: copies, log: log).run(args)
|
213
213
|
when 'create'
|
214
214
|
require_relative '../lib/zold/commands/create'
|
215
|
-
Zold::Create.new(wallets: wallets, log: log).run(args)
|
215
|
+
Zold::Create.new(wallets: wallets, remotes: remotes, log: log).run(args)
|
216
216
|
when 'remote'
|
217
217
|
require_relative '../lib/zold/commands/remote'
|
218
218
|
Zold::Remote.new(remotes: remotes, log: log).run(args)
|
data/lib/zold/commands/create.rb
CHANGED
@@ -37,8 +37,9 @@ module Zold
|
|
37
37
|
class Create
|
38
38
|
prepend ThreadBadge
|
39
39
|
|
40
|
-
def initialize(wallets:, log: Log::NULL)
|
40
|
+
def initialize(wallets:, remotes:, log: Log::NULL)
|
41
41
|
@wallets = wallets
|
42
|
+
@remotes = remotes
|
42
43
|
@log = log
|
43
44
|
end
|
44
45
|
|
@@ -50,6 +51,9 @@ Available options:"
|
|
50
51
|
'The location of RSA public key (default: ~/.ssh/id_rsa.pub)',
|
51
52
|
require: true,
|
52
53
|
default: File.expand_path('~/.ssh/id_rsa.pub')
|
54
|
+
o.bool '--skip-test',
|
55
|
+
'Don\'t check whether this wallet ID is available',
|
56
|
+
default: false
|
53
57
|
o.string '--network',
|
54
58
|
"The name of the network (default: #{Wallet::MAINET}",
|
55
59
|
require: true,
|
@@ -57,11 +61,25 @@ Available options:"
|
|
57
61
|
o.bool '--help', 'Print instructions'
|
58
62
|
end
|
59
63
|
mine = Args.new(opts, @log).take || return
|
60
|
-
create(mine.empty? ?
|
64
|
+
create(mine.empty? ? create_id(opts) : Id.new(mine[0]), opts)
|
61
65
|
end
|
62
66
|
|
63
67
|
private
|
64
68
|
|
69
|
+
def create_id(opts)
|
70
|
+
loop do
|
71
|
+
id = Id.new
|
72
|
+
return id if opts['skip-test']
|
73
|
+
found = false
|
74
|
+
@remotes.iterate(@log) do |r|
|
75
|
+
head = r.http("/wallet/#{id}/digest").get
|
76
|
+
found = true if head.status == 200
|
77
|
+
end
|
78
|
+
return id unless found
|
79
|
+
@log.info("Wallet ID #{id} is already occupied, will try another one...")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
65
83
|
def create(id, opts)
|
66
84
|
key = Zold::Key.new(file: opts['public-key'])
|
67
85
|
@wallets.acq(id, exclusive: true) do |wallet|
|
@@ -98,7 +98,7 @@ module Zold
|
|
98
98
|
unless exists?(id, body)
|
99
99
|
loop do
|
100
100
|
uuid = SecureRandom.uuid
|
101
|
-
file = File.join(@dir, "#{id}-#{uuid}")
|
101
|
+
file = File.join(@dir, "#{id}-#{uuid}#{Wallet::EXT}")
|
102
102
|
next if File.exist?(file)
|
103
103
|
IO.write(file, body)
|
104
104
|
@queue << { id: id, file: file }
|
data/lib/zold/node/front.rb
CHANGED
@@ -275,10 +275,6 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
|
|
275
275
|
fetch { |w| w.age.to_s }
|
276
276
|
end
|
277
277
|
|
278
|
-
get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/age} do
|
279
|
-
fetch { |w| w.age.to_s }
|
280
|
-
end
|
281
|
-
|
282
278
|
get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/txns} do
|
283
279
|
fetch { |w| w.txns.count.to_s }
|
284
280
|
end
|
data/lib/zold/patch.rb
CHANGED
@@ -126,9 +126,12 @@ with a new one \"#{txn.to_text}\" from #{wallet.mnemo}")
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
if @wallets.acq(txn.bnf, &:exists?) && !@wallets.acq(txn.bnf) { |p| p.includes_negative?(txn.id, wallet.id) }
|
129
|
-
|
129
|
+
yield(txn)
|
130
|
+
unless @wallets.acq(txn.bnf) { |p| p.includes_negative?(txn.id, wallet.id) }
|
131
|
+
@log.debug("The beneficiary #{@wallets.acq(txn.bnf, &:mnemo)} of #{@id} \
|
130
132
|
doesn't have this transaction: \"#{txn.to_text}\"")
|
131
|
-
|
133
|
+
next
|
134
|
+
end
|
132
135
|
end
|
133
136
|
end
|
134
137
|
@txns << txn
|
data/lib/zold/version.rb
CHANGED
@@ -35,8 +35,8 @@ class TestCreate < Zold::Test
|
|
35
35
|
def test_creates_wallet
|
36
36
|
Dir.mktmpdir do |dir|
|
37
37
|
wallets = Zold::Wallets.new(dir)
|
38
|
-
id = Zold::Create.new(wallets: wallets, log: test_log).run(
|
39
|
-
['create', '--public-key=fixtures/id_rsa.pub']
|
38
|
+
id = Zold::Create.new(wallets: wallets, remotes: nil, log: test_log).run(
|
39
|
+
['create', '--public-key=fixtures/id_rsa.pub', '--skip-test']
|
40
40
|
)
|
41
41
|
wallets.acq(id) do |wallet|
|
42
42
|
assert(wallet.balance.zero?)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.26.
|
4
|
+
version: 0.26.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -773,7 +773,7 @@ licenses:
|
|
773
773
|
- MIT
|
774
774
|
metadata: {}
|
775
775
|
post_install_message: |-
|
776
|
-
Thanks for installing Zold 0.26.
|
776
|
+
Thanks for installing Zold 0.26.13!
|
777
777
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
778
778
|
Read our blog posts: https://blog.zold.io
|
779
779
|
Try ZLD online wallet at: https://wts.zold.io
|