nanook 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 632d341b2aa122d7c5049077fbebf1fd67097abb9bc0a4814ae938d2a5d70356
4
- data.tar.gz: 9e640aadc4074e46b95e2ceafff4a67808aeca2f181dd95d530fb1d52fb5be30
3
+ metadata.gz: 7431dc051a61aef23d118372d17df3c833e0963f05279a246c60b65eea10d478
4
+ data.tar.gz: cadd03df615dca28120483b30720215d15f357ac3afa57dcf226938a17ca45af
5
5
  SHA512:
6
- metadata.gz: a697f30061015b19d30075698e7d08fb4c868d886abfb8c420367e929dbf94b800b49f735785f1c6a72cda9ae8287704a90532b553c37c1ac0e8130118197b53
7
- data.tar.gz: 79ecfa816e0c6d2b7b2c671ac99a28bc8840dfff71a5c6e5608a5700a80c3dcf18632141b91d76d9d31219cb111395d220bb05b9ca744513415238cc6003ab1a
6
+ metadata.gz: c6249a2d0e98a38d38058c11f50a6b3677d014e35600792d3c18609532f7b97399320d004523eb730863f4bc9bbdab378e3349122e16caa66c394b717be73442
7
+ data.tar.gz: ba7494dc21db212d20dae2d7a436c5a0766675a76086fa35e9cbc0a98fac4249f451e99f145f8033f77bd1a3966d319a4d3d4d83f2eaf9d9793281100b2875d3
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 2.5.0
8
+
9
+ ### Added
10
+
11
+ - New `Nanook::Node#bootstrap_lazy` method.
12
+ - New `Nanook::Node#bootstrap_status` method.
13
+ - New `Nanook::Node#difficulty` method.
14
+ - New `Nanook::Node#uptime` method.
15
+ - New `Nanook::Wallet#lock` method.
16
+
17
+ ### Changed
18
+
19
+ - `Nanook::Node#chain` now takes optional `offset` argument.
20
+ - `Nanook::Node#successors` now takes optional `offset` argument.
21
+ - `Nanook::Node#successors` now aliased as `Nanook::Node#ancestors`
22
+ - Updated docs to use `nano_` prefixed addresses.
23
+
7
24
  ## 2.4.0
8
25
 
9
26
  ### Added
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Nanook
2
2
 
