Class: Lisk::Legacy

Inherits:
Object
  • Object
show all
Defined in:
lib/lisk/legacy.rb

Overview

Implements raw legacy APIs of the Lisk Core pre-1.0.0 node.

Direct Known Subclasses

API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Legacy

Initializing the legacy API with a legacy Lisk Core API client.



11
12
13
14
15
16
17
18
# File 'lib/lisk/legacy.rb', line 11

def initialize client
  if not client.nil?
    @client = client
    return self
  else
    return nil
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Handles unimplemented methods



451
452
453
# File 'lib/lisk/legacy.rb', line 451

def method_missing name, *args, &block
  todo "#{self}::#{name} METHOD MISSING"
end

Instance Attribute Details

#clientObject

A “lisk/client” connecting to a Lisk Core API node.



8
9
10
# File 'lib/lisk/legacy.rb', line 8

def client
  @client
end

Instance Method Details

#accounts(address) ⇒ Object

Returns account information of an address. ‘GET /accounts?address=address`



55
56
57
58
# File 'lib/lisk/legacy.rb', line 55

def accounts address
  params = { :address => address }
   = @client.query_get "accounts", params
end

#accounts_delegates(address) ⇒ Object

Get votes by account wallet address. ‘GET /accounts/delegates/?address=address`



303
304
305
306
# File 'lib/lisk/legacy.rb', line 303

def accounts_delegates address
  params = { :address => address }
   = @client.query_get "accounts/delegates", params
end

#accounts_delegates_get_by_address(address) ⇒ Object

Returns delegate vote accounts by address. ‘GET /accounts/delegates?address=address`



62
63
64
65
# File 'lib/lisk/legacy.rb', line 62

def accounts_delegates_get_by_address address
  params = { :address => address }
  delegate = @client.query_get "accounts/delegates", params
end

#accounts_delegates_put(votes) ⇒ Object

Vote for the selected delegates. Maximum of 33 delegates at once. ‘PUT /accounts/delegates`



69
70
71
# File 'lib/lisk/legacy.rb', line 69

def accounts_delegates_put votes
  delegate = @client.query_put "accounts/delegates", votes
end

#accounts_generate_public_key(secret) ⇒ Object

Returns the public key of the provided secret key. ‘POST /accounts/generatePublicKey`



48
49
50
51
# File 'lib/lisk/legacy.rb', line 48

def accounts_generate_public_key secret
  params = { :secret => secret }
  public_key = @client.query_post "accounts/generatePublicKey", params
end

#accounts_get_balance(address) ⇒ Object

Request the balance of an account. ‘GET /accounts/getBalance?address=address`



34
35
36
37
# File 'lib/lisk/legacy.rb', line 34

def accounts_get_balance address
  params = { :address => address }
  balance = @client.query_get "accounts/getBalance", params
end

#accounts_get_public_key(address) ⇒ Object

Get the public key of an account. If the account does not exist the API call will return an error. ‘GET /accounts/getPublicKey?address=address`



41
42
43
44
# File 'lib/lisk/legacy.rb', line 41

def accounts_get_public_key address
  params = { :address => address }
  public_key = @client.query_get "accounts/getPublicKey", params
end

#accounts_open(secret) ⇒ Object

Request information about an account. ‘POST /accounts/open`



22
23
24
25
26
27
28
29
30
# File 'lib/lisk/legacy.rb', line 22

def accounts_open secret
  params = { :secret => secret }
   = @client.query_post "accounts/open", params
  if ["success"]
    return ["account"]
  else
    return nil
  end
end

#blocks(filter = nil) ⇒ Object

Gets all blocks by provided filter(s). ‘GET /blocks?generatorPublicKey=generatorPublicKey&height=height&previousBlock=previousBlock&totalAmount=totalAmount&totalFee=totalFee&limit=limit&offset=offset&orderBy=orderBy`



167
168
169
170
171
172
173
174
# File 'lib/lisk/legacy.rb', line 167

def blocks filter = nil
  blocks = @client.query_get "blocks", filter
  if blocks["success"]
    return blocks["blocks"]
  else
    return nil
  end
end

#blocks_get_by_id(id) ⇒ Object

Gets block by provided id. ‘GET /blocks/get?id=id`



178
179
180
181
# File 'lib/lisk/legacy.rb', line 178

def blocks_get_by_id id
  params = { :id => id }
  block = @client.query_get "blocks/get", params
end

#blocks_get_feeObject

Get transaction fee for sending “normal” transactions. ‘GET /blocks/getFee`



185
186
187
# File 'lib/lisk/legacy.rb', line 185

def blocks_get_fee
  fee = @client.query_get "blocks/getFee"
end

#blocks_get_feesObject

Get transaction fee for all types of transactions. ‘GET /blocks/getFees`



