RecordsKeeperRubyLib 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/CODE_OF_CONDUCT.md +0 -8
- data/Gemfile +0 -1
- data/Gemfile.lock +4 -62
- data/LICENSE.txt +2 -2
- data/README.md +92 -1
- data/{RecordsKeeperRuby.gemspec → RecordsKeeperRubyLib.gemspec} +4 -5
- data/bin/console +1 -1
- data/config.yaml +8 -0
- data/docs/{addressdoc.rb → address_doc.rb} +105 -116
- data/docs/{assetsdoc.rb → asset_doc.rb} +54 -65
- data/docs/block_doc.rb +63 -0
- data/docs/blockchain_doc.rb +77 -0
- data/docs/{permissionsdoc.rb → permissions_doc.rb} +54 -65
- data/docs/{streamdoc.rb → stream_doc.rb} +79 -84
- data/docs/{transactiondoc.rb → transaction_doc.rb} +110 -121
- data/docs/{walletdoc.rb → wallet_doc.rb} +122 -133
- data/lib/RecordsKeeperRubyLib.rb +9 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/address.rb +198 -186
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/assets.rb +99 -87
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/block.rb +94 -89
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/blockchain.rb +148 -135
- data/lib/RecordsKeeperRubyLib/config.yaml +8 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/permissions.rb +77 -77
- data/lib/RecordsKeeperRubyLib/stream.rb +220 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/transaction.rb +213 -182
- data/lib/RecordsKeeperRubyLib/version.rb +3 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/wallet.rb +263 -252
- data/lib/config.yaml +8 -0
- metadata +27 -41
- data/docs/blockchaindoc.rb +0 -77
- data/docs/blockdoc.rb +0 -76
- data/lib/RecordsKeeperRuby.rb +0 -9
- data/lib/RecordsKeeperRuby/sample_config.yaml +0 -60
- data/lib/RecordsKeeperRuby/stream.rb +0 -169
- data/lib/RecordsKeeperRuby/version.rb +0 -3
- data/lib/sample_config.yaml +0 -60
- data/sample_config.yaml +0 -60
@@ -0,0 +1,9 @@
|
|
1
|
+
require "RecordsKeeperRubyLib/version"
|
2
|
+
require_relative ('RecordsKeeperRubyLib/address')
|
3
|
+
require_relative ('RecordsKeeperRubyLib/assets')
|
4
|
+
require_relative ('RecordsKeeperRubyLib/block')
|
5
|
+
require_relative ('RecordsKeeperRubyLib/blockchain')
|
6
|
+
require_relative ('RecordsKeeperRubyLib/permissions')
|
7
|
+
require_relative ('RecordsKeeperRubyLib/stream')
|
8
|
+
require_relative ('RecordsKeeperRubyLib/transaction')
|
9
|
+
require_relative ('RecordsKeeperRubyLib/wallet')
|
@@ -1,186 +1,198 @@
|
|
1
|
-
# Library to work with RecordsKeeper address class.
|
2
|
-
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance
|
3
|
-
# by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
-
|
5
|
-
# import rubygems, httparty, json, binary_parser, objspace and yaml
|
6
|
-
require 'rubygems'
|
7
|
-
require 'httparty'
|
8
|
-
require 'json'
|
9
|
-
require 'binary_parser'
|
10
|
-
require 'yaml'
|
11
|
-
|
12
|
-
# Address class to access
|
13
|
-
module
|
14
|
-
class Address
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@url = cfg['
|
20
|
-
@user = cfg['
|
21
|
-
@password = cfg['
|
22
|
-
@chain = cfg['
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
res = out[0]['
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
:
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
res = out[0]['
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
:
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
address =
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
return
|
109
|
-
end
|
110
|
-
|
111
|
-
# Function to check if given address is valid or not
|
112
|
-
def self.checkifValid address
|
113
|
-
auth = {:username => @user, :password => @password}
|
114
|
-
options = {
|
115
|
-
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
116
|
-
:basic_auth => auth,
|
117
|
-
:body => [ {"method":"validateaddress","params":[address],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
118
|
-
}
|
119
|
-
response = HTTParty.get(@url, options)
|
120
|
-
out = response.parsed_response
|
121
|
-
validity = out[0]['result']['isvalid']
|
122
|
-
if validity
|
123
|
-
addressCheck = "Address is valid" # Prints that address is valid
|
124
|
-
else
|
125
|
-
addressCheck= "Address is invalid" # Prints that address is invalid
|
126
|
-
end
|
127
|
-
return addressCheck; # Return the address check status
|
128
|
-
end
|
129
|
-
|
130
|
-
# Function to check if given address has mining permission or not
|
131
|
-
def self.checkifMineAllowed address
|
132
|
-
auth = {:username => @user, :password => @password}
|
133
|
-
options = {
|
134
|
-
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
135
|
-
:basic_auth => auth,
|
136
|
-
:body => [ {"method":"validateaddress","params":[address],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
137
|
-
}
|
138
|
-
response = HTTParty.get(@url, options)
|
139
|
-
out = response.parsed_response
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
1
|
+
# Library to work with RecordsKeeper address class.
|
2
|
+
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance
|
3
|
+
# by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
|
5
|
+
# import rubygems, httparty, json, binary_parser, objspace and yaml
|
6
|
+
require 'rubygems'
|
7
|
+
require 'httparty'
|
8
|
+
require 'json'
|
9
|
+
require 'binary_parser'
|
10
|
+
require 'yaml'
|
11
|
+
|
12
|
+
# Address class to access Address related functions
|
13
|
+
module RecordsKeeperRubyLib
|
14
|
+
class Address
|
15
|
+
if File.exist?('config.yaml')
|
16
|
+
# Import values from configuration file.
|
17
|
+
cfg = YAML::load(File.open('config.yaml','r'))
|
18
|
+
|
19
|
+
@url = cfg['url']
|
20
|
+
@user = cfg['rkuser']
|
21
|
+
@password = cfg['passwd']
|
22
|
+
@chain = cfg['chain']
|
23
|
+
|
24
|
+
else
|
25
|
+
#Import using ENV variables
|
26
|
+
|
27
|
+
@url = ENV['url']
|
28
|
+
@user = ENV['rkuser']
|
29
|
+
@password = ENV['passwd']
|
30
|
+
@chain = ENV['chain']
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# Function to generate new address on the node's wallet
|
35
|
+
def self.getAddress
|
36
|
+
|
37
|
+
auth = {:username => @user, :password => @password}
|
38
|
+
options = {
|
39
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
40
|
+
:basic_auth => auth,
|
41
|
+
:body => [ {"method":"getnewaddress","params":[],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
42
|
+
}
|
43
|
+
response = HTTParty.get(@url, options)
|
44
|
+
out = response.parsed_response
|
45
|
+
address = out[0]['result']
|
46
|
+
return address
|
47
|
+
end
|
48
|
+
|
49
|
+
# Function to generate a new multisignature address
|
50
|
+
def self.getMultisigAddress nrequired, key #getMultisigAddress() function definition
|
51
|
+
|
52
|
+
key_list = key.split(",")
|
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":"createmultisig","params":[nrequired, key_list],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
58
|
+
}
|
59
|
+
response = HTTParty.get(@url, options)
|
60
|
+
out = response.parsed_response
|
61
|
+
address = out[0]['result']
|
62
|
+
if address.nil?
|
63
|
+
res = out[0]['error']['message']
|
64
|
+
else
|
65
|
+
res = out[0]['result']['address']
|
66
|
+
end
|
67
|
+
return res; #returns new multisig address
|
68
|
+
end
|
69
|
+
|
70
|
+
# Function to generate a new multisignature address on the node's wallet
|
71
|
+
def self.getMultisigWalletAddress nrequired, key
|
72
|
+
key_list = key.split(",")
|
73
|
+
auth = {:username => @user, :password => @password}
|
74
|
+
options = {
|
75
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
76
|
+
:basic_auth => auth,
|
77
|
+
:body => [ {"method":"addmultisigaddress","params":[nrequired, key_list],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
78
|
+
}
|
79
|
+
response = HTTParty.get(@url, options)
|
80
|
+
out = response.parsed_response
|
81
|
+
address = out[0]['result']
|
82
|
+
if address.nil?
|
83
|
+
res = out[0]['error']['message']
|
84
|
+
else
|
85
|
+
res = out[0]['result']
|
86
|
+
end
|
87
|
+
return res; # Returns new multisig address
|
88
|
+
end
|
89
|
+
|
90
|
+
# Function to list all addresses and no of addresses on the node's wallet
|
91
|
+
def self.retrieveAddresses
|
92
|
+
auth = {:username => @user, :password => @password}
|
93
|
+
options = {
|
94
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
95
|
+
:basic_auth => auth,
|
96
|
+
:body => [ {"method":"getaddresses","params":[],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
97
|
+
}
|
98
|
+
response = HTTParty.get(@url, options)
|
99
|
+
out = response.parsed_response
|
100
|
+
address = out[0]['result']
|
101
|
+
address_count = address.length
|
102
|
+
address =[]
|
103
|
+
for i in 0..address_count
|
104
|
+
address.push(out[0]['result'][i])
|
105
|
+
end
|
106
|
+
retrieved = { :address => address,:address_count => address_count}
|
107
|
+
retrievedinfo = JSON.generate retrieved
|
108
|
+
return retrievedinfo
|
109
|
+
end
|
110
|
+
|
111
|
+
# Function to check if given address is valid or not
|
112
|
+
def self.checkifValid address
|
113
|
+
auth = {:username => @user, :password => @password}
|
114
|
+
options = {
|
115
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
116
|
+
:basic_auth => auth,
|
117
|
+
:body => [ {"method":"validateaddress","params":[address],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
118
|
+
}
|
119
|
+
response = HTTParty.get(@url, options)
|
120
|
+
out = response.parsed_response
|
121
|
+
validity = out[0]['result']['isvalid']
|
122
|
+
if validity
|
123
|
+
addressCheck = "Address is valid" # Prints that address is valid
|
124
|
+
else
|
125
|
+
addressCheck= "Address is invalid" # Prints that address is invalid
|
126
|
+
end
|
127
|
+
return addressCheck; # Return the address check status
|
128
|
+
end
|
129
|
+
|
130
|
+
# Function to check if given address has mining permission or not
|
131
|
+
def self.checkifMineAllowed address
|
132
|
+
auth = {:username => @user, :password => @password}
|
133
|
+
options = {
|
134
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
135
|
+
:basic_auth => auth,
|
136
|
+
:body => [ {"method":"validateaddress","params":[address],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
137
|
+
}
|
138
|
+
response = HTTParty.get(@url, options)
|
139
|
+
out = response.parsed_response
|
140
|
+
|
141
|
+
check = out[0]['result']['isvalid']
|
142
|
+
|
143
|
+
if check
|
144
|
+
permission = out[0]['result']['ismine']
|
145
|
+
if permission
|
146
|
+
permissionCheck = "Address has mining permission" # Prints that address has mining permission
|
147
|
+
else
|
148
|
+
permissionCheck = "Address has not given mining permission" # Prints that address hasn't been given mining permission
|
149
|
+
end
|
150
|
+
else
|
151
|
+
permissionCheck = "Invalid address";
|
152
|
+
end
|
153
|
+
return permissionCheck; # Returns the permission status
|
154
|
+
end
|
155
|
+
|
156
|
+
# Function to check node address balance on RecordsKeeper Blockchain
|
157
|
+
def self.checkBalance address
|
158
|
+
auth = {:username => @user, :password => @password}
|
159
|
+
options = {
|
160
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
161
|
+
:basic_auth => auth,
|
162
|
+
:body => [ {"method":"getaddressbalances","params":[address],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
163
|
+
}
|
164
|
+
response = HTTParty.get(@url, options)
|
165
|
+
out = response.parsed_response
|
166
|
+
check = out[0]['result']
|
167
|
+
if check
|
168
|
+
balance = out[0]['result'][0]['qty']
|
169
|
+
else
|
170
|
+
balance = out[0]['error']['message']
|
171
|
+
end
|
172
|
+
return balance; # Returns balance of a particular node address
|
173
|
+
end
|
174
|
+
|
175
|
+
# Function to import address on RecordsKeeper Blockchain
|
176
|
+
def self.importAddress public_address
|
177
|
+
auth = {:username => @user, :password => @password}
|
178
|
+
options = {
|
179
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
180
|
+
:basic_auth => auth,
|
181
|
+
:body => [ {"method":"importaddress","params":[public_address, " ", false],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
182
|
+
}
|
183
|
+
response = HTTParty.get(@url, options)
|
184
|
+
out = response.parsed_response
|
185
|
+
result = out[0]['result']
|
186
|
+
error = out[0]['error']
|
187
|
+
if result.nil? && error.nil?
|
188
|
+
resp = "Address successfully imported" # Prints that address has been succesfully imported
|
189
|
+
elsif result.nil? && error!= nil
|
190
|
+
resp = out[0]['error']['message']
|
191
|
+
else
|
192
|
+
resp = 0
|
193
|
+
end
|
194
|
+
return resp;
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
end
|
@@ -1,87 +1,99 @@
|
|
1
|
-
# Library to work with assets.
|
2
|
-
|
3
|
-
# You can issue assets or retrieve assets information by using asset class.
|
4
|
-
# You just have to pass parameters to invoke the pre-defined functions.
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require 'httparty'
|
8
|
-
require 'json'
|
9
|
-
require 'binary_parser'
|
10
|
-
require 'yaml'
|
11
|
-
require 'hex_string'
|
12
|
-
|
13
|
-
module
|
14
|
-
class Assets
|
15
|
-
# # Entry point for accessing
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@url = cfg['
|
21
|
-
@user = cfg['
|
22
|
-
@password = cfg['
|
23
|
-
@chain = cfg['
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:
|
42
|
-
:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
1
|
+
# Library to work with assets.
|
2
|
+
|
3
|
+
# You can issue assets, send assets or retrieve assets information by using asset class.
|
4
|
+
# You just have to pass parameters to invoke the pre-defined functions.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'httparty'
|
8
|
+
require 'json'
|
9
|
+
require 'binary_parser'
|
10
|
+
require 'yaml'
|
11
|
+
require 'hex_string'
|
12
|
+
|
13
|
+
module RecordsKeeperRubyLib
|
14
|
+
class Assets
|
15
|
+
# # Entry point for accessing Asset class functions
|
16
|
+
if File.exist?('config.yaml')
|
17
|
+
# Import values from configuration file.
|
18
|
+
cfg = YAML::load(File.open('config.yaml','r'))
|
19
|
+
|
20
|
+
@url = cfg['url']
|
21
|
+
@user = cfg['rkuser']
|
22
|
+
@password = cfg['passwd']
|
23
|
+
@chain = cfg['chain']
|
24
|
+
|
25
|
+
else
|
26
|
+
#Import using ENV variables
|
27
|
+
|
28
|
+
@url = ENV['url']
|
29
|
+
@user = ENV['rkuser']
|
30
|
+
@password = ENV['passwd']
|
31
|
+
@chain = ENV['chain']
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# Function to create or issue an asset
|
36
|
+
def self.createAsset address, asset_name, asset_qty
|
37
|
+
|
38
|
+
auth = {:username => @user, :password => @password}
|
39
|
+
options = {
|
40
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
41
|
+
:basic_auth => auth,
|
42
|
+
:body => [ {"method":"issue","params":[address, asset_name, asset_qty],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
43
|
+
}
|
44
|
+
response = HTTParty.get(@url, options)
|
45
|
+
out = response.parsed_response
|
46
|
+
check = out[0]['result']
|
47
|
+
if check == nil
|
48
|
+
txid = out[0]['error']['message']
|
49
|
+
else
|
50
|
+
txid = out[0]['result']
|
51
|
+
end
|
52
|
+
return txid; # Variable to store issue transaction id
|
53
|
+
end
|
54
|
+
|
55
|
+
# Function to retrieve assets information
|
56
|
+
def self.retrieveAssets
|
57
|
+
asset_name = []
|
58
|
+
issue_id = []
|
59
|
+
issue_qty = []
|
60
|
+
auth = {:username => @user, :password => @password}
|
61
|
+
options = {
|
62
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
63
|
+
:basic_auth => auth,
|
64
|
+
:body => [ {"method":"listassets","params":[],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
65
|
+
}
|
66
|
+
response = HTTParty.get(@url, options)
|
67
|
+
out = response.parsed_response
|
68
|
+
asset_count = out[0]['result'].length # Returns assets count
|
69
|
+
for i in 0...asset_count
|
70
|
+
asset_name.push(out[0]['result'][i]['name']) # Returns asset name
|
71
|
+
issue_id.push(out[0]['result'][i]['issuetxid']) # Returns issue id
|
72
|
+
issue_qty.push(out[0]['result'][i]['issueraw']) # Returns issue quantity
|
73
|
+
end
|
74
|
+
retrieve = {:asset_name => asset_name,:issue_id => issue_id,:issue_qty => issue_qty,:asset_count => asset_count}
|
75
|
+
retrievedinfo = JSON.generate retrieve
|
76
|
+
return retrievedinfo
|
77
|
+
end
|
78
|
+
|
79
|
+
# Function to send assets to an address
|
80
|
+
def self.sendasset address, asset_name, asset_qty
|
81
|
+
auth = {:username => @user, :password => @password}
|
82
|
+
options = {
|
83
|
+
:headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
|
84
|
+
:basic_auth => auth,
|
85
|
+
:body => [ {"method":"sendasset","params":[address, asset_name, asset_qty],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
|
86
|
+
}
|
87
|
+
response = HTTParty.get(@url, options)
|
88
|
+
out = response.parsed_response
|
89
|
+
if out[0]['result'].nil?
|
90
|
+
txid = out[0]['error']['message']
|
91
|
+
else
|
92
|
+
txid = out[0]['result']
|
93
|
+
end
|
94
|
+
return txid; # Variable to store send asset transaction id
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|