3
- This is a Ruby library for managing a [nano currency](https://nano.org/) node, including making and receiving payments, using the [nano RPC protocol](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol). Nano is a fee-less, fast, environmentally-friendly cryptocurrency. It's awesome. See [https://nano.org](https://nano.org/).
3
+ This is a Ruby library for managing a [nano currency](https://nano.org/) node, including making and receiving payments, using the [nano RPC protocol](https://developers.nano.org/docs/rpc). Nano is a fee-less, fast, environmentally-friendly cryptocurrency. It's awesome. See [https://nano.org](https://nano.org/).
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/nanook.svg)](https://badge.fury.io/rb/nanook)
6
6
  [![CircleCI](https://circleci.com/gh/lukes/nanook/tree/master.svg?style=shield)](https://circleci.com/gh/lukes/nanook/tree/master)
@@ -76,7 +76,7 @@ wallet = Nanook.new.wallet(wallet_id)
76
76
  wallet.pay(from: your_account_id, to: recipient_account_id, amount: 0.2, id: unique_id)
77
77
  ```
78
78
 
79
- The `id` can be any string and needs to be unique per payment. It serves an important purpose; it allows you to make this call multiple times with the same `id` and be reassured that you will only ever send that nano payment once. From the [Nano RPC](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#account-create):
79
+ The `id` can be any string and needs to be unique per payment. It serves an important purpose; it allows you to make this call multiple times with the same `id` and be reassured that you will only ever send that nano payment once. From the [Nano RPC](https://developers.nano.org/docs/rpc#send):
80
80
 
81
81
  > You can (and should) specify a unique id for each spend to provide idempotency. That means that if you [make the payment call] two times with the same id, the second request won't send any additional Nano.
82
82
 
@@ -86,7 +86,7 @@ The unit of the `amount` is NANO (which is currently technically Mnano — s
86
86
  account.pay(to: recipient_account_id, amount: 999, unit: :raw, id: unique_id)
87
87
  ```
88
88
 
89
- Note, there may be a delay in receiving a response due to Proof of Work being done. From the [Nano RPC](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#account-create):
89
+ Note, there may be a delay in receiving a response due to Proof of Work being done. From the [Nano RPC](https://developers.nano.org/docs/rpc#send):
90
90
 
91
91
  > Proof of Work is precomputed for one transaction in the background. If it has been a while since your last transaction it will send instantly, the next one will need to wait for Proof of Work to be generated.
92
92
 
@@ -120,11 +120,11 @@ wallet.receive(block_id, into: account_id)
120
120
 
121
121
  ## All commands
122
122
 
123
- Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/2.4.0/) for a searchable detailed description of every class and method, what the arguments mean, and example responses (Tip: the classes are listed under the "**Nanook** < Object" item in the sidebar).
123
+ Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/2.5.0/) for a searchable detailed description of every class and method, what the arguments mean, and example responses (Tip: the classes are listed under the "**Nanook** < Object" item in the sidebar).
124
124
 
125
125
  ### Wallets
126
126
 
127
- See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/2.4.0/Nanook/Wallet.html) for a detailed description of each method and example responses.
127
+ See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/2.5.0/Nanook/Wallet.html) for a detailed description of each method and example responses.
128
128
 
129
129
  #### Create wallet:
130
130
 
@@ -159,6 +159,7 @@ wallet.receive(into: account_id)
159
159
  wallet.receive(pending_block_id, into: account_id)
160
160
 
161
161
  wallet.account.create
162
+ wallet.account.create(5)
162
163
  wallet.accounts
163
164
  wallet.contains?(account_id)
164
165
 
@@ -167,6 +168,7 @@ wallet.change_default_representative(new_representative)
167
168
  wallet.info
168
169
  wallet.info(unit: :raw)
169
170
  wallet.export
171
+ wallet.lock
170
172
  wallet.locked?
171
173
  wallet.unlock(password)
172
174
  wallet.change_password(password)
@@ -189,7 +191,7 @@ Nanook.new.wallet(wallet_id).account.create(5)
189
191
 
190
192
  #### Working with a single account:
191
193
 
192
- See the [full documentation for Nanook::WalletAccount](https://lukes.github.io/nanook/2.4.0/Nanook/WalletAccount.html) for a detailed description of each method and example responses.
194
+ See the [full documentation for Nanook::WalletAccount](https://lukes.github.io/nanook/2.5.0/Nanook/WalletAccount.html) for a detailed description of each method and example responses.
193
195
 
194
196
  ```ruby
195
197
  account = Nanook.new.wallet(wallet_id).account(account_id)
@@ -229,7 +231,7 @@ account.destroy
229
231
 
230
232
  #### Working with any account (not necessarily in your wallet):
231
233
 
232
- See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/2.4.0/Nanook/Account.html) for a detailed description of each method and example responses.
234
+ See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/2.5.0/Nanook/Account.html) for a detailed description of each method and example responses.
233
235
 
234
236
  ```ruby
235
237
  account = Nanook.new.account(account_id)
@@ -262,7 +264,7 @@ account.weight
262
264
 
263
265
  ### Blocks
264
266
 
265
- See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/2.4.0/Nanook/Block.html) for a detailed description of each method and example responses.
267
+ See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/2.5.0/Nanook/Block.html) for a detailed description of each method and example responses.
266
268
 
267
269
  ```ruby
268
270
  block = Nanook.new.block(block_id)
@@ -272,6 +274,7 @@ block.info(allow_unchecked: true) # Verified blocks AND unchecked synchronizing
272
274
  block.account
273
275
  block.chain
274
276
  block.chain(limit: 10)
277
+ block.chain(offset: 10)
275
278
  block.confirm
276
279
  block.confirmed_recently?
277
280
  block.history
@@ -283,6 +286,7 @@ block.pending?
283
286
  block.publish
284
287
  block.successors
285
288
  block.successors(limit: 10)
289
+ block.successors(offset: 10)
286
290
 
287
291
  block.generate_work
288
292
  block.generate_work(use_peers: true)
@@ -292,7 +296,7 @@ block.is_valid_work?(work_id)
292
296
 
293
297
  ### Managing your nano node
294
298
 
295
- See the [full documentation for Nanook::Node](https://lukes.github.io/nanook/2.4.0/Nanook/Node.html) for a detailed description of each method and example responses.
299
+ See the [full documentation for Nanook::Node](https://lukes.github.io/nanook/2.5.0/Nanook/Node.html) for a detailed description of each method and example responses.
296
300
 
297
301
  ```ruby
298
302
  node = Nanook.new.node
@@ -300,9 +304,14 @@ node = Nanook.new.node
300
304
  node.account_count
301
305
  node.block_count
302
306
  node.block_count_by_type
303
- node.bootstrap_any
304
307
  node.bootstrap(address: "::ffff:138.201.94.249", port: 7075)
308
+ node.bootstrap_any
309
+ node.bootstrap_lazy(block_id)
310
+ node.bootstrap_lazy(block_id, force: true)
311
+ node.bootstrap_status
305
312
  node.confirmation_history
313
+ node.difficulty
314
+ node.difficulty(include_trend: true)
306
315
  node.peers
307
316
  node.representatives
308
317
  node.representatives(unit: :raw)
@@ -344,12 +353,12 @@ key.info
344
353
 
345
354
  ## Nanook Metal
346
355
 
347
- You can do any call listed in the [Nano RPC](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol) directly through the `rpc` method. The first argument should match the `action` of the RPC call, and then all remaining parameters are passed in as arguments.
356
+ You can do any call listed in the [Nano RPC](https://developers.nano.org/docs/rpc) directly through the `rpc` method. The first argument should match the `action` of the RPC call, and then all remaining parameters are passed in as arguments.
348
357
 
349
- E.g., the [accounts_create command](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#accounts-create) can be called like this:
358
+ E.g., the [accounts_create command](https://developers.nano.org/docs/rpc#accounts-create) can be called like this:
350
359
 
351
360
  ```ruby
352
- Nano.new.rpc(:accounts_create, wallet: wallet_id, count: 2)
361
+ Nanook.new.rpc.call(:accounts_create, wallet: wallet_id, count: 2)
353
362
  ```
354
363
 
355
364
  ## Contributing
@@ -370,11 +379,11 @@ The gem is available as open source under the terms of the [MIT License](https:/
370
379
 
371
380
  ## Buy me a nano coffee
372
381
 
373
- This library is totally free to use, but feel free to send some nano [my way](https://www.nanode.co/account/xrb_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j) if you'd like to!
382
+ This library is totally free to use, but feel free to send some nano [my way](https://www.nanode.co/account/nano_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j) if you'd like to!
374
383
 
375
- xrb_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j
384
+ nano_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j
376
385
 
377
- ![alt xrb_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j](https://raw.githubusercontent.com/lukes/nanook/master/img/qr.png)
386
+ ![alt nano_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j](https://raw.githubusercontent.com/lukes/nanook/master/img/qr.png)
378
387
 
379
388
 
380
389
 
@@ -58,7 +58,7 @@ class Nanook
58
58
  # Returns a new instance of {Nanook::Account}.
59
59
  #
60
60
  # ==== Example:
61
- # account = Nanook.new.account("xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000")
61
+ # account = Nanook.new.account("nano_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000")
62
62
  #
63
63
  # @param account [String] the id of the account you want to work with
64
64
  # @return [Nanook::Account]
@@ -8,12 +8,12 @@ class Nanook
8
8
  # Initialize this class through the convenient {Nanook#account} method:
9
9
  #
10
10
  # nanook = Nanook.new
11
- # account = nanook.account("xrb_...")
11
+ # account = nanook.account("nano_...")
12
12
  #
13
13
  # Or compose the longhand way like this:
14
14
  #
15
15
  # rpc_conn = Nanook::Rpc.new
16
- # account = Nanook::Account.new(rpc_conn, "xrb_...")
16
+ # account = Nanook::Account.new(rpc_conn, "nano_...")
17
17
  class Account
18
18
 
19
19
  def initialize(rpc, account)
@@ -30,8 +30,8 @@ class Nanook
30
30
  # Example response:
31
31
  #
32
32
  # {
33
- # :xrb_13bqhi1cdqq8yb9szneoc38qk899d58i5rcrgdk5mkdm86hekpoez3zxw5sd=>500000000000000000000000000000000000,
34
- # :xrb_17k6ug685154an8gri9whhe5kb5z1mf5w6y39gokc1657sh95fegm8ht1zpn=>961647970820730000000000000000000000
33
+ # :nano_13bqhi1cdqq8yb9szneoc38qk899d58i5rcrgdk5mkdm86hekpoez3zxw5sd=>500000000000000000000000000000000000,
34
+ # :nano_17k6ug685154an8gri9whhe5kb5z1mf5w6y39gokc1657sh95fegm8ht1zpn=>961647970820730000000000000000000000
35
35
  # }
36
36
  #
37
37
  # @param unit (see #balance)
@@ -89,7 +89,7 @@ class Nanook
89
89
  # [
90
90
  # {
91
91
  # type: "send",
92
- # account: "xrb_1kdc5u48j3hr5r7eof9iao47szqh81ndqgq5e5hrsn1g9a3sa4hkkcotn3uq",
92
+ # account: "nano_1kdc5u48j3hr5r7eof9iao47szqh81ndqgq5e5hrsn1g9a3sa4hkkcotn3uq",
93
93
  # amount: 2,
94
94
  # hash: "2C3C570EA8898443C0FD04A1C385A3E3A8C985AD792635FCDCEBB30ADF6A0570"
95
95
  # }
@@ -146,7 +146,7 @@ class Nanook
146
146
  #
147
147
  # ==== Example:
148
148
  #
149
- # account.representative # => "xrb_3pc..."
149
+ # account.representative # => "nano_3pc..."
150
150
  #
151
151
  # @return [String] Representative account of the account
152
152
  def representative
@@ -209,7 +209,7 @@ class Nanook
209
209
  #
210
210
  # ==== Example:
211
211
  #
212
- # account.id # => "xrb_16u..."
212
+ # account.id # => "nano_16u..."
213
213
  #
214
214
  # @return [String] the id of the account
215
215
  def id
@@ -225,7 +225,7 @@ class Nanook
225
225
  # Example response:
226
226
  #
227
227
  # {
228
- # id: "xrb_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5",
228
+ # id: "nano_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5",
229
229
  # balance: 11.439597000000001,
230
230
  # block_count: 4,
231
231
  # frontier: "2C3C570EA8898443C0FD04A1C385A3E3A8C985AD792635FCDCEBB30ADF6A0570",
@@ -241,7 +241,7 @@ class Nanook
241
241
  # Example response:
242
242
  #
243
243
  # {
244
- # id: "xrb_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5",
244
+ # id: "nano_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5",
245
245
  # balance: 11.439597000000001,
246
246
  # block_count: 4,
247
247
  # frontier: "2C3C570EA8898443C0FD04A1C385A3E3A8C985AD792635FCDCEBB30ADF6A0570",
@@ -249,7 +249,7 @@ class Nanook
249
249
  # open_block: "C82376314C387080A753871A32AD70F4168080C317C5E67356F0A62EB5F34FF9",
250
250
  # pending: 0,
251
251
  # public_key: "A82C906460046D230D7D37C6663723DC3EFCECC4B3254EBF45294B66746F4FEF",
252
- # representative: "xrb_3pczxuorp48td8645bs3m6c3xotxd3idskrenmi65rbrga5zmkemzhwkaznh",
252
+ # representative: "nano_3pczxuorp48td8645bs3m6c3xotxd3idskrenmi65rbrga5zmkemzhwkaznh",
253
253
  # representative_block: "C82376314C387080A753871A32AD70F4168080C317C5E67356F0A62EB5F34FF9",
254
254
  # weight: 0
255
255
  # }
@@ -316,7 +316,7 @@ class Nanook
316
316
  # Example response:
317
317
  #
318
318
  # {
319
- # :xrb_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j=>{
319
+ # :nano_3c3ek3k8135f6e8qtfy8eruk9q3yzmpebes7btzncccdest8ymzhjmnr196j=>{
320
320
  # :frontier=>"2C3C570EA8898443C0FD04A1C385A3E3A8C985AD792635FCDCEBB30ADF6A0570",
321
321
  # :open_block=>"C82376314C387080A753871A32AD70F4168080C317C5E67356F0A62EB5F34FF9",
322
322
  # :representative_block=>"C82376314C387080A753871A32AD70F4168080C317C5E67356F0A62EB5F34FF9",
@@ -324,7 +324,7 @@ class Nanook
324
324
  # :modified_timestamp=>1520500357,
325
325
  # :block_count=>4
326
326
  # },
327
- # :xrb_3c3ettq59kijuuad5fnaq35itc9schtr4r7r6rjhmwjbairowzq3wi5ap7h8=>{ ... }
327
+ # :nano_3c3ettq59kijuuad5fnaq35itc9schtr4r7r6rjhmwjbairowzq3wi5ap7h8=>{ ... }
328
328
  # }
329
329
  #
330
330
  # @param [Integer] limit number of accounts to return in the ledger (default is 1)
@@ -380,7 +380,7 @@ class Nanook
380
380
  # {
381
381
  # block: "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
382
382
  # amount: 6,
383
- # source: "xrb_3dcfozsmekr1tr9skf1oa5wbgmxt81qepfdnt7zicq5x3hk65fg4fqj58mbr"
383
+ # source: "nano_3dcfozsmekr1tr9skf1oa5wbgmxt81qepfdnt7zicq5x3hk65fg4fqj58mbr"
384
384
  # },
385
385
  # { ... }
386
386
  # ]
@@ -45,8 +45,11 @@ class Nanook
45
45
  rpc(:work_cancel, :hash).empty?
46
46
  end
47
47
 
48
- # Returns an Array of block hashes in the account chain starting at
49
- # this block.
48
+ # Returns a consecutive list of block hashes in the account chain
49
+ # starting at block back to count (direction from frontier back to
50
+ # open block, from newer blocks to older). Will list all blocks back
51
+ # to the open block of this chain when count is set to "-1".
52
+ # The requested block hash is included in the answer.
50
53
  #
51
54
  # See also #successors.
52
55
  #
@@ -60,11 +63,14 @@ class Nanook
60
63
  # "36A0FB717368BA8CF8D255B63DC207771EABC6C6FFC22A7F455EC2209464897E",
61
64
  # "FBF8B0E6623A31AB528EBD839EEAA91CAFD25C12294C46754E45FD017F7939EB"
62
65
  # ]
66
+ #
63
67
  # @param limit [Integer] maximum number of block hashes to return (default is 1000)
64
- def chain(limit: 1000)
65
- response = rpc(:chain, :block, count: limit)[:blocks]
68
+ # @param offset [Integer] return the account chain block hashes offset by the specified number of blocks (default is 0)
69
+ def chain(limit: 1000, offset: 0)
70
+ response = rpc(:chain, :block, count: limit, offset: offset)[:blocks]
66
71
  Nanook::Util.coerce_empty_string_to_type(response, Array)
67
72
  end
73
+ alias_method :ancestors, :chain
68
74
 
69
75
  # Request confirmation for a block from online representative nodes.
70
76
  # Will return immediately with a boolean to indicate if the request for
@@ -81,6 +87,9 @@ class Nanook
81
87
  rpc(:block_confirm, :hash)[:started] == 1
82
88
  end
83
89
 
90
+ # This call is for internal diagnostics/debug purposes only. Do not
91
+ # rely on this interface being stable and do not use in a production system.
92
+ #
84
93
  # Check if the block appears in the list of recently confirmed blocks by
85
94
  # online representatives. The full list of blocks can be queried for with {Nanook::Node#confirmation_history}.
86
95
  #
@@ -127,7 +136,7 @@ class Nanook
127
136
  #
128
137
  # [
129
138
  # {
130
- # :account=>"xrb_3x7cjioqahgs5ppheys6prpqtb4rdknked83chf97bot1unrbdkaux37t31b",
139
+ # :account=>"nano_3x7cjioqahgs5ppheys6prpqtb4rdknked83chf97bot1unrbdkaux37t31b",
131
140
  # :amount=>539834279601145558517940224,
132
141
  # :hash=>"36A0FB717368BA8CF8D255B63DC207771EABC6C6FFC22A7F455EC2209464897E",
133
142
  # :type=>"send"
@@ -164,7 +173,7 @@ class Nanook
164
173
  # :id=>"36A0FB717368BA8CF8D255B63DC207771EABC6C6FFC22A7F455EC2209464897E",
165
174
  # :type=>"send",
166
175
  # :previous=>"FBF8B0E6623A31AB528EBD839EEAA91CAFD25C12294C46754E45FD017F7939EB",
167
- # :destination=>"xrb_3x7cjioqahgs5ppheys6prpqtb4rdknked83chf97bot1unrbdkaux37t31b",
176
+ # :destination=>"nano_3x7cjioqahgs5ppheys6prpqtb4rdknked83chf97bot1unrbdkaux37t31b",
168
177
  # :balance=>"00000000000000000000000000000000",
169
178
  # :work=>"44cc24b60705083a",
170
179
  # :signature=>"42ADFEFE7C3FFF188AE92A202F8A5734DE91779C454613E446EEC93D001D6C953E9FD16730AF32C891791BA8EDAECEB059A213E2FE1EEB7ADF9D5D0815464D06"
@@ -260,10 +269,12 @@ class Nanook
260
269
  # ["36A0FB717368BA8CF8D255B63DC207771EABC6C6FFC22A7F455EC2209464897E"]
261
270
  #
262
271
  # @param limit [Integer] maximum number of send/receive block hashes
263
- # to return in the chain (default is 1000)
272
+ # to return in the chain (default is 1000)
273
+ # @param offset [Integer] return the account chain block hashes offset
274
+ # by the specified number of blocks (default is 0)
264
275
  # @return [Array<String>] block hashes in the account chain ending at this block
265
- def successors(limit: 1000)
266
- response = rpc(:successors, :block, count: limit)[:blocks]
276
+ def successors(limit: 1000, offset: 0)
277
+ response = rpc(:successors, :block, count: limit, offset: offset)[:blocks]
267
278
  Nanook::Util.coerce_empty_string_to_type(response, Array)
268
279
  end
269
280
 
@@ -90,7 +90,57 @@ class Nanook
90
90
  rpc(:bootstrap_any).has_key?(:success)
91
91
  end
92
92
 
93
- # Returns block and tally weight (in raw) for recent elections winners
93
+ # Initialize lazy bootstrap with given block hash
94
+ #
95
+ # @param hash [String]
96
+ # @param force [Boolean] False by default. Manually force closing
97
+ # of all current bootstraps
98
+ # @return [Boolean] indicating if the action was successful
99
+ def bootstrap_lazy(hash, force: false)
100
+ rpc(:bootstrap_lazy, hash: hash, force: force)[:started] == 1
101
+ end
102
+
103
+ # Returning status of current bootstrap attempt for debug purposes only.
104
+ # This call is for internal diagnostics/debug purposes only.
105
+ # Do not rely on this interface being stable and do not use in a
106
+ # production system.
107
+ #
108
+ # ==== Example:
109
+ #
110
+ # node.bootstrap_status
111
+ #
112
+ # Example response:
113
+ #
114
+ # {
115
+ # clients: 5790,
116
+ # pulls: 141065,
117
+ # pulling: 3,
118
+ # connections: 16,
119
+ # idle: 0,
120
+ # target_connections: 64,
121
+ # total_blocks: 536820,
122
+ # lazy_mode: true,
123
+ # lazy_blocks: 423388,
124
+ # lazy_state_unknown: 2,
125
+ # lazy_balances: 0,
126
+ # lazy_pulls: 0,
127
+ # lazy_stopped: 644,
128
+ # lazy_keys: 449,
129
+ # lazy_key_1: "A86EB2B479AAF3CD531C8356A1FBE3CB500DFBF5BF292E5E6B8D1048DE199C32"
130
+ # }
131
+ #
132
+ # @return [Hash{Symbol=>String|Integer|Boolean}]
133
+ def bootstrap_status
134
+ rpc(:bootstrap_status)
135
+ end
136
+
137
+ # This call is for internal diagnostics/debug purposes only.
138
+ # Do not rely on this interface being stable and do not use in a
139
+ # production system.
140
+ #
141
+ # Returns block and tally weight (in raw) election duration (in
142
+ # milliseconds), election confirmation timestamp for recent elections
143
+ # winners.
94
144
  #
95
145
  # ==== Example:
96
146
  #
@@ -101,11 +151,15 @@ class Nanook
101
151
  # [
102
152
  # {
103
153
  # block: "EA70B32C55C193345D625F766EEA2FCA52D3F2CCE0B3A30838CC543026BB0FEA",
104
- # tally: 80394786589602980996311817874549318248
154
+ # tally: 80394786589602980996311817874549318248,
155
+ # duration: 4000,
156
+ # time: 1544819986,
105
157
  # },
106
158
  # {
107
159
  # block: "F2F8DA6D2CA0A4D78EB043A7A29E12BDE5B4CE7DE1B99A93A5210428EE5B8667",
108
- # tally: 68921714529890443063672782079965877749
160
+ # tally: 68921714529890443063672782079965877749,
161
+ # duration: 6000,
162
+ # time: 1544819988,
109
163
  # }
110
164
  # ]
111
165
  #
@@ -118,6 +172,48 @@ class Nanook
118
172
  end
119
173
  end
120
174
 
175
+ # Returns the difficulty values (16 hexadecimal digits string, 64 bit)
176
+ # for the minimum required on the network (network_minimum) as well
177
+ # as the current active difficulty seen on the network (network_current,
178
+ # 5 minute trended average of adjusted difficulty seen on confirmed
179
+ # transactions) which can be used to perform rework for better
180
+ # prioritization of transaction processing. A multiplier of the
181
+ # network_current from the base difficulty of network_minimum is also
182
+ # provided for comparison.
183
+ #
184
+ # ==== Example:
185
+ #
186
+ # node.difficulty(include_trend: true)
187
+ #
188
+ # Example response:
189
+ #
190
+ # {
191
+ # network_minimum: "ffffffc000000000",
192
+ # network_current: "ffffffc1816766f2",
193
+ # multiplier: 1.024089858417128,
194
+ # difficulty_trend: [
195
+ # 1.156096135149775,
196
+ # 1.190133894573061,
197
+ # 1.135567138563921,
198
+ # 1.000000000000000,
199
+ # ]
200
+ # }
201
+ #
202
+ # @param include_trend [Boolean] false by default. Also returns the
203
+ # trend of difficulty seen on the network as a list of multipliers.
204
+ # Sampling occurs every 16 to 36 seconds. The list is ordered such
205
+ # that the first value is the most recent sample.
206
+ # @return [Hash{Symbol=>String|Float|Array}]
207
+ def difficulty(include_trend: false)
208
+ rpc(:active_difficulty, include_trend: include_trend).tap do |response|
209
+ response[:multiplier] = response[:multiplier].to_f
210
+
211
+ if response.key?(:difficulty_trend)
212
+ response[:difficulty_trend].map!(&:to_f)
213
+ end
214
+ end
215
+ end
216
+
121
217
  # @return [String]
122
218
  def inspect
123
219
  "#{self.class.name}(object_id: \"#{"0x00%x" % (object_id << 1)}\")"
@@ -136,9 +232,9 @@ class Nanook
136
232
  # Example response:
137
233
  #
138
234
  # {
139
- # xrb_1111111111111111111111111111111111111111111111111117353trpda: 3822372327060170000000000000000000000,
140
- # xrb_1111111111111111111111111111111111111111111111111awsq94gtecn: 30999999999999999999999999000000,
141
- # xrb_114nk4rwjctu6n6tr6g6ps61g1w3hdpjxfas4xj1tq6i8jyomc5d858xr1xi: 0
235
+ # nano_1111111111111111111111111111111111111111111111111117353trpda: 3822372327060170000000000000000000000,
236
+ # nano_1111111111111111111111111111111111111111111111111awsq94gtecn: 30999999999999999999999999000000,
237
+ # nano_114nk4rwjctu6n6tr6g6ps61g1w3hdpjxfas4xj1tq6i8jyomc5d858xr1xi: 0
142
238
  # }
143
239
  #
144
240
  # @return [Hash{Symbol=>Integer}] known representatives and their voting weight
@@ -165,7 +261,7 @@ class Nanook
165
261
  #
166
262
  # ==== Example:
167
263
  #
168
- # node.representatives_online # => ["xrb_111...", "xrb_222"]
264
+ # node.representatives_online # => ["nano_111...", "nano_222"]
169
265
  #
170
266
  # @return [Array<String>] array of representative account ids
171
267
  def representatives_online
@@ -208,6 +304,13 @@ class Nanook
208
304
  count.to_f * 100 / total.to_f
209
305
  end
210
306
 
307
+ # Returns node uptime in seconds
308
+ #
309
+ # @return [Integer] seconds of uptime
310
+ def uptime
311
+ rpc(:uptime)['seconds']
312
+ end
313
+
211
314
  # This method is deprecated and will be removed in 3.0, as a node never
212
315
  # reaches 100% synchronization.
213
316
  #
@@ -1,3 +1,3 @@
1
1
  class Nanook
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -33,7 +33,7 @@ class Nanook
33
33
  # want to restore the wallet anywhere else on the nano network besides
34
34
  # the node you originally created it on. The nano command line interface
35
35
  # (CLI) is the only method for discovering a wallet's seed. See the
36
- # {https://github.com/nanocurrency/raiblocks/wiki/Command-line-interface
36
+ # {https://developers.nano.org/docs/command-line-interface/#wallet_decrypt_unsafe
37
37
  # --wallet_decrypt_unsafe CLI command}.
38
38
  #
39
39
  # === Initializing
@@ -67,7 +67,7 @@ class Nanook
67
67
  #
68
68
  # ==== Examples:
69
69
  #
70
- # wallet.account("xrb_...") # => Nanook::WalletAccount
70
+ # wallet.account("nano_...") # => Nanook::WalletAccount
71
71
  # wallet.account.create # => Nanook::WalletAccount
72
72
  #
73
73
  # @param [String] account optional String of an account (starting with
@@ -128,11 +128,11 @@ class Nanook
128
128
  # Example response:
129
129
  #
130
130
  # {
131
- # "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"=>{
131
+ # "nano_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"=>{
132
132
  # "balance"=>2.5,
133
133
  # "pending"=>1
134
134
  # },
135
- # "xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"=>{
135
+ # "nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"=>{
136
136
  # "balance"=>51.4,
137
137
  # "pending"=>0
138
138
  # },
@@ -171,6 +171,9 @@ class Nanook
171
171
 
172
172
  # Changes a wallet's seed.
173
173
  #
174
+ # It's recommended to only change the seed of a wallet that contains
175
+ # no accounts.
176
+ #
174
177
  # ==== Example:
175
178
  #
176
179
  # wallet.change_seed("000D1BA...") # => true
@@ -227,9 +230,9 @@ class Nanook
227
230
  # Will return +true+ if the account exists in the wallet.
228
231
  #
229
232
  # ==== Example:
230
- # wallet.contains?("xrb_...") # => true
233
+ # wallet.contains?("nano_...") # => true
231
234
  #
232
- # @param account [String] id (will start with <tt>"xrb_..."</tt>)
235
+ # @param account [String] id (will start with <tt>"nano_..."</tt>)
233
236
  # @return [Boolean] indicating if the wallet contains the given account
234
237
  def contains?(account)
235
238
  wallet_required!
@@ -251,7 +254,7 @@ class Nanook
251
254
  # on the nano network.
252
255
  #
253
256
  # Note, there may be a delay in receiving a response due to Proof of
254
- # Work being done. From the {Nano RPC}[https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#account-create]:
257
+ # Work being done. From the {Nano RPC}[https://developers.nano.org/docs/rpc#send]:
255
258
  #
256
259
  # <i>Proof of Work is precomputed for one transaction in the
257
260
  # background. If it has been a while since your last transaction it
@@ -260,8 +263,8 @@ class Nanook
260
263
  #
261
264
  # ==== Examples:
262
265
  #
263
- # wallet.pay(from: "xrb_...", to: "xrb_...", amount: 1.1, id: "myUniqueId123") # => "9AE2311..."
264
- # wallet.pay(from: "xrb_...", to: "xrb_...", amount: 54000000000000, unit: :raw, id: "myUniqueId123") # => "9AE2311..."
266
+ # wallet.pay(from: "nano_...", to: "nano_...", amount: 1.1, id: "myUniqueId123") # => "9AE2311..."
267
+ # wallet.pay(from: "nano_...", to: "nano_...", amount: 54000000000000, unit: :raw, id: "myUniqueId123") # => "9AE2311..."
265
268
  #
266
269
  # @param from [String] account id of an account in your wallet
267
270
  # @param to (see Nanook::WalletAccount#pay)
@@ -292,11 +295,11 @@ class Nanook
292
295
  # Example response:
293
296
  #
294
297
  # {
295
- # :xrb_1111111111111111111111111111111111111111111111111117353trpda=>[
298
+ # :nano_1111111111111111111111111111111111111111111111111117353trpda=>[
296
299
  # "142A538F36833D1CC78B94E11C766F75818F8B940771335C6C1B8AB880C5BB1D",
297
300
  # "718CC2121C3E641059BC1C2CFC45666C99E8AE922F7A807B7D07B62C995D79E2"
298
301
  # ],
299
- # :xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3=>[
302
+ # :nano_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3=>[
300
303
  # "4C1FEEF0BEA7F50BE35489A1233FE002B212DEA554B55B1B470D78BD8F210C74"
301
304
  # ]
302
305
  # }
@@ -308,22 +311,22 @@ class Nanook
308
311
  # Example response:
309
312
  #
310
313
  # {
311
- # :xrb_1111111111111111111111111111111111111111111111111117353trpda=>[
314
+ # :nano_1111111111111111111111111111111111111111111111111117353trpda=>[
312
315
  # {
313
316
  # :amount=>6.0,
314
- # :source=>"xrb_3dcfozsmekr1tr9skf1oa5wbgmxt81qepfdnt7zicq5x3hk65fg4fqj58mbr",
317
+ # :source=>"nano_3dcfozsmekr1tr9skf1oa5wbgmxt81qepfdnt7zicq5x3hk65fg4fqj58mbr",
315
318
  # :block=>:"142A538F36833D1CC78B94E11C766F75818F8B940771335C6C1B8AB880C5BB1D"
316
319
  # },
317
320
  # {
318
321
  # :amount=>12.0,
319
- # :source=>"xrb_3dcfozsmekr1tr9skf1oa5wbgmxt81qepfdnt7zicq5x3hk65fg4fqj58mbr",
322
+ # :source=>"nano_3dcfozsmekr1tr9skf1oa5wbgmxt81qepfdnt7zicq5x3hk65fg4fqj58mbr",
320
323
  # :block=>:"242A538F36833D1CC78B94E11C766F75818F8B940771335C6C1B8AB880C5BB1D"
321
324
  # }
322
325
  # ],
323
- # :xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3=>[
326
+ # :nano_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3=>[
324
327
  # {
325
328
  # :amount=>106.370018,
326
- # :source=>"xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo",
329
+ # :source=>"nano_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo",
327
330
  # :block=>:"4C1FEEF0BEA7F50BE35489A1233FE002B212DEA554B55B1B470D78BD8F210C74"
328
331
  # }
329
332
  # ]
@@ -395,7 +398,7 @@ class Nanook
395
398
  #
396
399
  # ==== Example:
397
400
  #
398
- # wallet.default_representative # => "xrb_3pc..."
401
+ # wallet.default_representative # => "nano_3pc..."
399
402
  #
400
403
  # @return [String] Representative account of the account
401
404
  def default_representative
@@ -411,7 +414,7 @@ class Nanook
411
414
  #
412
415
  # ==== Example:
413
416
  #
414
- # wallet.change_default_representative("xrb_...") # => "xrb_..."
417
+ # wallet.change_default_representative("nano_...") # => "nano_..."
415
418
  #
416
419
  # @param [String] representative the id of the representative account
417
420
  # to set as this account's representative
@@ -470,7 +473,7 @@ class Nanook
470
473
  # id: "2C3C570EA8898443C0FD04A1C385A3E3A8C985AD792635FCDCEBB30ADF6A0570",
471
474
  # accounts: [
472
475
  # {
473
- # id: "xrb_11119gbh8hb4hj1duf7fdtfyf5s75okzxdgupgpgm1bj78ex3kgy7frt3s9n"
476
+ # id: "nano_11119gbh8hb4hj1duf7fdtfyf5s75okzxdgupgpgm1bj78ex3kgy7frt3s9n"
474
477
  # frontier: "E71AF3E9DD86BBD8B4620EFA63E065B34D358CFC091ACB4E103B965F95783321",
475
478
  # open_block: "643B77F1ECEFBDBE1CC909872964C1DBBE23A6149BD3CEF2B50B76044659B60F",
476
479
  # representative_block: "643B77F1ECEFBDBE1CC909872964C1DBBE23A6149BD3CEF2B50B76044659B60F",
@@ -505,6 +508,19 @@ class Nanook
505
508
  }.to_symbolized_hash
506
509
  end
507
510
 
511
+ # Locks the wallet. A locked wallet cannot pocket pending transactions or make payments. See {#unlock}.
512
+ #
513
+ # ==== Example:
514
+ #
515
+ # wallet.lock #=> true
516
+ #
517
+ # @return [Boolean] indicates if the wallet was successfully locked
518
+ def lock
519
+ wallet_required!
520
+ response = rpc(:wallet_lock)
521
+ !response.empty? && response[:locked] == 1
522
+ end
523
+
508
524
  # Returns +true+ if the wallet is locked.
509
525
  #
510
526
  # ==== Example:
@@ -113,14 +113,14 @@ class Nanook
113
113
  # if successful, or a {Nanook::Error} if unsuccessful.
114
114
  #
115
115
  # Note, there may be a delay in receiving a response due to Proof
116
- # of Work being done. From the {Nano RPC}[https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#account-create]:
116
+ # of Work being done. From the {Nano RPC}[https://developers.nano.org/docs/rpc#send]:
117
117
  #
118
118
  # <i>Proof of Work is precomputed for one transaction in the background. If it has been a while since your last transaction it will send instantly, the next one will need to wait for Proof of Work to be generated.</i>
119
119
  #
120
120
  # ==== Examples:
121
121
  #
122
- # account.pay(to: "xrb_...", amount: 1.1, id: "myUniqueId123") # => "9AE2311..."
123
- # account.pay(to: "xrb_...", amount: 54000000000000, id: "myUniqueId123", unit: :raw) # => "9AE2311..."
122
+ # account.pay(to: "nano_...", amount: 1.1, id: "myUniqueId123") # => "9AE2311..."
123
+ # account.pay(to: "nano_...", amount: 54000000000000, id: "myUniqueId123", unit: :raw) # => "9AE2311..."
124
124
  #
125
125
  # @param to [String] account id of the recipient of your payment
126
126
  # @param amount [Integer|Float]
@@ -211,7 +211,7 @@ class Nanook
211
211
  #
212
212
  # ==== Example:
213
213
  #
214
- # account.change_representative("xrb_...") # => "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
214
+ # account.change_representative("nano_...") # => "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
215
215
  #
216
216
  # @param [String] representative the id of the representative account
217
217
  # to set as this account's representative
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanook
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.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: 2018-07-05 00:00:00.000000000 Z
11
+ date: 2019-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.7.7
185
+ rubygems_version: 2.7.6
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Library for managing a nano currency node, including making and receiving