191
192
193
# File 'lib/lisk/legacy.rb', line 191

def blocks_get_fees
  fees = @client.query_get "blocks/getFees"
end

#blocks_get_heightObject

Gets the blockchain height of the client. ‘GET /blocks/getHeight`



209
210
211
# File 'lib/lisk/legacy.rb', line 209

def blocks_get_height
  height = @client.query_get "blocks/getHeight"
end

#blocks_get_milestoneObject

Gets the milestone of the blockchain on a client. ‘GET /blocks/getMilestone`



227
228
229
# File 'lib/lisk/legacy.rb', line 227

def blocks_get_milestone
  milestone = @client.query_get "blocks/getMilestone"
end

#blocks_get_nethashObject

Gets the nethash of the blockchain on a client. ‘GET /blocks/getNethash`



221
222
223
# File 'lib/lisk/legacy.rb', line 221

def blocks_get_nethash
  nethash = @client.query_get "blocks/getNethash"
end

#blocks_get_rewardObject

Gets the forging reward for blocks. ‘GET /blocks/getReward`



197
198
199
# File 'lib/lisk/legacy.rb', line 197

def blocks_get_reward
  reward = @client.query_get "blocks/getReward"
end

#blocks_get_statusObject

Gets status of height, fee, milestone, blockreward and supply. ‘GET /blocks/getStatus`



215
216
217
# File 'lib/lisk/legacy.rb', line 215

def blocks_get_status
  status = @client.query_get "blocks/getStatus"
end

#blocks_get_supplyObject

Gets the total amount of Lisk in circulation ‘GET /blocks/getSupply`



203
204
205
# File 'lib/lisk/legacy.rb', line 203

def blocks_get_supply
  supply = @client.query_get "blocks/getSupply"
end

#dapps(filter) ⇒ Object

‘GET /dapps?category=category&name=name&type=type&link=link&limit=limit&offset=offset&orderBy=orderBy`



358
359
360
# File 'lib/lisk/legacy.rb', line 358

def dapps filter
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_categoriesObject

‘GET /dapps/categories`



413
414
415
# File 'lib/lisk/legacy.rb', line 413

def dapps_categories
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_get_by_id(id) ⇒ Object

‘GET /dapps/get?id=id`



363
364
365
# File 'lib/lisk/legacy.rb', line 363

def dapps_get_by_id id
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_installObject

‘POST /dapps/install`



373
374
375
# File 'lib/lisk/legacy.rb', line 373

def dapps_install
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_installedObject

‘GET /dapps/installed`



378
379
380
# File 'lib/lisk/legacy.rb', line 378

def dapps_installed
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_installed_idsObject

‘GET /dapps/installedIds`



383
384
385
# File 'lib/lisk/legacy.rb', line 383

def dapps_installed_ids
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_installingObject

‘GET /dapps/installing`



398
399
400
# File 'lib/lisk/legacy.rb', line 398

def dapps_installing
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_launchObject

‘POST /dapps/launch`



393
394
395
# File 'lib/lisk/legacy.rb', line 393

def dapps_launch
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_launchedObject

‘GET /dapps/launched`



408
409
410
# File 'lib/lisk/legacy.rb', line 408

def dapps_launched
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_putObject

‘PUT /dapps`



353
354
355
# File 'lib/lisk/legacy.rb', line 353

def dapps_put
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_search(query) ⇒ Object

‘GET /dapps/search?q=q&category=category&installed=installed`



368
369
370
# File 'lib/lisk/legacy.rb', line 368

def dapps_search query
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_stopObject

‘POST /dapps/stop`



418
419
420
# File 'lib/lisk/legacy.rb', line 418

def dapps_stop
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_uninstallObject

‘POST /dapps/uninstall`



388
389
390
# File 'lib/lisk/legacy.rb', line 388

def dapps_uninstall
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#dapps_uninstallingObject

‘GET /dapps/uninstalling`



403
404
405
# File 'lib/lisk/legacy.rb', line 403

def dapps_uninstalling
  todo "#{self}::#{__method__} UNIMPLEMENTED"
end

#delegates(filter = nil) ⇒ Object

Gets list of delegates by provided filter. ‘GET /delegates?limit=limit&offset=offset&orderBy=orderBy`



251
252
253
254
255
256
257
258
# File 'lib/lisk/legacy.rb', line 251

def delegates filter = nil
  delegates = @client.query_get "delegates", filter
  if delegates["success"]
    return delegates["delegates"]
  else
    return nil
  end
end

#delegates_countObject

Get total count of registered delegates. ‘GET /delegates/count`



297
298
299
# File 'lib/lisk/legacy.rb', line 297

