RecordsKeeperRubyLib 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +114 -0
- data/LICENSE.txt +8 -0
- data/README.md +1 -0
- data/Rakefile +6 -0
- data/RecordsKeeperRuby.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/addressdoc.rb +116 -0
- data/docs/assetsdoc.rb +65 -0
- data/docs/blockchaindoc.rb +77 -0
- data/docs/blockdoc.rb +76 -0
- data/docs/permissionsdoc.rb +65 -0
- data/docs/streamdoc.rb +84 -0
- data/docs/transactiondoc.rb +121 -0
- data/docs/walletdoc.rb +133 -0
- data/lib/RecordsKeeperRuby/address.rb +186 -0
- data/lib/RecordsKeeperRuby/assets.rb +87 -0
- data/lib/RecordsKeeperRuby/block.rb +89 -0
- data/lib/RecordsKeeperRuby/blockchain.rb +135 -0
- data/lib/RecordsKeeperRuby/permissions.rb +77 -0
- data/lib/RecordsKeeperRuby/sample_config.yaml +60 -0
- data/lib/RecordsKeeperRuby/stream.rb +169 -0
- data/lib/RecordsKeeperRuby/transaction.rb +182 -0
- data/lib/RecordsKeeperRuby/version.rb +3 -0
- data/lib/RecordsKeeperRuby/wallet.rb +252 -0
- data/lib/RecordsKeeperRuby.rb +9 -0
- data/lib/sample_config.yaml +60 -0
- data/sample_config.yaml +60 -0
- metadata +203 -0
@@ -0,0 +1,182 @@
|
|
1
|
+
# Library to work with RecordsKeeper transactions.
|
2
|
+
|
3
|
+
# You can send transaction, create raw transaction, sign raw transaction, send raw transaction, send signed transaction,
|
4
|
+
# retrieve transaction information and calculate transaction's fees by using transaction class. You just have to pass
|
5
|
+
# parameters to invoke the pre-defined functions.
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'httparty'
|
9
|
+
require 'json'
|
10
|
+
require 'binary_parser'
|
11
|
+
require 'yaml'
|
12
|
+
require 'hex_string'
|
13
|
+
|
14
|
+
module RecordsKeeperRuby
|
15
|
+
|
16
|
+
class Transaction
|
17
|
+
|
18
|
+
# Entry point for accessing Block class resources.
|
19
|
+
# Import values from config file.
|
20
|
+
cfg = YAML::load(File.open('config.yaml','r'))
|
21
|
+
@network = cfg['testnet'] # Network variable to store the networrk that you want to access
|
22
|
+
if @network==cfg['testnet']
|
23
|
+
@url = cfg['testnet']['url']
|
24
|
+
@user = cfg['testnet']['rkuser']
|
25
|
+
@password = cfg['testnet']['passwd']
|
26
|
+
@chain = cfg['testnet']['chain']
|
27
|
+
else
|
28
|
+
@url = cfg['mainnet']['url']
|
29
|
+
@user = cfg['mainnet']['rkuser']
|
30
|
+
@password = cfg['mainnet']['passwd']
|
31
|
+
@chain = cfg['mainnet']['chain']
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.variable
|
35
|
+
net = @network
|
36
|
+
return net
|
37
|
+
end
|
38
|
+
|
39
|
+
# Function to send transaction on RecordsKeeper Blockchain
|
40
|
+
def self.sendTransaction sender_address, receiveraddress, data, amount
|
41
|
+
data_hex = data.to_hex_string
|
42
|
+
datahex = data_hex.delete(' ')
|
43
|
+
auth = {:username => @user, :password => @password}
|
44
|
+
options = {
|
45
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
46
|
+
:basic_auth => auth,
|
47
|
+
:body => [ {"method":"createrawsendfrom","params":[sender_address, { receiveraddress => amount }, [datahex], "send"],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
48
|
+
}
|
49
|
+
response = HTTParty.get(@url, options)
|
50
|
+
out = response.parsed_response
|
51
|
+
txid = out[0]['result']
|
52
|
+
return txid;
|
53
|
+
end
|
54
|
+
|
55
|
+
# Function to create transaction hex on RecordsKeeper Blockchain
|
56
|
+
def self.createRawTransaction sender_address, receiveraddress, amount, data
|
57
|
+
data_hex = data.to_hex_string
|
58
|
+
datahex = data_hex.delete(' ')
|
59
|
+
auth = {:username => @user, :password => @password}
|
60
|
+
options = {
|
61
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
62
|
+
:basic_auth => auth,
|
63
|
+
:body => [ {"method":"createrawsendfrom","params":[sender_address, {receiveraddress => amount}, [datahex], ''],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
64
|
+
}
|
65
|
+
response = HTTParty.get(@url, options)
|
66
|
+
out = response.parsed_response
|
67
|
+
txhex = out[0]['result']
|
68
|
+
return txhex;
|
69
|
+
end
|
70
|
+
|
71
|
+
# Function to sign transaction on RecordsKeeper Blockchain
|
72
|
+
def self.signRawTransaction txHex, private_key
|
73
|
+
priv_key = []
|
74
|
+
priv_key.push(private_key)
|
75
|
+
auth = {:username => @user, :password => @password}
|
76
|
+
options = {
|
77
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
78
|
+
:basic_auth => auth,
|
79
|
+
:body => [ {"method":"signrawtransaction","params":[txHex, [], priv_key],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
80
|
+
}
|
81
|
+
response = HTTParty.get(@url, options)
|
82
|
+
out = response.parsed_response
|
83
|
+
signedHex = out[0]['result']['hex']
|
84
|
+
return signedHex;
|
85
|
+
end
|
86
|
+
|
87
|
+
# Function to send raw transaction on RecordsKeeper Blockchain
|
88
|
+
def self.sendRawTransaction signed_txHex
|
89
|
+
auth = {:username => @user, :password => @password}
|
90
|
+
options = {
|
91
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
92
|
+
:basic_auth => auth,
|
93
|
+
:body => [ {"method":"sendrawtransaction","params":[signed_txHex],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
94
|
+
}
|
95
|
+
response = HTTParty.get(@url, options)
|
96
|
+
out = response.parsed_response
|
97
|
+
txn = out[0]['result']
|
98
|
+
if txn.nil?
|
99
|
+
txid = out[0]['error']['message']
|
100
|
+
else
|
101
|
+
txid = txn
|
102
|
+
end
|
103
|
+
return txid;
|
104
|
+
end
|
105
|
+
|
106
|
+
# Function to send signed transaction on RecordsKeeper Blockchain
|
107
|
+
def self.sendSignedTransaction sender_address, receiveraddress, amount, private_key, data
|
108
|
+
data_hex = data.to_hex_string
|
109
|
+
datahex = data_hex.delete(' ')
|
110
|
+
def self.createRawTransaction sender_address, receiveraddress, amount, datahex
|
111
|
+
auth = {:username => @user, :password => @password}
|
112
|
+
options = {
|
113
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
114
|
+
:basic_auth => auth,
|
115
|
+
:body => [ {"method":"createrawsendfrom","params":[sender_address, {receiveraddress => amount}, [datahex], ""],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
116
|
+
}
|
117
|
+
response = HTTParty.get(@url, options)
|
118
|
+
out = response.parsed_response
|
119
|
+
return out[0]['result']
|
120
|
+
end
|
121
|
+
txHex = createRawTransaction sender_address, receiveraddress, Float(amount), datahex
|
122
|
+
def self.signRawTransaction txHex, private_key
|
123
|
+
auth = {:username => @user, :password => @password}
|
124
|
+
options = {
|
125
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
126
|
+
:basic_auth => auth,
|
127
|
+
:body => [ {"method":"signrawtransaction","params":[txHex, [], [private_key]],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
128
|
+
}
|
129
|
+
response = HTTParty.get(@url, options)
|
130
|
+
out = response.parsed_response
|
131
|
+
return out[0]['result']['hex']
|
132
|
+
end
|
133
|
+
signed_tx_hex = signRawTransaction txHex, private_key
|
134
|
+
def self.sendRawTransaction signed_tx_hex
|
135
|
+
auth = {:username => @user, :password => @password}
|
136
|
+
options = {
|
137
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
138
|
+
:basic_auth => auth,
|
139
|
+
:body => [ {"method":"sendrawtransaction","params":[signed_tx_hex],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
140
|
+
}
|
141
|
+
response = HTTParty.get(@url, options)
|
142
|
+
out = response.parsed_response
|
143
|
+
return out[0]['result']
|
144
|
+
end
|
145
|
+
tx_id = sendRawTransaction signed_tx_hex
|
146
|
+
return tx_id;
|
147
|
+
end
|
148
|
+
|
149
|
+
# Function to retrieve transaction on RecordsKeeper Blockchain
|
150
|
+
def self.retrieveTransaction tx_id
|
151
|
+
auth = {:username => @user, :password => @password}
|
152
|
+
options = {
|
153
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
154
|
+
:basic_auth => auth,
|
155
|
+
:body => [ {"method":"getrawtransaction","params":[tx_id, 1],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
156
|
+
}
|
157
|
+
response = HTTParty.get(@url, options)
|
158
|
+
out = response.parsed_response
|
159
|
+
sent_hex_data = out[0]['result']['data'][0]
|
160
|
+
sent_data = sent_hex_data.to_byte_string
|
161
|
+
sent_amount = out[0]['result']['vout'][0]['value']
|
162
|
+
return sent_data, sent_amount; #returns data from retrieved transaction
|
163
|
+
end
|
164
|
+
|
165
|
+
# Function to calculate transaction's fee on RecordsKeeper Blockchain
|
166
|
+
def self.getFee address, tx_id
|
167
|
+
auth = {:username => @user, :password => @password}
|
168
|
+
options = {
|
169
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
170
|
+
:basic_auth => auth,
|
171
|
+
:body => [ {"method":"getaddresstransaction","params":[address, tx_id, true],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
172
|
+
}
|
173
|
+
response = HTTParty.get(@url, options)
|
174
|
+
out = response.parsed_response
|
175
|
+
sent_amount = out[0]['result']['vout'][0]['amount']
|
176
|
+
balance_amount = out[0]['result']['balance']['amount']
|
177
|
+
fees = balance_amount.abs - sent_amount
|
178
|
+
return fees; #returns fees
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
@@ -0,0 +1,252 @@
|
|
1
|
+
# Library to work with RecordsKeeper wallet.
|
2
|
+
|
3
|
+
# You can create wallet, create multisignature wallet, retrieve wallet's information, retrieve private key of a particular
|
4
|
+
# wallet address, sign message verify message, dump wallet file, backup wallet file, import wallet file, encrypt wallet by
|
5
|
+
# using wallet class. You just have to pass parameters to invoke the pre-defined functions.
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'httparty'
|
9
|
+
require 'json'
|
10
|
+
require 'binary_parser'
|
11
|
+
require 'yaml'
|
12
|
+
require 'hex_string'
|
13
|
+
|
14
|
+
module RecordsKeeperRuby
|
15
|
+
class Wallet
|
16
|
+
|
17
|
+
# Entry point for accessing Block class resources.
|
18
|
+
# Import values from config file.
|
19
|
+
cfg = YAML::load(File.open('config.yaml','r'))
|
20
|
+
@network = cfg['testnet'] # Network variable to store the networrk that you want to access
|
21
|
+
if @network==cfg['testnet']
|
22
|
+
@url = cfg['testnet']['url']
|
23
|
+
@user = cfg['testnet']['rkuser']
|
24
|
+
@password = cfg['testnet']['passwd']
|
25
|
+
@chain = cfg['testnet']['chain']
|
26
|
+
else
|
27
|
+
@url = cfg['mainnet']['url']
|
28
|
+
@user = cfg['mainnet']['rkuser']
|
29
|
+
@password = cfg['mainnet']['passwd']
|
30
|
+
@chain = cfg['mainnet']['chain']
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.variable
|
34
|
+
net = @network
|
35
|
+
return net
|
36
|
+
end
|
37
|
+
|
38
|
+
# Function to create wallet on RecordsKeeper Blockchain
|
39
|
+
def self.createWallet
|
40
|
+
auth = {:username => @user, :password => @password}
|
41
|
+
options = {
|
42
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
43
|
+
:basic_auth => auth,
|
44
|
+
:body => [ {"method":"createkeypairs","params":[],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
45
|
+
}
|
46
|
+
response = HTTParty.get(@url, options)
|
47
|
+
out = response.parsed_response
|
48
|
+
public_address = out[0]['result'][0]['address'] # returns public address of the wallet
|
49
|
+
private_key = out[0]['result'][0]['privkey'] # returns private key of the wallet
|
50
|
+
public_key = out[0]['result'][0]['pubkey'] # returns public key of the wallet
|
51
|
+
|
52
|
+
def self.importAddress public_address
|
53
|
+
auth = {:username => @user, :password => @password}
|
54
|
+
options = {
|
55
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
56
|
+
:basic_auth => auth,
|
57
|
+
:body => [ {"method":"importaddress","params":[public_address, " ", false],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
58
|
+
}
|
59
|
+
response = HTTParty.get(@url, options)
|
60
|
+
out = response.parsed_response
|
61
|
+
result = out[0]['result']
|
62
|
+
return result;
|
63
|
+
end
|
64
|
+
import_address = importAddress public_address
|
65
|
+
|
66
|
+
return public_address, private_key, public_key; #returns public and private key
|
67
|
+
end
|
68
|
+
|
69
|
+
# Function to retrieve private key of a wallet on RecordsKeeper Blockchain
|
70
|
+
def self.getPrivateKey public_address
|
71
|
+
auth = {:username => @user, :password => @password}
|
72
|
+
options = {
|
73
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
74
|
+
:basic_auth => auth,
|
75
|
+
:body => [ {"method":"dumpprivkey","params":[public_address],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
76
|
+
}
|
77
|
+
response = HTTParty.get(@url, options)
|
78
|
+
out = response.parsed_response
|
79
|
+
result = out[0]['result']
|
80
|
+
if result.nil?
|
81
|
+
private_key = out[0]['error']['message']
|
82
|
+
else
|
83
|
+
private_key = out[0]['result']
|
84
|
+
end
|
85
|
+
return private_key; #returns private key
|
86
|
+
end
|
87
|
+
|
88
|
+
# Function to retrieve wallet's information on RecordsKeeper Blockchain
|
89
|
+
def self.retrieveWalletinfo
|
90
|
+
auth = {:username => @user, :password => @password}
|
91
|
+
options = {
|
92
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
93
|
+
:basic_auth => auth,
|
94
|
+
:body => [ {"method":"getwalletinfo","params":[],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
95
|
+
}
|
96
|
+
response = HTTParty.get(@url, options)
|
97
|
+
out = response.parsed_response
|
98
|
+
balance = out[0]['result']['balance']
|
99
|
+
tx_count = out[0]['result']['txcount']
|
100
|
+
unspent_tx = out[0]['result']['utxocount']
|
101
|
+
return balance, tx_count, unspent_tx; #returns balance, tx count, unspent tx
|
102
|
+
end
|
103
|
+
|
104
|
+
# Function to create wallet's backup on RecordsKeeper Blockchain
|
105
|
+
def self.backupWallet filename
|
106
|
+
auth = {:username => @user, :password => @password}
|
107
|
+
options = {
|
108
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
109
|
+
:basic_auth => auth,
|
110
|
+
:body => [ {"method":"backupwallet","params":[filename],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
111
|
+
}
|
112
|
+
response = HTTParty.get(@url, options)
|
113
|
+
out = response.parsed_response
|
114
|
+
result = out[0]['result']
|
115
|
+
if result.nil?
|
116
|
+
res = "Backup successful!"
|
117
|
+
else
|
118
|
+
res = out[0]['error']['message']
|
119
|
+
end
|
120
|
+
return res; #returns result
|
121
|
+
end
|
122
|
+
|
123
|
+
# Function to import wallet's backup on RecordsKeeper Blockchain
|
124
|
+
def self.importWallet filename
|
125
|
+
auth = {:username => @user, :password => @password}
|
126
|
+
options = {
|
127
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
128
|
+
:basic_auth => auth,
|
129
|
+
:body => [ {"method":"importwallet","params":[filename],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
130
|
+
}
|
131
|
+
response = HTTParty.get(@url, options)
|
132
|
+
out = response.parsed_response
|
133
|
+
result = out[0]['result']
|
134
|
+
if result.nil?
|
135
|
+
res = "Wallet is successfully imported"
|
136
|
+
else
|
137
|
+
res = out[0]['error']['message']
|
138
|
+
end
|
139
|
+
return res; #returns result
|
140
|
+
end
|
141
|
+
|
142
|
+
# Function to dump wallet on RecordsKeeper Blockchain
|
143
|
+
def self.dumpWallet filename
|
144
|
+
auth = {:username => @user, :password => @password}
|
145
|
+
options = {
|
146
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
147
|
+
:basic_auth => auth,
|
148
|
+
:body => [ {"method":"dumpwallet","params":[filename],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
149
|
+
}
|
150
|
+
response = HTTParty.get(@url, options)
|
151
|
+
out = response.parsed_response
|
152
|
+
result = out[0]['result']
|
153
|
+
if result.nil?
|
154
|
+
res = "Wallet is successfully dumped"
|
155
|
+
else
|
156
|
+
res = out[0]['error']['message']
|
157
|
+
end
|
158
|
+
return res; #returns result
|
159
|
+
end
|
160
|
+
|
161
|
+
# Function to lock wallet on RecordsKeeper Blockchain
|
162
|
+
def self.lockWallet password
|
163
|
+
auth = {:username => @user, :password => @password}
|
164
|
+
options = {
|
165
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
166
|
+
:basic_auth => auth,
|
167
|
+
:body => [ {"method":"encryptwallet","params":[password],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
168
|
+
}
|
169
|
+
response = HTTParty.get(@url, options)
|
170
|
+
out = response.parsed_response
|
171
|
+
result = out[0]['result']
|
172
|
+
if result.nil?
|
173
|
+
res = "Wallet is successfully encrypted."
|
174
|
+
else
|
175
|
+
res = out[0]['error']['message']
|
176
|
+
end
|
177
|
+
return res; #returns result
|
178
|
+
end
|
179
|
+
|
180
|
+
# Function to unlock wallet on RecordsKeeper Blockchain
|
181
|
+
def self.unlockWallet password, unlocktime
|
182
|
+
auth = {:username => @user, :password => @password}
|
183
|
+
options = {
|
184
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
185
|
+
:basic_auth => auth,
|
186
|
+
:body => [ {"method":"walletpassphrase","params":[password, unlocktime],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
187
|
+
}
|
188
|
+
response = HTTParty.get(@url, options)
|
189
|
+
out = response.parsed_response
|
190
|
+
result = out[0]['result']
|
191
|
+
if result.nil?
|
192
|
+
res = "Wallet is successfully unlocked."
|
193
|
+
else
|
194
|
+
res = out[0]['error']['message']
|
195
|
+
end
|
196
|
+
return res; #returns result
|
197
|
+
end
|
198
|
+
|
199
|
+
# Function to change password for wallet on RecordsKeeper Blockchain
|
200
|
+
def self.changeWalletPassword old_password, new_password
|
201
|
+
auth = {:username => @user, :password => @password}
|
202
|
+
options = {
|
203
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
204
|
+
:basic_auth => auth,
|
205
|
+
:body => [ {"method":"walletpassphrasechange","params":[old_password, new_password],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
206
|
+
}
|
207
|
+
response = HTTParty.get(@url, options)
|
208
|
+
out = response.parsed_response
|
209
|
+
result = out[0]['result']
|
210
|
+
if result.nil?
|
211
|
+
res = "Password successfully changed!"
|
212
|
+
else
|
213
|
+
res = out[0]['error']['message']
|
214
|
+
end
|
215
|
+
return res; #returns result
|
216
|
+
end
|
217
|
+
|
218
|
+
# Function to sign message on RecordsKeeper Blockchain
|
219
|
+
def self.signMessage private_key, message
|
220
|
+
auth = {:username => @user, :password => @password}
|
221
|
+
options = {
|
222
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
223
|
+
:basic_auth => auth,
|
224
|
+
:body => [ {"method":"signmessage","params":[private_key, message],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
225
|
+
}
|
226
|
+
response = HTTParty.get(@url, options)
|
227
|
+
out = response.parsed_response
|
228
|
+
signedMessage = out[0]['result']
|
229
|
+
return signedMessage; #returns private key
|
230
|
+
end
|
231
|
+
|
232
|
+
# Function to verify message on RecordsKeeper Blockchain
|
233
|
+
def self.verifyMessage address, signedMessage, message
|
234
|
+
auth = {:username => @user, :password => @password}
|
235
|
+
options = {
|
236
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
237
|
+
:basic_auth => auth,
|
238
|
+
:body => [ {"method":"verifymessage","params":[address, signedMessage, message],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
239
|
+
}
|
240
|
+
response = HTTParty.get(@url, options)
|
241
|
+
out = response.parsed_response
|
242
|
+
verifiedMessage = out[0]['result']
|
243
|
+
if verifiedMessage
|
244
|
+
validity = "Yes, message is verified"
|
245
|
+
else
|
246
|
+
validity = "No, signedMessage is not correct"
|
247
|
+
end
|
248
|
+
return validity; #returns validity
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "RecordsKeeperRuby/version"
|
2
|
+
require_relative ('RecordsKeeperRuby/address')
|
3
|
+
require_relative ('RecordsKeeperRuby/assets')
|
4
|
+
require_relative ('RecordsKeeperRuby/block')
|
5
|
+
require_relative ('RecordsKeeperRuby/blockchain')
|
6
|
+
require_relative ('RecordsKeeperRuby/permissions')
|
7
|
+
require_relative ('RecordsKeeperRuby/stream')
|
8
|
+
require_relative ('RecordsKeeperRuby/transaction')
|
9
|
+
require_relative ('RecordsKeeperRuby/wallet')
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# config.yaml
|
2
|
+
testnet:
|
3
|
+
url: testurl
|
4
|
+
rkuser: rkuser
|
5
|
+
passwd: rkpwd
|
6
|
+
chain: test-chain
|
7
|
+
port: testport
|
8
|
+
stream: streamname
|
9
|
+
testdata: test_data
|
10
|
+
amount: test_amount
|
11
|
+
dumptxid: test_txid
|
12
|
+
privatekey: test_privkey
|
13
|
+
validaddress: valid_address
|
14
|
+
invalidaddress: invalid_address
|
15
|
+
miningaddress: mining_address
|
16
|
+
nonminingaddress: nonmining_address
|
17
|
+
multisigaddress: multisig_address
|
18
|
+
wrongimportaddress: wrongimport_address
|
19
|
+
mainaddress: main_address
|
20
|
+
permissionaddress: permission_address
|
21
|
+
dumptxhex: dump_txhex
|
22
|
+
dumpsignedtxhex: dump_signedtxhex
|
23
|
+
samplegetmultisigaddress: sample_multisigaddress
|
24
|
+
samplemerkleroot: sample_merkleroot
|
25
|
+
sampleblockhash: sample_blockhash
|
26
|
+
sampledata: sample_data
|
27
|
+
sampletransac: sample_transaction_id
|
28
|
+
transactionid: transaction_id
|
29
|
+
sampletxid: sample_txid
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
mainnet:
|
34
|
+
url: mainurl
|
35
|
+
rkuser: rkuser
|
36
|
+
passwd: rkpwd
|
37
|
+
chain: main-chain
|
38
|
+
port: mainport
|
39
|
+
stream: streamname
|
40
|
+
testdata: main_data
|
41
|
+
amount: main_amount
|
42
|
+
dumptxid: main_txid
|
43
|
+
privatekey: main_privkey
|
44
|
+
validaddress: valid_address
|
45
|
+
invalidaddress: invalid_address
|
46
|
+
miningaddress: mining_address
|
47
|
+
nonminingaddress: nonmining_address
|
48
|
+
multisigaddress: multisig_address
|
49
|
+
wrongimportaddress: wrongimport_address
|
50
|
+
mainaddress: main_address
|
51
|
+
permissionaddress: permission_address
|
52
|
+
dumptxhex: dump_txhex
|
53
|
+
dumpsignedtxhex: dump_signedtxhex
|
54
|
+
samplegetmultisigaddress: sample_multisigaddress
|
55
|
+
samplemerkleroot: sample_merkleroot
|
56
|
+
sampleblockhash: sample_blockhash
|
57
|
+
sampledata: sample_data
|
58
|
+
sampletransac: sample_transaction_id
|
59
|
+
transactionid: transaction_id
|
60
|
+
sampletxid: sample_txid
|
data/sample_config.yaml
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# config.yaml
|
2
|
+
testnet:
|
3
|
+
url: testurl
|
4
|
+
rkuser: rkuser
|
5
|
+
passwd: rkpwd
|
6
|
+
chain: test-chain
|
7
|
+
port: testport
|
8
|
+
stream: streamname
|
9
|
+
testdata: test_data
|
10
|
+
amount: test_amount
|
11
|
+
dumptxid: test_txid
|
12
|
+
privatekey: test_privkey
|
13
|
+
validaddress: valid_address
|
14
|
+
invalidaddress: invalid_address
|
15
|
+
miningaddress: mining_address
|
16
|
+
nonminingaddress: nonmining_address
|
17
|
+
multisigaddress: multisig_address
|
18
|
+
wrongimportaddress: wrongimport_address
|
19
|
+
mainaddress: main_address
|
20
|
+
permissionaddress: permission_address
|
21
|
+
dumptxhex: dump_txhex
|
22
|
+
dumpsignedtxhex: dump_signedtxhex
|
23
|
+
samplegetmultisigaddress: sample_multisigaddress
|
24
|
+
samplemerkleroot: sample_merkleroot
|
25
|
+
sampleblockhash: sample_blockhash
|
26
|
+
sampledata: sample_data
|
27
|
+
sampletransac: sample_transaction_id
|
28
|
+
transactionid: transaction_id
|
29
|
+
sampletxid: sample_txid
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
mainnet:
|
34
|
+
url: mainurl
|
35
|
+
rkuser: rkuser
|
36
|
+
passwd: rkpwd
|
37
|
+
chain: main-chain
|
38
|
+
port: mainport
|
39
|
+
stream: streamname
|
40
|
+
testdata: main_data
|
41
|
+
amount: main_amount
|
42
|
+
dumptxid: main_txid
|
43
|
+
privatekey: main_privkey
|
44
|
+
validaddress: valid_address
|
45
|
+
invalidaddress: invalid_address
|
46
|
+
miningaddress: mining_address
|
47
|
+
nonminingaddress: nonmining_address
|
48
|
+
multisigaddress: multisig_address
|
49
|
+
wrongimportaddress: wrongimport_address
|
50
|
+
mainaddress: main_address
|
51
|
+
permissionaddress: permission_address
|
52
|
+
dumptxhex: dump_txhex
|
53
|
+
dumpsignedtxhex: dump_signedtxhex
|
54
|
+
samplegetmultisigaddress: sample_multisigaddress
|
55
|
+
samplemerkleroot: sample_merkleroot
|
56
|
+
sampleblockhash: sample_blockhash
|
57
|
+
sampledata: sample_data
|
58
|
+
sampletransac: sample_transaction_id
|
59
|
+
transactionid: transaction_id
|
60
|
+
sampletxid: sample_txid
|