RecordsKeeperRubyLib 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/docs/stream_doc.rb DELETED
@@ -1,79 +0,0 @@
1
- # = Stream Class Usage
2
- # This is a library to work with streams in RecordsKeeper Blockchain.
3
- # You can publish address, retrieve data, retrieve with address, retrieve with key, verify data and retrieve items.
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 Stream
34
- # Stream class is used to call stream related functions to publish address, retrieve data, retrieve with address, retrieve with key, verify data and retrieve items.
35
- # === 1. publish address, stream, key, data
36
- # This function retrieves information about the chain.
37
- # publish address, stream, key, data
38
- # transacid = publish address, stream, key, data # Function call
39
- #
40
- # puts transacid # Prints txid.
41
- # === 2. retrieve stream, txid
42
- # This function retrieves information related to your node.
43
- # retrieve stream, txid
44
- # data = retrieve stream, txid # Function call
45
- #
46
- # puts data # Prints raw_data.
47
- # === 3. retrieveWithAddress stream, address
48
- # This function lists all the permissions.
49
- # retrieveWithAddress stream, address
50
- # retadd = JSON.parse retrieveWithAddress stream, address # Function call
51
- #
52
- # puts retadd['key'] # Prints key, data and txid.
53
- # puts retadd['raw_data'] # prints raw data
54
- # puts retadd['txid'] # prints transaction id
55
- # === 4. retrieveWithKey stream, key
56
- # This function retrieves information related to your node.
57
- # retrieveWithKey stream, key
58
- # retkey = JSON.parse retrieveWithKey stream, key # Function call
59
- #
60
- # puts retkey['publisher'] # prints publisher
61
- # puts retkey['raw_data'] # prints raw data
62
- # puts retkey['txid'] # prints transaction id
63
- # === 5. verifyData stream, data, count
64
- # This function retrieves information related to your node.
65
- # verifyData stream, data, count
66
- # verifystat = verifyData stream, data, count # Function call
67
- #
68
- # puts verifystat # Prints result.
69
- # === 6. retrieveItems stream, count
70
- # This function retrieves information related to your node.
71
- # retrieveItems stream, count
72
- # retitem = JSON.parse retrieveItems stream, count # Function call
73
- #
74
- # puts retitem['address'] # prints address
75
- # puts retitem['key_value'] # prints key_value
76
- # puts retitem['raw_data'] # prints raw_data
77
- # puts retitem['txid'] # prints transaction id
78
- class Stream
79
- end
@@ -1,110 +0,0 @@
1
- # = Transaction Class Usage
2
- # This is a library to work with RecordsKeeper transactions.
3
- # 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.
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
- # require 'hex_string'
13
- # -----------------
14
- # == Create Connection
15
- # Entry point for accessing Address class resources.
16
- # * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
17
- # * Chain-name: chain name
18
- # cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
19
- # * Set a *network* value.
20
- # network = cfg['network'] # Network variable to store the network that you want to access
21
- # * Set url and chain name:
22
- # @url = cfg['network']['url']
23
- # @chain = cfg['network']['chain']
24
- # -------------------
25
- # == Node Authentication
26
- # Import values from config file.
27
- # * User name: The rpc user is used to call the APIs.
28
- # * Password: The rpc password is used to authenticate the APIs.
29
- # * Set the rpc username and password:
30
- # @user = cfg['network']['rkuser']
31
- # @password = cfg['network']['passwd']
32
- # Now we have node authentication credentials.
33
- # ------------
34
- # = class Transaction
35
- # Transaction class is used to call transaction related functions like create raw transaction, sign transaction, send transaction , retrieve transaction and verify transaction functions which are used to create raw transactions, send transactions, sign transactions, retrieve transactions and verify transactions on the RecordsKeeeper Blockchain.
36
- # === 1. sendTransaction sender_address, reciever_address, amount
37
- # This function is used to send transaction by passing reciever’s address, sender’s address and amount.
38
- #
39
- # You have to pass these three arguments to the sendTransaction function call:
40
- # * Transaction’s sender address
41
- # * Transaction’s reciever address
42
- # * Amount to be sent in transaction
43
- #
44
- # txid = sendTransaction sender_address, reciever_address, amount # Function call
45
- #
46
- # puts txid # prints transaction id of the sent transaction
47
- # === 2. sendSignedTransaction
48
- # This function is used to send transaction by passing reciever’s address, sender’s address, private key of sender and amount. In this function private key is required to sign transaction.
49
- #
50
- # You have to pass these four arguments to the sendSignedTransaction function call:
51
- # * Transaction’s sender address
52
- # * Transaction’s reciever address
53
- # * Amount to be sent in transaction
54
- # * Private key of the sender’s address
55
- #
56
- # transaction_id = sendSignedTransaction # Function call
57
- #
58
- # puts transaction_id # prints transaction id of the signed transaction
59
- # === 3. createRawTransaction sender_address, reciever_address, amount
60
- # This function is used to create raw transaction by passing reciever’s address, sender’s address and amount.
61
- #
62
- # You have to pass these three arguments to the sendTransaction function call:
63
- # * Transaction’s sender address
64
- # * Transaction’s reciever address
65
- # * Amount to be sent in transaction
66
- #
67
- # tx_hex = createRawTransaction sender_address, reciever_address, amount # Function call
68
- #
69
- # puts tx_hex # prints transaction hex of the raw transaction
70
- # === 4. signRawTransaction tx_hex, private_key
71
- # This function retrieves is used to sign raw transaction by passing transaction hex of the raw transaction and the private key to sign the raw transaction.
72
- #
73
- # You have to pass these three arguments to the signRawTransaction function call:
74
- # * Transaction hex of the raw transaction
75
- # * Private key to sign raw transaction
76
- #
77
- # signed_hex = signRawTransaction txHex, private_key # Function call
78
- #
79
- # puts signed_hex # prints signed transaction hex of the raw transaction
80
- # === 5. sendRawTransaction signed_txHex
81
- # This function is used to send raw transaction by passing signed transaction hex of the raw transaction.
82
- #
83
- # You have to pass the signed transaction hex of the raw transaction.
84
- #
85
- # tx_id = sendRawTransaction signed_txHex # Function call
86
- #
87
- # puts tx_id # prints transaction id of the raw transaction
88
- # === 6. retrieveTransaction tx_id
89
- # This function is used to retrieve transaction’s information by passing transaction id to the function.
90
- #
91
- # You have to pass the transaction id of the transaction you want to retrieve.
92
- #
93
- # retrievedinfo = JSON.parse retrieveTransaction tx_id # Function call
94
- #
95
- # puts retrievedinfo['sent_data'] #prints sent data
96
- # puts retrievedinfo['sent_amount'] #prints sent amount
97
- # puts retrievedinfo['reciever_address'] #prints reciever's address
98
- # === 7. getFee address, tx_id
99
- # This function is used to calculate transaction’s fee by passing transaction id and sender’s address to the function.
100
- #
101
- # You have to pass these two arguments to the getFee function call:
102
- # * Transaction id of the transaction you want to calculate fee for
103
- # * Sender’s address
104
- #
105
- # fees = getFee address, tx_id # Function call
106
- #
107
- # puts fees #prints fees consumed in the verified transaction
108
-
109
- class Transaction
110
- end
data/docs/wallet_doc.rb DELETED
@@ -1,122 +0,0 @@
1
- # = Wallet Class Usage
2
- # Library to work with RecordsKeeper wallet functionalities.
3
- # 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.
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
- # require 'hex_string'
13
- # -----------------
14
- # == Create Connection
15
- # Entry point for accessing Address class resources.
16
- # * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
17
- # * Chain-name: chain name
18
- # cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
19
- # * Set a *network* value.
20
- # network = cfg['network'] # Network variable to store the network that you want to access
21
- # * Set url and chain name:
22
- # @url = cfg['network']['url']
23
- # @chain = cfg['network']['chain']
24
- # -------------------
25
- # == Node Authentication
26
- # Import values from config file.
27
- # * User name: The rpc user is used to call the APIs.
28
- # * Password: The rpc password is used to authenticate the APIs.
29
- # * Set the rpc username and password:
30
- # @user = cfg['network']['rkuser']
31
- # @password = cfg['network']['passwd']
32
- # Now we have node authentication credentials.
33
- # ------------
34
- # = class Wallet
35
- # Wallet class is used to call wallet related functions like create wallet, retrieve private key of wallet address, retrieve wallet’s information, dump wallet, lock wallet, unlock wallet, change wallet’s password, create wallet’s backup, import wallet’s backup, sign message and verify message functions on RecordsKeeeper Blockchain.
36
- # === 1. createWallet
37
- # This function is used to create wallet on RecordsKeeper blockchain
38
- # newwallet = JSON.parse createWallet
39
- #
40
- # puts newwallet['publicaddress'] # prints public address of the wallet
41
- # puts newwallet['privatekey'] # prints private key of the wallet
42
- # puts newwallet['publickey'] # prints public key of the wallet
43
- # === 2. getPrivateKey
44
- # This function is used to retrieve private key of the given address.
45
- # privkey = getPrivateKey
46
- #
47
- # puts privkey # prints private key of the given address
48
- # === 3. retrieveWalletinfo
49
- # This function is used to retrieve node wallet’s information.
50
- # walletinfo = JSON.parse retrieveWalletinfo
51
- #
52
- # puts walletinfo['balance'] # prints wallet's balance
53
- # puts walletinfo['tx_count'] # prints wallet transaction count
54
- # puts walletinfo['unspent_tx'] # prints unspent wallet transactions
55
- # === 4. backupWallet filename
56
- # This function is used to create backup of the wallet.dat file.
57
- #
58
- # You have to pass filename; wallet’s backup file name
59
- # result = backupWallet filename
60
- #
61
- # puts result # prints result
62
- # It will return the response of the backup wallet function. The backup of the wallet is created in your chain’s directory and you can simply access your file by using same filename that you have passed with the backupwallet function. Creates a backup of the wallet.dat file in which the node’s private keys and watch-only addresses are stored. The backup is created in file filename. Use with caution – any node with access to this file can perform any action restricted to this node’s addresses.
63
- # === 5. importWallet filename
64
- # This function is used to import wallet’s backup file.
65
- #
66
- # You have to pass the filename; wallet’s backup file name.
67
- # result = importWallet filename
68
- #
69
- # puts result # prints result
70
- # It will return the response of the import wallet function. It will import the entire set of private keys which were dumped (using dumpwallet) into file filename.
71
- # === 6. dumpWallet filename
72
- # This function is used to retrieve transaction’s information by passing transaction id to the function.
73
- #
74
- # You have to pass the filename; file name to dump wallet in.
75
- # result = dumpWallet filename
76
- #
77
- # puts result # prints result
78
- # === 7. lockWallet password
79
- # This function is used to verify transaction’s information by passing transaction id and sender’s address to the function.
80
- #
81
- # You have to pass password; password to lock the wallet.
82
- # result = lockWallet password
83
- #
84
- # puts result # prints result
85
- # === 8. unlockWallet password, unlock_time
86
- # This function is used to verify transaction’s information by passing transaction id and sender’s address to the function.
87
- #
88
- # You have to pass these two arguments to the unlockWallet function call:
89
- # * Password: password to unlock the wallet
90
- # * unlocktime: seconds for which wallet remains unlock
91
- # result = unlockWallet password, unlock_time
92
- #
93
- # puts result # prints result
94
- # === 9. changeWalletPassword old_password, new_password
95
- # This function is used to change wallet’s password and set new password.
96
- #
97
- # You have to pass these two arguments to the changeWalletPassword function call:
98
- # * Old Password: old password of the wallet
99
- # * New Password: new password of the wallet
100
- # result = changeWalletPassword password, new_password
101
- #
102
- # puts result # prints result
103
- # === 10. signMessage private_key, message
104
- # This function is used to change wallet’s password and set new password.
105
- #
106
- # You have to pass these two arguments to the signMessage function call:
107
- # * Message: message to send
108
- # * Private Key: private key of the sender’s wallet address
109
- # signedMessage = signMessage private_key, message
110
- #
111
- # puts signedMessage # prints signed message
112
- # === 11. verifyMessage address, signedMessage, message
113
- # This function is used to change wallet’s password and set new password.
114
- #
115
- # You have to pass these three arguments to the verifyMessage function call:
116
- # * Message: message to send
117
- # * Private Key: private key of the sender’s wallet address
118
- # validity = verifyMessage address, signedMessage, message
119
- #
120
- # puts validity # prints validity of the message
121
- class Wallet
122
- end
@@ -1,8 +0,0 @@
1
- # config.yaml
2
-
3
- url: testurl
4
- rkuser: rkuser
5
- passwd: rkpwd
6
- chain: test-chain
7
- port: testport
8
-
data/lib/config.yaml DELETED
@@ -1,8 +0,0 @@
1
- # config.yaml
2
-
3
- url: testurl
4
- rkuser: rkuser
5
- passwd: rkpwd
6
- chain: test-chain
7
- port: testport
8
-