def delegates_count
  count = @client.query_get "delegates/count"
end

#delegates_forging_disable(secret) ⇒ Object

Disables forging for a delegate on the client node. ‘POST /delegates/forging/disable`



329
330
331
332
# File 'lib/lisk/legacy.rb', line 329

def delegates_forging_disable secret
  params = { :secret => secret }
  count = @client.query_post "delegates/forging/disable", params
end

#delegates_forging_enable(secret) ⇒ Object

Enables forging for a delegate on the client node. ‘POST /delegates/forging/enable`



322
323
324
325
# File 'lib/lisk/legacy.rb', line 322

def delegates_forging_enable secret
  params = { :secret => secret }
  count = @client.query_post "delegates/forging/enable", params
end

#delegates_forging_get_forged_by_account(public_key) ⇒ Object

Get amount of Lisk forged by an account. ‘GET /delegates/forging/getForgedByAccount?generatorPublicKey=generatorPublicKey`



336
337
338
339
# File 'lib/lisk/legacy.rb', line 336

def  public_key
  params = { :generatorPublicKey => public_key }
  forged = @client.query_get "delegates/forging/getForgedByAccount", params
end

#delegates_get_by_key(public_key) ⇒ Object

Gets delegate by public key. ‘GET /delegates/get?publicKey=publicKey`



262
263
264
265
266
267
268
269
270
# File 'lib/lisk/legacy.rb', line 262

def delegates_get_by_key public_key
  params = { :publicKey => public_key }
  delegate = @client.query_get "delegates/get", params
  if delegate["success"]
    return delegate["delegate"]
  else
    return nil
  end
end

#delegates_get_by_name(user_name) ⇒ Object

Gets delegate by username. ‘GET /delegates/get?username=username`



274
275
276
277
278
279
280
281
282
# File 'lib/lisk/legacy.rb', line 274

def delegates_get_by_name user_name
  params = { :username => user_name }
  delegate = @client.query_get "delegates/get", params
  if delegate["success"]
    return delegate["delegate"]
  else
    return nil
  end
end

#delegates_get_next_forgers(limit = 10) ⇒ Object

Get next delegate lining up to forge. ‘GET /delegates/getNextForgers?limit=limit`



343
344
345
346
# File 'lib/lisk/legacy.rb', line 343

def delegates_get_next_forgers limit = 10
  params = { :limit => limit }
  forgers = @client.query_get "delegates/getNextForgers", params
end

#delegates_put(delegate) ⇒ Object

Puts request to create a delegate. ‘PUT /delegates`



245
246
247
# File 'lib/lisk/legacy.rb', line 245

def delegates_put delegate
  delegate = @client.query_put "delegates", delegate
end

#delegates_search(query) ⇒ Object

Search for Delegates by “fuzzy” username. ‘GET /delegates/search?q=username&orderBy=producedblocks:desc`



286
287
288
289
290
291
292
293
# File 'lib/lisk/legacy.rb', line 286

def delegates_search query
  delegates = @client.query_get "delegates/search", query
  if delegates["success"]
    return delegates["delegates"]
  else
    return nil
  end
end

#delegates_voters(public_key) ⇒ Object

Gets voters of delegate. ‘GET /delegates/voters?publicKey=publicKey`



310
311
312
313
314
315
316
317
318
# File 'lib/lisk/legacy.rb', line 310

def delegates_voters public_key
  params = { :publicKey => public_key }
  voters = @client.query_get "delegates/voters", params
  if voters["success"]
    return voters["accounts"]
  else
    return nil
  end
end

#loader_statusObject

Returns the sync status of the blockchain. ‘GET /loader/status/sync`



81
82
83
# File 'lib/lisk/legacy.rb', line 81

def loader_status
  status = @client.query_get "loader/status"
end

#loader_status_pingObject

Get the status of last received block. Returns true if block was received in the past 120 seconds. ‘GET /loader/status/ping`



88
89
90
# File 'lib/lisk/legacy.rb', line 88

def loader_status_ping
  ping = @client.query_get "loader/status/ping"
end

#loader_status_syncObject

Get the synchronization status of the client. ‘GET /loader/status`



75
76
77
# File 'lib/lisk/legacy.rb', line 75

def loader_status_sync
  sync = @client.query_get "loader/status/sync"
end

#multisignatures_accounts(public_key) ⇒ Object

Gets a list of accounts that belong to a multi-signature account. ‘GET /multisignatures/accounts?publicKey=publicKey`



432
433
434
435
# File 'lib/lisk/legacy.rb', line 432

def multisignatures_accounts public_key
  params = { :publicKey => public_key }
  accounts = @client.query_get "multisignatures/accounts", params
end

#multisignatures_pending(public_key) ⇒ Object

Returns a list of multi-signature transactions that waiting for signature by publicKey. ‘GET /multisignatures/pending?publicKey=publicKey`



