nanook 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +145 -3
- data/README.md +157 -90
- data/bin/console +4 -3
- data/lib/nanook.rb +77 -21
- data/lib/nanook/account.rb +236 -168
- data/lib/nanook/block.rb +363 -119
- data/lib/nanook/errors.rb +10 -0
- data/lib/nanook/node.rb +229 -66
- data/lib/nanook/private_key.rb +115 -0
- data/lib/nanook/public_key.rb +55 -0
- data/lib/nanook/rpc.rb +104 -44
- data/lib/nanook/util.rb +68 -19
- data/lib/nanook/version.rb +3 -1
- data/lib/nanook/wallet.rb +413 -120
- data/lib/nanook/wallet_account.rb +154 -91
- data/lib/nanook/work_peer.rb +14 -7
- metadata +29 -28
- data/lib/nanook/error.rb +0 -5
- data/lib/nanook/key.rb +0 -46
data/lib/nanook/error.rb
DELETED
data/lib/nanook/key.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
class Nanook
|
2
|
-
class Key
|
3
|
-
|
4
|
-
def initialize(rpc, key=nil)
|
5
|
-
@rpc = rpc
|
6
|
-
@key = key
|
7
|
-
end
|
8
|
-
|
9
|
-
def generate(seed: nil, index: nil)
|
10
|
-
if seed.nil? && index.nil?
|
11
|
-
rpc(:key_create)
|
12
|
-
elsif !seed.nil? && !index.nil?
|
13
|
-
rpc(:deterministic_key, seed: seed, index: index)
|
14
|
-
else
|
15
|
-
raise ArgumentError.new("This method must be called with either seed AND index params given or no params")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def id
|
20
|
-
@key
|
21
|
-
end
|
22
|
-
|
23
|
-
def info
|
24
|
-
key_required!
|
25
|
-
rpc(:key_expand)
|
26
|
-
end
|
27
|
-
|
28
|
-
def inspect
|
29
|
-
"#{self.class.name}(id: \"#{id}\", object_id: \"#{"0x00%x" % (object_id << 1)}\")"
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def rpc(action, params={})
|
35
|
-
p = @key.nil? ? {} : { key: @key }
|
36
|
-
@rpc.call(action, p.merge(params))
|
37
|
-
end
|
38
|
-
|
39
|
-
def key_required!
|
40
|
-
if @key.nil?
|
41
|
-
raise ArgumentError.new("Key must be present")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|