RecordsKeeperRubyLib 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/Gemfile.lock +3 -1
- data/README.md +92 -1
- data/config.yaml +8 -0
- data/docs/address_doc.rb +105 -0
- data/docs/asset_doc.rb +54 -0
- data/docs/block_doc.rb +63 -0
- data/docs/blockchain_doc.rb +77 -0
- data/docs/permissions_doc.rb +54 -0
- data/docs/stream_doc.rb +79 -0
- data/docs/transaction_doc.rb +110 -0
- data/docs/wallet_doc.rb +122 -0
- data/lib/RecordsKeeperRubyLib/address.rb +198 -186
- data/lib/RecordsKeeperRubyLib/assets.rb +99 -92
- data/lib/RecordsKeeperRubyLib/block.rb +94 -88
- data/lib/RecordsKeeperRubyLib/blockchain.rb +148 -138
- data/lib/RecordsKeeperRubyLib/config.yaml +8 -0
- data/lib/RecordsKeeperRubyLib/permissions.rb +77 -71
- data/lib/RecordsKeeperRubyLib/stream.rb +220 -164
- data/lib/RecordsKeeperRubyLib/transaction.rb +213 -183
- data/lib/RecordsKeeperRubyLib/version.rb +1 -1
- data/lib/RecordsKeeperRubyLib/wallet.rb +263 -247
- data/lib/config.yaml +8 -0
- metadata +14 -6
- data/lib/RecordsKeeperRubyLib/sample_config.yaml +0 -29
- data/lib/sample_config.yaml +0 -29
- data/sample_config.yaml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 571e0c582fc30457e34d795b4385fe83c1b8eccd
|
4
|
+
data.tar.gz: d8d1f0bd30c6253cd0a70a01b269c81c7fc32849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fab0c3a26255de3d54da08c2db6dc61c5d55932d54381b71f473e56575aac84740629dffb8d37f5c764433b91472cce818b2fa34d8e54dc71d1b6dded6c83eb2
|
7
|
+
data.tar.gz: 7230b6bf6e6d39d300dec2bac8bb714f2e7d57967bd2e24ceb4e74bd530c54c0e1ab9f1ceb109d7c35dbe8e29ee8fd676113a87dee46b957eb656f30a5c89da8
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1 +1,92 @@
|
|
1
|
-
|
1
|
+
RecordsKeeper-Ruby-SDK
|
2
|
+
=========================
|
3
|
+
|
4
|
+
It is an infrastructure to build RecordsKeeper blockchain-based applications, products and is used to work around applications that are built on top of this blockchain platform.
|
5
|
+
|
6
|
+
**Note:** If you're looking for the RecordsKeeper Ruby Library please see: [RecordsKeeper Ruby Library](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk)
|
7
|
+
|
8
|
+
|
9
|
+
## Getting Started
|
10
|
+
|
11
|
+
Before you begin you need to setup Ruby Development Environment.
|
12
|
+
|
13
|
+
|
14
|
+
Import these ruby libraries first to get started with the library classes and functions.
|
15
|
+
|
16
|
+
|
17
|
+
```bash
|
18
|
+
require 'rubygems'
|
19
|
+
require 'httparty'
|
20
|
+
require 'json'
|
21
|
+
require 'binary_parser'
|
22
|
+
require 'yaml'
|
23
|
+
require 'hex_string'
|
24
|
+
```
|
25
|
+
|
26
|
+
|
27
|
+
Creating Connection
|
28
|
+
-------------------
|
29
|
+
|
30
|
+
Entry point for accessing Address class resources.
|
31
|
+
|
32
|
+
Make Config file to import config parameters.
|
33
|
+
|
34
|
+
Import chain url and chain name from config file:
|
35
|
+
|
36
|
+
* URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
37
|
+
* Chain-name: chain name
|
38
|
+
|
39
|
+
```bash
|
40
|
+
|
41
|
+
url = network['url']
|
42
|
+
chain-name = network['chain']
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
Node Authentication
|
47
|
+
-------------------
|
48
|
+
|
49
|
+
Import user name and password values from config file to authenticate the node:
|
50
|
+
|
51
|
+
* User name: The rpc user is used to call the APIs.
|
52
|
+
* Password: The rpc password is used to authenticate the APIs.
|
53
|
+
|
54
|
+
```bash
|
55
|
+
|
56
|
+
user = network['rkuser']
|
57
|
+
password = network['passwd']
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
## Libraries
|
62
|
+
|
63
|
+
- [Address](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/address.rb) Library to work with RecordsKeeper addresses. You can generate new address, check all addresses, check address validity, check address permissions, check address balance by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
64
|
+
|
65
|
+
- [Assets](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/assets.rb) Library to work with RecordsKeeper assets. You can create new assets and list all assets by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
66
|
+
|
67
|
+
- [Block](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/block.rb) Library to work with RecordsKeeper block informaion. You can collect block information by using block class. You just have to pass parameters to invoke the pre-defined functions.
|
68
|
+
|
69
|
+
- [Blockchain](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/blockchain.rb) Library to work with RecordsKeeper block informaion. You can collect block information by using block class. You just have to pass parameters to invoke the pre-defined functions.
|
70
|
+
|
71
|
+
- [Permissions](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/permissions.rb) Library to work with RecordsKeeper permissions. You can grant and revoke permissions like connect, send, receive, create, issue, mine, activate, admin by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
72
|
+
|
73
|
+
- [Stream](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/stream.rb) Library to work with RecordsKeeper streams. You can publish, retrieve and verify stream data by using stream class. You just have to pass parameters to invoke the pre-defined functions.
|
74
|
+
|
75
|
+
- [Transaction](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/transaction.rb) Library to work with RecordsKeeper transactions. You can send transaction, create raw transaction, sign raw transaction, send raw transaction, send signed transaction, retrieve transaction information and calculate transaction's fees by using transaction class. You just have to pass parameters to invoke the pre-defined functions.
|
76
|
+
|
77
|
+
- [Wallet](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/blob/master/lib/RecordsKeeperRubyLib/wallet.rb) Library to work with RecordsKeeper wallet functionalities. You can create wallet, dump wallet into a file, backup wallet into a file, import wallet from a file, lock wallet, unlock wallet, change wallet's password, retrieve private key, retrieve wallet's information, sign and verify message by using wallet class. You just have to pass parameters to invoke the pre-defined functions.
|
78
|
+
|
79
|
+
|
80
|
+
## Unit Tests
|
81
|
+
|
82
|
+
Under recordskeeper_ruby_ spec/test using test data from config.yaml file.
|
83
|
+
- Command to run a all the tests:
|
84
|
+
[rake spec]
|
85
|
+
- Command to a specific test file:
|
86
|
+
[rspec spec/test_name.rb]
|
87
|
+
|
88
|
+
|
89
|
+
## Documentation
|
90
|
+
|
91
|
+
The complete documentation is here: [RecordsKeeper Ruby Library Documentation](https://github.com/RecordsKeeper/recordskeeper-ruby-sdk/tree/master/docs).
|
92
|
+
|
data/config.yaml
ADDED
data/docs/address_doc.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# = Address Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper block information.
|
3
|
+
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Address
|
34
|
+
# Address class is used to call address related functions like generate new address, list all addresses and no of addresses on the node’s wallet, check if given address is valid or not, check if given address has mining permission or not and check a particular address balance on the node functions which are used on the RecordsKeeeper Blockchain.
|
35
|
+
# === 1. getAddress
|
36
|
+
# This function generates a new address on the node wallet.
|
37
|
+
# getAddress
|
38
|
+
# newAddress = getAddress # Function call
|
39
|
+
#
|
40
|
+
# puts newAddress # prints a new address
|
41
|
+
# === 2. getMultisigAddress nrequired, key
|
42
|
+
# This function generates a new multisignature address.
|
43
|
+
#
|
44
|
+
# You have to pass these two arguments to the getMultisigAddress function call:
|
45
|
+
# * nrequired: To pass the no of signatures that are a must to sign a transaction.
|
46
|
+
# * key: To pass any number of comma-separated public addresses that are to be used with this multisig address as a single variable.
|
47
|
+
# getMultisigAddress nrequired, key
|
48
|
+
# newAddress = getMultisigAddress nrequired, key # Function call
|
49
|
+
#
|
50
|
+
# puts newAddress # prints a new address
|
51
|
+
# === 3. getMultisigWalletAddress nrequired, key
|
52
|
+
# This function generates a new multisignature address on the node's wallet.
|
53
|
+
#
|
54
|
+
# You have to pass these two arguments to the getMultisigWalletAddress function call:
|
55
|
+
# * nrequired: This variable is required to pass the number of signatures that are a must to sign a transaction.
|
56
|
+
# * key: This variable is required to pass a string of comma-separated public addresses that are to be used with this multisig address as a single variable.
|
57
|
+
# getMultisigWalletAddress nrequired, key
|
58
|
+
# newAddress = getMultisigWalletAddress nrequired, key # Function call
|
59
|
+
#
|
60
|
+
# puts newAddress #prints a new address
|
61
|
+
# === 4. retrieveAddresses
|
62
|
+
# To list all the addresses and number of addresses on the node's wallet
|
63
|
+
# retrieveAddresses
|
64
|
+
# retrievedinfo = JSON.parse retrieveAddresses # Function call
|
65
|
+
#
|
66
|
+
# puts retrievedinfo['address'] # prints all the addresses of the wallet
|
67
|
+
# puts retrievedinfo['address_count'] # prints the count of addresses in the wallet
|
68
|
+
# === 5. checkifValid address
|
69
|
+
# To check validity of the address
|
70
|
+
#
|
71
|
+
# You have to pass address as argument to the checkifValid function call:
|
72
|
+
# * Address: To check its validity.
|
73
|
+
# checkifValid
|
74
|
+
# addressC = checkifValid address # Function call
|
75
|
+
#
|
76
|
+
# puts addressC # prints validity
|
77
|
+
# === 6. checkifMineAllowed address
|
78
|
+
# To check if given address has mining permission or not
|
79
|
+
#
|
80
|
+
# You have to pass address as argument to the checkifMineAllowed function call:
|
81
|
+
# * Address: To check the permission status
|
82
|
+
# checkifMineAllowed address
|
83
|
+
# permissionCheck = checkifMineAllowed address # Function call
|
84
|
+
#
|
85
|
+
# puts permissionCheck # prints permission status of the given address
|
86
|
+
# === 7. checkBalance address
|
87
|
+
# To check address balance on a particular node
|
88
|
+
#
|
89
|
+
# You have to pass address as argument to the checkifMineAllowed function call:
|
90
|
+
# * Address: To check the balance
|
91
|
+
# checkBalance address
|
92
|
+
# address_balance = checkBalance address # Function call
|
93
|
+
#
|
94
|
+
# puts address_balance # prints balance of the address
|
95
|
+
# === 8. importAddress public_address
|
96
|
+
# To import a non-wallet address on RecordsKeeeper Blockchain
|
97
|
+
#
|
98
|
+
# You have to pass address as argument to the importAddress function call:
|
99
|
+
# * Address: A non-wallet address to import on a particular node
|
100
|
+
# importAddress public_address
|
101
|
+
# response = importAddress public_address # Function call
|
102
|
+
#
|
103
|
+
# puts response # prints response
|
104
|
+
class Address
|
105
|
+
end
|
data/docs/asset_doc.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# = Assets Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper assets.
|
3
|
+
# You can create new assets and list all assets by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Assets
|
34
|
+
# Assets class is used to call assets related functions like create assets and list assets functions which are used on the RecordsKeeeper Blockchain.
|
35
|
+
# === 1. createAsset
|
36
|
+
# This function is used to create or issue an asset.
|
37
|
+
# txid = createAsset address, asset_name, asset_qty # Function call
|
38
|
+
#
|
39
|
+
# puts txid # prints tx id of the issued asset
|
40
|
+
# === 2. retrieveAssets
|
41
|
+
# This function is used to list all assets, no of assets, issued quantity and issued transaction id of all the assets on RecordsKeeper Blockchain.
|
42
|
+
# retrievedinfo = JSON.parse retrieveAssets # Function call
|
43
|
+
#
|
44
|
+
# puts retrievedinfo['asset_name'] # prints all the addresses of the wallet
|
45
|
+
# puts retrievedinfo['asset_count'] # prints the address count
|
46
|
+
# puts retrievedinfo['issue_qty'] # prints assets issued quantity
|
47
|
+
# puts retrievedinfo['issue_id'] # prints assets issued transaction id
|
48
|
+
# === 3. sendAsset
|
49
|
+
# This function is used to send an asset.
|
50
|
+
# txid = sendAsset address, asset_name, asset_qty # Function call
|
51
|
+
#
|
52
|
+
# puts txid # prints tx id of the sent asset
|
53
|
+
class Assets
|
54
|
+
end
|
data/docs/block_doc.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# = Block Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper block information.
|
3
|
+
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Block
|
34
|
+
# Block class is used to call block related functions like blockinfo which is used to retrieve block details
|
35
|
+
# like block's hash value, size, nonce, transaction ids, transaction count, miner address, previous block hash,
|
36
|
+
# next block hash, merkleroot, blocktime and difficulty of the block for which you have made the query.
|
37
|
+
# === 1. blockinfo block_height
|
38
|
+
# * You have to pass the block height as an argument in the blockinfo function call (Block height: Height of the block of which you want to collect information.)
|
39
|
+
# * It will return transaction ids, transaction count, nonce, size, hash value, previous block's hash value, next block hash value, merkle root, difficulty, blocktime and miner address of the block.
|
40
|
+
# information = JSON.parse blockinfo block_height # Function call
|
41
|
+
#
|
42
|
+
# puts information['tx_count'] # prints transaction count of the block
|
43
|
+
# puts information['tx'] # prints transaction ids of the block
|
44
|
+
# puts information['size'] # prints size of the block
|
45
|
+
# puts information['blockHash'] # prints hash value of the block
|
46
|
+
# puts information['nonce'] # prints nonce of the block
|
47
|
+
# puts information['miner'] # prints miner's address of the block
|
48
|
+
# puts information['nextblock'] # prints next block's hash
|
49
|
+
# puts information['prevblock'] # prints previous block's hash
|
50
|
+
# puts information['merkleroot'] # prints merkle root of the block
|
51
|
+
# puts information['blocktime'] # prints time at which block is mined
|
52
|
+
# puts information['difficulty'] # prints difficulty of the block
|
53
|
+
# === 2. retrieveBlocks block_range
|
54
|
+
# * You have to pass the block's height as the argument to the retrieveBlocks function call (Block range: Range of the block of which you want to collect information)
|
55
|
+
# * It will return blockhash, miner address, blocktime and transaction count of the blocks.
|
56
|
+
# information = JSON.parse retrieveBlocks block_range # Function call
|
57
|
+
#
|
58
|
+
# puts information['block_hash'] # prints hash of the blocks
|
59
|
+
# puts information['miner_add'] # prints miner of the blocks
|
60
|
+
# puts information['block_time'] # prints block time of the blocks
|
61
|
+
# puts information['txcount'] # prints transaction count of the blocks
|
62
|
+
class Block
|
63
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# = Blockchain Class Usage
|
2
|
+
# This is a library to work with Blockchains in RecordsKeeper.
|
3
|
+
# You can retrieve information about the chain and node, list all the permissions and the pending transactions and check your node's balance.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Blockchain
|
34
|
+
# Blockchain class is used to call blockchain related functions to retrieve information about the chain and node, list all the permissions and the pending transactions and check your node's balance.
|
35
|
+
# === 1. getChainInfo
|
36
|
+
# This function retrieves information about the chain.
|
37
|
+
# getChainInfo
|
38
|
+
# chainInfo = JSON.parse getChainInfo # Function call
|
39
|
+
#
|
40
|
+
# puts chainInfo['chain_protocol'] # prints chain-protocol
|
41
|
+
# puts chainInfo['chain_description'] # prints chain-description
|
42
|
+
# puts chainInfo['root_stream'] # prints root-stream-name
|
43
|
+
# puts chainInfo['max_blocksize'] # prints maximum-block-size
|
44
|
+
# puts chainInfo['default_networkport'] # prints default-network-port
|
45
|
+
# puts chainInfo['default_rpcport'] # prints default-rpc-port
|
46
|
+
# puts chainInfo['mining_diversity'] # prints mining-diversity
|
47
|
+
# puts chainInfo['chain_name'] # prints chain-name
|
48
|
+
# === 2. getNodeInfo
|
49
|
+
# This function retrieves information related to your node.
|
50
|
+
# getNodeInfo
|
51
|
+
# nodeInfo = JSON.parse getNodeInfo # Function call
|
52
|
+
#
|
53
|
+
# puts nodeInfo['node_balance'] # prints balance
|
54
|
+
# puts nodeInfo['synced_blocks'] # prints synced-blocks
|
55
|
+
# puts nodeInfo['node_address'] # prints nodeaddress
|
56
|
+
# puts nodeInfo['difficulty'] # prints difficulty
|
57
|
+
# === 3. permissions
|
58
|
+
# This function lists all the permissions.
|
59
|
+
# permissions
|
60
|
+
# listpermissions = permissions # Function call
|
61
|
+
#
|
62
|
+
# puts listpermissions # Prints the list of permissions.
|
63
|
+
# === 4. getpendingTransactions
|
64
|
+
# This function retrieves information related to your node.
|
65
|
+
# getpendingTransactions
|
66
|
+
# pentransac = JSON.parse getpendingTransactions # Function call
|
67
|
+
#
|
68
|
+
# puts pentransac['tx_count'] # prints transaction count
|
69
|
+
# puts pentransac['tx'] # prints the pending transactions
|
70
|
+
# === 5. checkNodeBalance
|
71
|
+
# This function retrieves information related to your node.
|
72
|
+
# checkNodeBalance
|
73
|
+
# nodeBal = checkNodeBalance # Function call
|
74
|
+
#
|
75
|
+
# puts nodeBal # Prints node's balance amount.
|
76
|
+
class Blockchain
|
77
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# = Permissions Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper permissions.
|
3
|
+
# You can grant and revoke permissions like connect, send, receive, create, issue, mine, activate, admin by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Permissions
|
34
|
+
# Permissions class is used to call permissions related functions like grant and revoke permissions for an address functions which are used on the RecordsKeeeper Blockchain.
|
35
|
+
# === 1. grantPermission address, permissions
|
36
|
+
# This function is used to grant permissions like connect, send, receive, create, issue, mine, activate, admin to an address on RecordsKeeper Blockchain.
|
37
|
+
#
|
38
|
+
# You have to pass these two arguments to the grantPermission function call:
|
39
|
+
# * Permissions: list of comma-seperated permissions passed as a string
|
40
|
+
# * Address: to which you have to grant permission
|
41
|
+
# result = grantPermission address, permissions
|
42
|
+
#
|
43
|
+
# puts txid # prints response of the grant permision transaction
|
44
|
+
# === 2. revokePermission address, permissions
|
45
|
+
# This function is used to revoke permissions like connect, send, receive, create, issue, mine, activate, admin to an address on RecordsKeeper Blockchain.
|
46
|
+
#
|
47
|
+
# You have to pass these two arguments to the grantPermission function call:
|
48
|
+
# * Permissions: list of comma-seperated permissions passed as a string
|
49
|
+
# * Address: to which you have to grant permission
|
50
|
+
# result = revokePermission address, permissions
|
51
|
+
#
|
52
|
+
# puts result # prints response of the revoke permision transaction
|
53
|
+
class Permissions
|
54
|
+
end
|