445
446
447
448
# File 'lib/lisk/legacy.rb', line 445

def multisignatures_pending public_key
  params = { :publicKey => public_key }
  transactions = @client.query_get "multisignatures/pending", params
end

#multisignatures_put(secrets) ⇒ Object

Create a multi-signature account. ‘PUT /multisignatures`



426
427
428
# File 'lib/lisk/legacy.rb', line 426

def multisignatures_put secrets
  transaction = @client.query_put "multisignatures", secrets
end

#multisignatures_sign(signature) ⇒ Object

Signs a transaction that is awaiting signature. ‘POST /multisignatures/sign`



439
440
441
# File 'lib/lisk/legacy.rb', line 439

def multisignatures_sign signature
  transaction = @client.query_post "multisignatures/sign", signature
end

#peers(filter = nil) ⇒ Object

Gets list of peers. ‘GET /peers?state=state&os=os&version=version&limit=limit&offset=offset&orderBy=orderBy`



144
145
146
147
148
149
150
151
# File 'lib/lisk/legacy.rb', line 144

def peers filter = nil
  peers = @client.query_get "peers", filter
  if peers["success"]
    return peers["peers"]
  else
    return nil
  end
end

#peers_get(filter = nil) ⇒ Object

Gets peer by IP address and port. ‘GET /peers/get?ip=ip&port=port`



155
156
157
# File 'lib/lisk/legacy.rb', line 155

def peers_get filter = nil
  peer = @client.query_get "peers/get", filter
end

#peers_versionObject

Gets version and build time. ‘GET /peers/version`



161
162
163
# File 'lib/lisk/legacy.rb', line 161

def peers_version
  version = @client.query_get "peers/version"
end

#signatures_feeObject

Gets the second signature status of an account. ‘GET /signatures/fee`



233
234
235
# File 'lib/lisk/legacy.rb', line 233

def signatures_fee
  fee = @client.query_get "signatures/fee"
end

#signatures_put(secrets) ⇒ Object

Add a second signature to an account. ‘PUT /signatures`



239
240
241
# File 'lib/lisk/legacy.rb', line 239

def signatures_put secrets
  transaction = @client.query_put "signatures", secrets
end

#transactions(filter = nil) ⇒ Object

List of transactions matched by provided parameters. ‘GET /transactions?blockId=blockId&senderId=senderId&recipientId=recipientId&limit=limit&offset=offset&orderBy=field`



94
95
96
97
98
99
100
101
# File 'lib/lisk/legacy.rb', line 94

def transactions filter = nil
  transactions = @client.query_get "transactions", filter
  if transactions["success"]
    return transactions["transactions"]
  else
    return nil
  end
end

#transactions_get_by_id(id) ⇒ Object

Get transaction that matches the provided id. ‘GET /transactions/get?id=id`



111
112
113
114
# File 'lib/lisk/legacy.rb', line 111

def transactions_get_by_id id
  params = { :id => id }
  transaction = @client.query_get "transactions/get", params
end

#transactions_put(transaction) ⇒ Object

Send transaction to broadcast network. ‘PUT /transactions`



105
106
107
# File 'lib/lisk/legacy.rb', line 105

def transactions_put transaction
  transaction = @client.query_put "transactions", transaction
end

#transactions_queuedObject

Gets a list of queued transactions. ‘GET /transactions/queued`



131
132
133
# File 'lib/lisk/legacy.rb', line 131

def transactions_queued
  transaction = @client.query_get "transactions/queued"
end

#transactions_queued_get_by_id(id) ⇒ Object

Get queued transaction that matches the provided id. ‘GET /transactions/queued/get?id=id`



137
138
139
140
# File 'lib/lisk/legacy.rb', line 137

def transactions_queued_get_by_id id
  params = { :id => id }
  transaction = @client.query_get "transactions/queued/get", params
end

#transactions_unconfirmedObject

Gets a list of unconfirmed transactions. ‘GET /transactions/unconfirmed`



125
126
127
# File 'lib/lisk/legacy.rb', line 125

def transactions_unconfirmed
  transaction = @client.query_get "transactions/unconfirmed"
end

#transactions_unconfirmed_get_by_id(id) ⇒ Object

Get unconfirmed transaction that matches the provided id. ‘GET /transactions/unconfirmed/get?id=id`



118
119
120
121
# File 'lib/lisk/legacy.rb', line 118

def transactions_unconfirmed_get_by_id id
  params = { :id => id }
  transaction = @client.query_get "transactions/unconfirmed/get", params
end