nanook 3.1.0 → 4.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -3
- data/README.md +13 -6
- data/lib/nanook.rb +3 -3
- data/lib/nanook/account.rb +50 -19
- data/lib/nanook/block.rb +19 -11
- data/lib/nanook/node.rb +42 -17
- data/lib/nanook/util.rb +9 -5
- data/lib/nanook/version.rb +1 -1
- data/lib/nanook/wallet.rb +12 -7
- data/lib/nanook/wallet_account.rb +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a8de62127c895a74b956a2b24a7619e526ef0050c34639edd4eeec20bac187
|
4
|
+
data.tar.gz: a2ac4e3e26838a04e33156d38a892623fa2ba893ca1ec02707caf07c72a1b955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6bc6c116aac59f7f3a124ef8e4c6db3377fb8d4c944be240576260ff985503c0b05d131b2f644abbc655ba2c741e057c9344654993dad9ed20f03622a604485
|
7
|
+
data.tar.gz: a2bb0a64d566613fa5c7e29ff454afd95491ccaac3233b1647f90c0d89afeac83d921748327ea417747e8675afd1f4978ca1ce9f1cb39603b50f3870a6dabaa0
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,25 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
7
|
|
7
|
-
##
|
8
|
+
## 4.0.0 (v22 compatible)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- `Node#bootstrap_lazy` now returns the v22 node response of a `Hash` of keys `started` and `key_inserted` with boolean values.
|
13
|
+
- `Node#bootstrap_any` now optionally takes `account` argument.
|
14
|
+
- `Account#pending` and `WalletAccount#pending`:
|
15
|
+
- now optionally takes `sorted` argument.
|
16
|
+
- now optionally takes `allow_unconfirmed` argument.
|
17
|
+
- `Account#balance` and `WalletAccount#balance` now optionally takes `allow_unconfirmed` argument.
|
18
|
+
- `Account#info` and `WalletAccount#info` now optionally takes `allow_unconfirmed` argument.
|
19
|
+
- `Block#pending?` now optionally takes `allow_unconfirmed` argument.
|
20
|
+
- `Wallet#pending` now optionally takes `allow_unconfirmed` argument.
|
21
|
+
|
22
|
+
## 3.1.0 (v21 compatible)
|
8
23
|
|
9
24
|
### Added
|
10
25
|
|
@@ -15,13 +30,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
15
30
|
|
16
31
|
- `Block.chain` and `Block.successors` no longer return the Block itself in the response.
|
17
32
|
|
18
|
-
## 3.0.1
|
33
|
+
## 3.0.1 (v21 compatible)
|
19
34
|
|
20
35
|
### Fixed
|
21
36
|
|
22
37
|
- Fix `Block#type` being `nil` when RPC doesn't return a `subtype`.
|
23
38
|
|
24
|
-
## 3.0.0
|
39
|
+
## 3.0.0 (v21 compatible)
|
25
40
|
|
26
41
|
### Removed
|
27
42
|
|
data/README.md
CHANGED
@@ -124,11 +124,11 @@ Read the [Using Nanook](https://github.com/lukes/nanook/wiki/Using-nanook) page
|
|
124
124
|
|
125
125
|
## All commands
|
126
126
|
|
127
|
-
Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/
|
127
|
+
Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/4.0.0/) for a searchable detailed description of every class and method, what the arguments mean, and example responses.
|
128
128
|
|
129
129
|
### Wallets
|
130
130
|
|
131
|
-
See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/
|
131
|
+
See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/4.0.0/Nanook/Wallet.html) for a detailed description of each method and example responses.
|
132
132
|
|
133
133
|
#### Create wallet:
|
134
134
|
|
@@ -158,6 +158,7 @@ wallet.pay(from: your_account_id, to: recipient_account_id, amount: 2, id: uniqu
|
|
158
158
|
wallet.pending
|
159
159
|
wallet.pending(limit: 1)
|
160
160
|
wallet.pending(detailed: true)
|
161
|
+
wallet.pending(allow_unconfirmed: true)
|
161
162
|
wallet.pending(unit: :raw)
|
162
163
|
wallet.receive(into: account_id)
|
163
164
|
wallet.receive(pending_block_id, into: account_id)
|
@@ -212,14 +213,17 @@ Any account on the Nano network that is known by your node can be initialized th
|
|
212
213
|
account = nanook.account(account_id)
|
213
214
|
```
|
214
215
|
|
215
|
-
See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/
|
216
|
+
See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/4.0.0/Nanook/Account.html) for a detailed description of each method and example responses.
|
216
217
|
|
217
218
|
```ruby
|
218
219
|
account.balance
|
220
|
+
account.balance(allow_unconfirmed: true)
|
219
221
|
account.balance(unit: :raw)
|
220
222
|
account.pending
|
221
223
|
account.pending(limit: 1)
|
224
|
+
account.pending(allow_unconfirmed: true)
|
222
225
|
account.pending(detailed: true)
|
226
|
+
account.pending(sorted: true)
|
223
227
|
account.pending(unit: :raw)
|
224
228
|
|
225
229
|
account.blocks
|
@@ -234,6 +238,7 @@ account.history(limit: 1)
|
|
234
238
|
account.history(unit: :raw)
|
235
239
|
account.history(sort: :desc)
|
236
240
|
account.info
|
241
|
+
account.info(allow_unconfirmed: true)
|
237
242
|
account.info(unit: :raw)
|
238
243
|
account.last_modified_at
|
239
244
|
account.ledger
|
@@ -260,7 +265,7 @@ account = wallet.account(account_id)
|
|
260
265
|
|
261
266
|
As well as the following methods, all methods of [regular accounts](#working-with-any-account) can also be called.
|
262
267
|
|
263
|
-
See the [full documentation for Nanook::WalletAccount](https://lukes.github.io/nanook/
|
268
|
+
See the [full documentation for Nanook::WalletAccount](https://lukes.github.io/nanook/4.0.0/Nanook/WalletAccount.html) for a detailed description of each method and example responses.
|
264
269
|
|
265
270
|
```ruby
|
266
271
|
account.pay(to: recipient_account_id, amount: 2, id: unique_id)
|
@@ -275,7 +280,7 @@ account.destroy
|
|
275
280
|
|
276
281
|
### Blocks
|
277
282
|
|
278
|
-
See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/
|
283
|
+
See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/4.0.0/Nanook/Block.html) for a detailed description of each method and example responses.
|
279
284
|
|
280
285
|
```ruby
|
281
286
|
block = nanook.block(block_id)
|
@@ -303,6 +308,7 @@ block.info(unit: :raw)
|
|
303
308
|
block.next
|
304
309
|
block.open?
|
305
310
|
block.pending?
|
311
|
+
block.pending?(allow_unconfirmed: true)
|
306
312
|
block.previous
|
307
313
|
block.receive?
|
308
314
|
block.representative
|
@@ -324,7 +330,7 @@ block.valid_work?(work)
|
|
324
330
|
|
325
331
|
### Managing your nano node
|
326
332
|
|
327
|
-
See the [full documentation for Nanook::Node](https://lukes.github.io/nanook/
|
333
|
+
See the [full documentation for Nanook::Node](https://lukes.github.io/nanook/4.0.0/Nanook/Node.html) for a detailed description of each method and example responses.
|
328
334
|
|
329
335
|
```ruby
|
330
336
|
node = nanook.node
|
@@ -333,6 +339,7 @@ node.account_count
|
|
333
339
|
node.block_count
|
334
340
|
node.bootstrap(address: "::ffff:138.201.94.249", port: 7075)
|
335
341
|
node.bootstrap_any
|
342
|
+
node.bootstrap_any(account: account_id)
|
336
343
|
node.bootstrap_lazy(block_id)
|
337
344
|
node.bootstrap_lazy(block_id, force: true)
|
338
345
|
node.confirmation_quorum
|
data/lib/nanook.rb
CHANGED
@@ -97,7 +97,7 @@ class Nanook
|
|
97
97
|
# @param key [String] a private key
|
98
98
|
# @return [Nanook::PrivateKey]
|
99
99
|
def private_key(key = nil)
|
100
|
-
as_private_key(key)
|
100
|
+
as_private_key(key, allow_blank: true)
|
101
101
|
end
|
102
102
|
|
103
103
|
# Returns a new instance of {Nanook::PublicKey}.
|
@@ -170,8 +170,8 @@ class Nanook
|
|
170
170
|
# @return [Nanook::WorkPeer]
|
171
171
|
def network_telemetry
|
172
172
|
response = call_rpc(:telemetry, _coerce: Hash)
|
173
|
-
response[:genesis_block] = as_block(response[:genesis_block])
|
174
|
-
response[:timestamp] = as_time(response[:timestamp])
|
173
|
+
response[:genesis_block] = as_block(response[:genesis_block])
|
174
|
+
response[:timestamp] = as_time(response[:timestamp])
|
175
175
|
response
|
176
176
|
end
|
177
177
|
|
data/lib/nanook/account.rb
CHANGED
@@ -209,7 +209,7 @@ class Nanook
|
|
209
209
|
# @return [Nanook::Account] Representative of the account. Can be nil.
|
210
210
|
def representative
|
211
211
|
representative = rpc(:account_representative, _access: :representative)
|
212
|
-
as_account(representative)
|
212
|
+
as_account(representative)
|
213
213
|
end
|
214
214
|
|
215
215
|
# The account's balance, including pending (unreceived payments).
|
@@ -241,7 +241,10 @@ class Nanook
|
|
241
241
|
# balance: 2000000000000000000000000000000,
|
242
242
|
# pending: 1100000000000000000000000000000
|
243
243
|
# }
|
244
|
-
#
|
244
|
+
# @param allow_unconfirmed [Boolean] +false+ by default. When +false+, +balance+
|
245
|
+
# will only include blocks on this account that have already been confirmed
|
246
|
+
# and +pending+ will only include incoming send blocks that have already been
|
247
|
+
# confirmed on the sending account.
|
245
248
|
# @param unit [Symbol] default is {Nanook.default_unit}.
|
246
249
|
# Must be one of {Nanook::UNITS}.
|
247
250
|
# Represents the unit that the balances will be returned in.
|
@@ -250,10 +253,14 @@ class Nanook
|
|
250
253
|
# See {https://docs.nano.org/protocol-design/distribution-and-units/#unit-dividers What are Nano's Units}
|
251
254
|
# @raise [Nanook::NanoUnitError] if `unit` is invalid
|
252
255
|
# @return [Hash{Symbol=>Integer|Float}]
|
253
|
-
def balance(unit: Nanook.default_unit)
|
256
|
+
def balance(allow_unconfirmed: false, unit: Nanook.default_unit)
|
254
257
|
validate_unit!(unit)
|
255
258
|
|
256
|
-
|
259
|
+
params = {
|
260
|
+
include_only_confirmed: !allow_unconfirmed
|
261
|
+
}
|
262
|
+
|
263
|
+
rpc(:account_balance, params).tap do |r|
|
257
264
|
if unit == :nano
|
258
265
|
r[:balance] = raw_to_NANO(r[:balance])
|
259
266
|
r[:pending] = raw_to_NANO(r[:pending])
|
@@ -304,6 +311,8 @@ class Nanook
|
|
304
311
|
# }
|
305
312
|
#
|
306
313
|
# @param unit (see #balance)
|
314
|
+
# @param allow_unconfirmed [Boolean] +false+ by default. When +false+ only confirmed +balance+
|
315
|
+
# +pending+, and +representative+ values are returned.
|
307
316
|
# @return [Hash{Symbol=>String|Integer|Float|Nanook::Account|Nanook::Block|Time}] information about the account containing:
|
308
317
|
# [+id+] The account id
|
309
318
|
# [+frontier+] The latest {Nanook::Block}
|
@@ -319,19 +328,36 @@ class Nanook
|
|
319
328
|
# [+weight+] See {#weight}
|
320
329
|
#
|
321
330
|
# @raise [Nanook::NanoUnitError] if `unit` is invalid
|
322
|
-
def info(unit: Nanook.default_unit)
|
331
|
+
def info(allow_unconfirmed: false, unit: Nanook.default_unit)
|
323
332
|
validate_unit!(unit)
|
324
333
|
|
325
|
-
|
334
|
+
params = {
|
335
|
+
representative: true,
|
336
|
+
weight: true,
|
337
|
+
pending: true,
|
338
|
+
include_confirmed: !allow_unconfirmed
|
339
|
+
}
|
340
|
+
|
341
|
+
response = rpc(:account_info, params)
|
326
342
|
response.merge!(id: @account)
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
response[:
|
343
|
+
|
344
|
+
# The RPC returned confirmed data when the `include_confirmed: true`
|
345
|
+
# has been passed. Normalize this data to the same keys as when
|
346
|
+
# unconfirmed data can be returned.
|
347
|
+
unless allow_unconfirmed
|
348
|
+
response[:balance] = response.delete(:confirmed_balance)
|
349
|
+
response[:pending] = response.delete(:confirmed_pending)
|
350
|
+
response[:representative] = response.delete(:confirmed_representative)
|
351
|
+
response[:frontier] = response.delete(:confirmed_frontier)
|
352
|
+
response[:confirmation_height] = response.delete(:confirmed_height)
|
333
353
|
end
|
354
|
+
|
355
|
+
response[:frontier] = as_block(response[:frontier])
|
356
|
+
response[:open_block] = as_block(response[:open_block])
|
357
|
+
response[:representative_block] = as_block(response[:representative_block])
|
358
|
+
response[:representative] = as_account(response[:representative])
|
334
359
|
response[:last_modified_at] = as_time(response.delete(:modified_timestamp))
|
360
|
+
response[:confirmation_height_frontier] = as_block(response[:confirmation_height_frontier])
|
335
361
|
|
336
362
|
if unit == :nano
|
337
363
|
response.merge!(
|
@@ -341,7 +367,7 @@ class Nanook
|
|
341
367
|
)
|
342
368
|
end
|
343
369
|
|
344
|
-
response
|
370
|
+
response.compact
|
345
371
|
end
|
346
372
|
|
347
373
|
# @return [String]
|
@@ -402,10 +428,10 @@ class Nanook
|
|
402
428
|
end
|
403
429
|
|
404
430
|
ledger[:last_modified_at] = as_time(ledger.delete(:modified_timestamp))
|
405
|
-
ledger[:representative] = as_account(ledger[:representative])
|
406
|
-
ledger[:representative_block] = as_block(ledger[:representative_block])
|
407
|
-
ledger[:open_block] = as_block(ledger[:open_block])
|
408
|
-
ledger[:frontier] = as_block(ledger[:frontier])
|
431
|
+
ledger[:representative] = as_account(ledger[:representative])
|
432
|
+
ledger[:representative_block] = as_block(ledger[:representative_block])
|
433
|
+
ledger[:open_block] = as_block(ledger[:open_block])
|
434
|
+
ledger[:frontier] = as_block(ledger[:frontier])
|
409
435
|
|
410
436
|
[as_account(account_id), ledger]
|
411
437
|
end
|
@@ -444,17 +470,22 @@ class Nanook
|
|
444
470
|
# ]
|
445
471
|
#
|
446
472
|
# @param limit [Integer] number of pending blocks to return (default is 1000)
|
447
|
-
# @param detailed [Boolean]return a more complex Hash of pending block information (default is +false+)
|
473
|
+
# @param detailed [Boolean] return a more complex Hash of pending block information (default is +false+)
|
474
|
+
# @param allow_unconfirmed [Boolean] +false+ by default. When +false+ only returns block which have their confirmation
|
475
|
+
# height set or are undergoing confirmation height processing.
|
448
476
|
# @param unit (see #balance)
|
477
|
+
# @param sorted [Boolean] false by default. Additionally sorts the blocks by their amounts in descending order.
|
449
478
|
#
|
450
479
|
# @return [Array<Nanook::Block>]
|
451
480
|
# @return [Array<Hash{Symbol=>Nanook::Block|Nanook::Account|Integer}>]
|
452
481
|
# @raise [Nanook::NanoUnitError] if `unit` is invalid
|
453
|
-
def pending(limit: 1000, detailed: false, unit: Nanook.default_unit)
|
482
|
+
def pending(limit: 1000, detailed: false, allow_unconfirmed: false, unit: Nanook.default_unit, sorted: false)
|
454
483
|
validate_unit!(unit)
|
455
484
|
|
456
485
|
params = {
|
457
486
|
count: limit,
|
487
|
+
sorting: sorted,
|
488
|
+
include_only_confirmed: !allow_unconfirmed,
|
458
489
|
_access: :blocks,
|
459
490
|
_coerce: (detailed ? Hash : Array)
|
460
491
|
}
|
data/lib/nanook/block.rb
CHANGED
@@ -82,7 +82,7 @@ class Nanook
|
|
82
82
|
#
|
83
83
|
# @param limit [Integer] maximum number of block hashes to return (default is 1000)
|
84
84
|
# @param offset [Integer] return the account chain block hashes offset by the specified number of blocks (default is 0)
|
85
|
-
def
|
85
|
+
def ancestors(limit: 1000, offset: 0)
|
86
86
|
# The RPC includes this block in its response, and Nanook will remove it from the results.
|
87
87
|
# Increment the limit by 1 to account for this (a limit of -1 is valid and means no limit).
|
88
88
|
limit += 1 if limit > 0
|
@@ -96,7 +96,7 @@ class Nanook
|
|
96
96
|
response = rpc(:chain, :block, params)[1..].to_a
|
97
97
|
response.map { |block| as_block(block) }
|
98
98
|
end
|
99
|
-
alias ancestors chain
|
99
|
+
alias chain ancestors # `chain` is the RPC command name
|
100
100
|
|
101
101
|
# Request confirmation for a block from online representative nodes.
|
102
102
|
# Will return immediately with a boolean to indicate if the request for
|
@@ -222,9 +222,17 @@ class Nanook
|
|
222
222
|
#
|
223
223
|
# block.pending? #=> false
|
224
224
|
#
|
225
|
+
# @param allow_unconfirmed [Boolean] +false+ by default. When +false+,
|
226
|
+
# will only include blocks which have their confirmation height set
|
227
|
+
# or are undergoing confirmation height processing.
|
225
228
|
# @return [Boolean] signalling if the block is a pending block.
|
226
|
-
def pending?
|
227
|
-
|
229
|
+
def pending?(allow_unconfirmed: false)
|
230
|
+
params = {
|
231
|
+
include_only_confirmed: !allow_unconfirmed,
|
232
|
+
_access: :exists
|
233
|
+
}
|
234
|
+
|
235
|
+
rpc(:pending_exists, :hash, params) == 1
|
228
236
|
end
|
229
237
|
|
230
238
|
# Returns an Array of block hashes in the account chain from (but not including) this block up to +count+
|
@@ -242,7 +250,7 @@ class Nanook
|
|
242
250
|
# @param offset [Integer] return the account chain block hashes offset
|
243
251
|
# by the specified number of blocks (default is 0)
|
244
252
|
# @return [Array<Nanook::Block>] blocks in the account chain ending at this block
|
245
|
-
def
|
253
|
+
def descendants(limit: 1000, offset: 0)
|
246
254
|
# The RPC includes this block in its response, and Nanook will remove it from the results.
|
247
255
|
# Increment the limit by 1 to account for this (a limit of -1 is valid and means no limit).
|
248
256
|
limit += 1 if limit > 0
|
@@ -257,7 +265,7 @@ class Nanook
|
|
257
265
|
response = rpc(:successors, :block, params)[1..].to_a
|
258
266
|
response.map { |block| as_block(block) }
|
259
267
|
end
|
260
|
-
alias descendants successors
|
268
|
+
alias successors descendants # `successors` is the RPC command name
|
261
269
|
|
262
270
|
# Returns the {Nanook::Account} of the block representative.
|
263
271
|
#
|
@@ -513,11 +521,11 @@ class Nanook
|
|
513
521
|
response[:type] = subtype
|
514
522
|
end
|
515
523
|
|
516
|
-
response[:account] = as_account(response[:account])
|
517
|
-
response[:representative] = as_account(response[:representative])
|
518
|
-
response[:previous] = as_block(response[:previous])
|
519
|
-
response[:link] = as_block(response[:link])
|
520
|
-
response[:link_as_account] = as_account(response[:link_as_account])
|
524
|
+
response[:account] = as_account(response[:account])
|
525
|
+
response[:representative] = as_account(response[:representative])
|
526
|
+
response[:previous] = as_block(response[:previous])
|
527
|
+
response[:link] = as_block(response[:link])
|
528
|
+
response[:link_as_account] = as_account(response[:link_as_account])
|
521
529
|
response[:local_timestamp] = as_time(response[:local_timestamp])
|
522
530
|
response[:last_modified_at] = as_time(response[:last_modified_at])
|
523
531
|
|
data/lib/nanook/node.rb
CHANGED
@@ -79,19 +79,41 @@ class Nanook
|
|
79
79
|
|
80
80
|
# Initialize multi-connection bootstrap to random peers
|
81
81
|
#
|
82
|
+
# @param account [Nanook::Account] False by default. Manually force closing
|
83
|
+
# of all current bootstraps
|
82
84
|
# @return [Boolean] indicating if the action was successful
|
83
|
-
def bootstrap_any
|
84
|
-
|
85
|
+
def bootstrap_any(account: nil)
|
86
|
+
params = {
|
87
|
+
account: account
|
88
|
+
}.compact
|
89
|
+
|
90
|
+
rpc(:bootstrap_any, params).key?(:success)
|
85
91
|
end
|
86
92
|
|
87
|
-
# Initialize lazy bootstrap with given block hash
|
93
|
+
# Initialize lazy bootstrap with given block hash.
|
94
|
+
# Response includes whether new election was started and whether a
|
95
|
+
# new lazy key_inserted was successful.
|
96
|
+
#
|
97
|
+
# ==== Example:
|
98
|
+
#
|
99
|
+
# node.bootstrap_lazy
|
100
|
+
#
|
101
|
+
# Example response:
|
102
|
+
#
|
103
|
+
# {
|
104
|
+
# "started": true,
|
105
|
+
# "key_inserted": false
|
106
|
+
# }
|
88
107
|
#
|
89
108
|
# @param hash [String]
|
90
109
|
# @param force [Boolean] False by default. Manually force closing
|
91
110
|
# of all current bootstraps
|
92
|
-
# @return [Boolean] indicating if the action was successful
|
111
|
+
# @return [Hash{Symbol=>Boolean}] indicating if the action was successful
|
93
112
|
def bootstrap_lazy(hash, force: false)
|
94
|
-
rpc(:bootstrap_lazy, hash: hash, force: force
|
113
|
+
response = rpc(:bootstrap_lazy, hash: hash, force: force)
|
114
|
+
values = response.map { |k, v| [k, v == 1] }
|
115
|
+
|
116
|
+
Hash[values]
|
95
117
|
end
|
96
118
|
|
97
119
|
# Returns information about node elections settings and observed network state:
|
@@ -110,12 +132,12 @@ class Nanook
|
|
110
132
|
# Example response:
|
111
133
|
#
|
112
134
|
# {
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
135
|
+
# quorum_delta: 43216377.43025059,
|
136
|
+
# online_weight_quorum_percent: 50,
|
137
|
+
# online_weight_minimum: 60000000.0,
|
138
|
+
# online_stake_total: 86432754.86050119,
|
139
|
+
# peers_stake_total: 84672338.52479072,
|
140
|
+
# peers_stake_required: 60000000.0
|
119
141
|
# }
|
120
142
|
#
|
121
143
|
# @return [Hash{Symbol=>String|Integer}]
|
@@ -136,6 +158,9 @@ class Nanook
|
|
136
158
|
response.compact
|
137
159
|
end
|
138
160
|
|
161
|
+
# Note: This RPC call is deprecated as of v22 of the node software.
|
162
|
+
# https://docs.nano.org/releases/release-v22-0/
|
163
|
+
#
|
139
164
|
# Returns the difficulty values (16 hexadecimal digits string, 64 bit)
|
140
165
|
# for the minimum required on the network (network_minimum) as well
|
141
166
|
# as the current active difficulty seen on the network (network_current,
|
@@ -276,12 +301,12 @@ class Nanook
|
|
276
301
|
}
|
277
302
|
|
278
303
|
response = rpc(:unchecked, params).map do |block, info|
|
279
|
-
info[:account] = as_account(info[:account])
|
280
|
-
info[:link_as_account] = as_account(info[:link_as_account])
|
281
|
-
info[:representative] = as_account(info[:representative])
|
282
|
-
info[:previous] = as_block(info[:previous])
|
283
|
-
info[:link] = as_block(info[:link])
|
284
|
-
info[:balance] = raw_to_NANO(info[:balance]) if unit == :nano
|
304
|
+
info[:account] = as_account(info[:account])
|
305
|
+
info[:link_as_account] = as_account(info[:link_as_account])
|
306
|
+
info[:representative] = as_account(info[:representative])
|
307
|
+
info[:previous] = as_block(info[:previous])
|
308
|
+
info[:link] = as_block(info[:link])
|
309
|
+
info[:balance] = raw_to_NANO(info[:balance]) if unit == :nano
|
285
310
|
|
286
311
|
[as_block(block), info]
|
287
312
|
end
|
data/lib/nanook/util.rb
CHANGED
@@ -67,23 +67,27 @@ class Nanook
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def as_account(account_id)
|
70
|
-
Nanook::Account.new(@rpc, account_id)
|
70
|
+
Nanook::Account.new(@rpc, account_id) if account_id
|
71
71
|
end
|
72
72
|
|
73
|
-
def as_wallet_account(account_id)
|
73
|
+
def as_wallet_account(account_id, allow_blank: false)
|
74
|
+
return unless account_id || allow_blank
|
75
|
+
|
74
76
|
Nanook::WalletAccount.new(@rpc, @wallet, account_id)
|
75
77
|
end
|
76
78
|
|
77
79
|
def as_block(block_id)
|
78
|
-
Nanook::Block.new(@rpc, block_id)
|
80
|
+
Nanook::Block.new(@rpc, block_id) if block_id
|
79
81
|
end
|
80
82
|
|
81
|
-
def as_private_key(key)
|
83
|
+
def as_private_key(key, allow_blank: false)
|
84
|
+
return unless key || allow_blank
|
85
|
+
|
82
86
|
Nanook::PrivateKey.new(@rpc, key)
|
83
87
|
end
|
84
88
|
|
85
89
|
def as_public_key(key)
|
86
|
-
Nanook::PublicKey.new(@rpc, key)
|
90
|
+
Nanook::PublicKey.new(@rpc, key) if key
|
87
91
|
end
|
88
92
|
|
89
93
|
def as_time(time)
|
data/lib/nanook/version.rb
CHANGED
data/lib/nanook/wallet.rb
CHANGED
@@ -102,7 +102,9 @@ class Nanook
|
|
102
102
|
# @return [Nanook::WalletAccount]
|
103
103
|
def account(account = nil)
|
104
104
|
check_wallet_required!
|
105
|
-
|
105
|
+
|
106
|
+
# We `allow_blank` in order to support `WalletAccount#create`.
|
107
|
+
as_wallet_account(account, allow_blank: true)
|
106
108
|
end
|
107
109
|
|
108
110
|
# Array of {Nanook::WalletAccount} instances of accounts in the wallet.
|
@@ -338,6 +340,8 @@ class Nanook
|
|
338
340
|
# See also the {#receive} method of this class for how to receive a pending payment.
|
339
341
|
#
|
340
342
|
# @param limit [Integer] number of accounts with pending payments to return (default is 1000)
|
343
|
+
# @param allow_unconfirmed [Boolean] +false+ by default. When +false+ only returns block which
|
344
|
+
# have their confirmation height set or are undergoing confirmation height processing.
|
341
345
|
# @param detailed [Boolean]return a more complex Hash of pending block information (default is +false+)
|
342
346
|
# @param unit (see Nanook::Account#balance)
|
343
347
|
#
|
@@ -386,11 +390,12 @@ class Nanook
|
|
386
390
|
# }
|
387
391
|
#
|
388
392
|
# @raise [Nanook::NanoUnitError] if `unit` is invalid
|
389
|
-
def pending(limit: 1000, detailed: false, unit: Nanook.default_unit)
|
393
|
+
def pending(limit: 1000, detailed: false, allow_unconfirmed: false, unit: Nanook.default_unit)
|
390
394
|
validate_unit!(unit)
|
391
395
|
|
392
396
|
params = {
|
393
397
|
count: limit,
|
398
|
+
include_only_confirmed: !allow_unconfirmed,
|
394
399
|
_access: :blocks,
|
395
400
|
_coerce: Hash
|
396
401
|
}
|
@@ -482,7 +487,7 @@ class Nanook
|
|
482
487
|
# @return [Nanook::Account] Representative account. Can be nil.
|
483
488
|
def default_representative
|
484
489
|
representative = rpc(:wallet_representative, _access: :representative)
|
485
|
-
as_account(representative)
|
490
|
+
as_account(representative)
|
486
491
|
end
|
487
492
|
alias representative default_representative
|
488
493
|
|
@@ -570,10 +575,10 @@ class Nanook
|
|
570
575
|
response = rpc(:wallet_ledger, _access: :accounts, _coerce: Hash)
|
571
576
|
|
572
577
|
accounts = response.map do |account_id, data|
|
573
|
-
data[:frontier] = as_block(data[:frontier])
|
574
|
-
data[:open_block] = as_block(data[:open_block])
|
575
|
-
data[:representative_block] = as_block(data[:representative_block])
|
576
|
-
data[:balance] = raw_to_NANO(data[:balance]) if unit == :nano
|
578
|
+
data[:frontier] = as_block(data[:frontier])
|
579
|
+
data[:open_block] = as_block(data[:open_block])
|
580
|
+
data[:representative_block] = as_block(data[:representative_block])
|
581
|
+
data[:balance] = raw_to_NANO(data[:balance]) if unit == :nano
|
577
582
|
data[:last_modified_at] = as_time(data.delete(:modified_timestamp))
|
578
583
|
|
579
584
|
[as_account(account_id), data]
|
@@ -21,7 +21,7 @@ class Nanook
|
|
21
21
|
extend Forwardable
|
22
22
|
# @!method ==
|
23
23
|
# (see Nanook::Account#==)
|
24
|
-
# @!method balance(unit: Nanook.default_unit)
|
24
|
+
# @!method balance(allow_unconfirmed: false, unit: Nanook.default_unit)
|
25
25
|
# (see Nanook::Account#balance)
|
26
26
|
# @!method block_count
|
27
27
|
# (see Nanook::Account#block_count)
|
@@ -41,7 +41,7 @@ class Nanook
|
|
41
41
|
# (see Nanook::Account#history)
|
42
42
|
# @!method id
|
43
43
|
# (see Nanook::Account#id)
|
44
|
-
# @!method info(
|
44
|
+
# @!method info(allow_unconfirmed: false, detailed: false, unit: Nanook.default_unit)
|
45
45
|
# (see Nanook::Account#info)
|
46
46
|
# @!method last_modified_at
|
47
47
|
# (see Nanook::Account#last_modified_at)
|
@@ -49,7 +49,7 @@ class Nanook
|
|
49
49
|
# (see Nanook::Account#ledger)
|
50
50
|
# @!method open_block
|
51
51
|
# (see Nanook::Account#open_block)
|
52
|
-
# @!method pending(limit: 1000, detailed: false, unit: Nanook.default_unit)
|
52
|
+
# @!method pending(limit: 1000, detailed: false, allow_unconfirmed: false, unit: Nanook.default_unit, sorted: false)
|
53
53
|
# (see Nanook::Account#pending)
|
54
54
|
# @!method public_key
|
55
55
|
# (see Nanook::Account#public_key)
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Duncalfe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.10
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|