-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallFuncsMain.h
More file actions
311 lines (220 loc) · 8.46 KB
/
callFuncsMain.h
File metadata and controls
311 lines (220 loc) · 8.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/*******************************************************************************
*
* Software Name: CryptoDbSS Client API RPC
* Copyright (C) 2025 Steeven J Salazar.
* License: CryptoDbSS: Software Review and Audit License
*
* https://github.com/CryptoDbSS/CryptoDbSS-Client-API-RPC
*
* This notice, including the copyright notice and permission notice,
* must be retained in all copies or substantial portions of the Software and
* in all derivative works.
*
* IMPORTANT: Before using, compiling, or doing anything with this software,
* you must read and accept the terms of the License provided with this software.
*
* If you do not have a copy of the License, you can obtain it at the following link:
* https://github.com/CryptoDbSS/CryptoDbSS-Client-API-RPC/blob/main/LICENSE.md
*
* By using, compiling, or modifying this software, you implicitly accept
* the terms of the License. If you do not agree with the terms,
* do not use, compile, or modify this software.
*
* This software is provided "as is," without warranty of any kind.
* For more details, see the LICENSE file.
*
********************************************************************************/
/*********************************************************************************
The CryptoDbSS, blockchain-core, consensus, protocols and misc.
This software is a review and audit release, it should only be used for
development, testing, education and auditing purposes.
Third-party dependencies: Crypto++, OpenSSL, libcurl.
questions, suggestions or contact : Steevenjavier@gmail.com
S.S
*********************************************************************************/
#include "CryptoDbSS-ClientRPC.h"
inline std::string RPC_Address = LoadProvider();
uint maxTimeForConfirmation = 650;
void ShowHelpInfo(const string &processAppName ,const string &help){
if(help == "ProcessTransaction"){
cout<<processAppName+ " ProcessTransaction <fromAcc> <AddressTo or message> <value transaction> <type of transaction>"<<endl;
return;
}
if(help == "setprovider"){
cout<<processAppName+" setprovider <rpc address>"<<endl;
return;
}
if(help == "IndexBalance"){
cout<<processAppName+" IndexBalance <address Account to index>"<<endl;
return;
}
if(help == "SearchTransaction"){
cout<<processAppName+" SearchTransaction <option: bynumber, hash, MSG> <block bumber of transaction> <number of transction>"<<endl<<
processAppName+" SearchTransaction <option: byhash> <hash of transaction>"<<endl;
return;
}
if(help == "SearchBlock"){
cout<<" ./cryptosbssClient SearchBlock <number of block to index>"<<endl;
return;
}
std::cout<< std::endl;
std::cout<< "CryptoDbSS Client commands <funtion> <args...>" << std::endl;
std::cout<< std::endl;
std::cout<< "general: <ProcessTransaction> <args...>" << std::endl;
std::cout<< " <IndexBalance> <args...>" << std::endl;
std::cout<< " <SearchTransaction> <args...>" << std::endl;
std::cout<< " <SearchBlock> <args...>" << std::endl;
std::cout<< " <walletsStored> " << std::endl;
std::cout<< std::endl;
std::cout<< "Accounts management: <SaveNewWallet> <args...>" << std::endl;
std::cout<< std::endl;
std::cout<< "Settings: <setpassencryption> <args...>" << std::endl;
std::cout<< " <setprovider> <args...>" << std::endl;
std::cout<< std::endl;
std::cout<< " || Developed by: steevenjavier@gmail.com ||" << std::endl;
std::cout<< std::endl;
}
void _savePass(){
if(savePass()){
cout<<"Client Password Set succesfully"<<endl;
} else {
cout<<"Client Password could not set"<<endl;
}
}
bool _ProcessTransaction(char* arg[], uint NumbArgs){
const string processAppName = arg[0];
if (NumbArgs != 6) {
const string help ="ProcessTransaction";
ShowHelpInfo(processAppName, help);
return false;
}
std::string fromAcc = arg[2];
std::string AddressTo = arg[3];
std::string value = arg[4];
std::string typeT = arg[5];
uint8_t TypeTransaction = hexToUint8_t(typeT);
//cheackear valor de entrada del value
ProcessTransaction(fromAcc, AddressTo, ullToHex(stoull(value)), TypeTransaction);
recovered="";
AccLoaded.clear();
return true;
}
bool _ProcessTransaction2(char* arg[], uint NumbArgs){
const string processAppName = arg[0];
if (NumbArgs != 6) {
const string help ="ProcessTransaction";
ShowHelpInfo(processAppName, help);
return false;
}
std::string fromAcc = arg[2];
std::string AddressTo = arg[3];
std::string value = arg[4];
std::string typeT = arg[5];
uint8_t TypeTransaction = hexToUint8_t(typeT);
//cheackear valor de entrada del value
ProcessTransaction2(fromAcc, AddressTo, ullToHex(stoull(value)), TypeTransaction);
recovered="";
AccLoaded.clear();
return true;
}
bool _ProcessTransactionDebugNoSign(char* arg[], uint NumbArgs){
const string processAppName = arg[0];
if (NumbArgs != 6) {
const string help ="ProcessTransaction";
ShowHelpInfo(processAppName, help);
return false;
}
std::string fromAcc = arg[2];
std::string AddressTo = arg[3];
std::string value = arg[4];
std::string typeT = arg[5];
uint8_t TypeTransaction = hexToUint8_t(typeT);
//cheackear valor de entrada del value
ProcessTransactionDebugNoSign(fromAcc, AddressTo, ullToHex(stoull(value)), TypeTransaction);
recovered="";
AccLoaded.clear();
cout<<endl;
return true;
}
bool _SaveNewWallet(){
return SaveNewWallet(1);
}
bool _DisplayWallets(){
std::vector<std::string>Wallets = savedWallets();
for (size_t i = 0; i < Wallets.size(); ++i) {
std::cout << std::setw(3) << i + 1 << ". " << Wallets[i] << std::endl;
}
return true;
}
bool _SetProvider(char* arg[], uint NumbArgs){
const string processAppName = arg[0];
if (NumbArgs != 3) {
const string help ="setprovider";
ShowHelpInfo(processAppName,help);
return false;
}
std::string address = arg[2];
return SetProvider(address);
}
bool _IndexBalance(char* argv[], uint NumbArgs){
const string processAppName = argv[0];
if (NumbArgs != 3) {
const string help ="IndexBalance";
ShowHelpInfo(processAppName, help);
return false;
}
indexBalanceAcc(argv[2]);
return true;
}
string _SearchTransaction(char* argv[], uint NumbArgs){
const string processAppName = argv[0];
if (NumbArgs != 4&&NumbArgs != 5 ) {
const string help ="SearchTransaction";
ShowHelpInfo(processAppName, help);
cout<<"wrong arguments provided";
return "wrong arguments provided";
}
std::string choice = argv[2];
if(NumbArgs == 4){
if( choice == "byhash" ){
std::string result= SearchTransactionByHash(argv[3]);
std::cout<<"Raw-Data Transaction : "<<result<<std::endl;
return result;
}
const string help= "SearchTransaction";
ShowHelpInfo(processAppName, help);
return "call func cdbss client does not match";
}
string BN = ullToHex(stoull(argv[3]));
string TN = ullToHex(stoull(argv[4]));
if( choice == "bynumber" ){
std::string result= SearchTransactionByNumer(BN,TN);
std::cout<<result<<std::endl;
return result;
}
if( choice == "hash" ){
std::string result= HashOfTransaction(BN,TN);
std::cout<<result<<std::endl;
return result;
}
if( choice == "MSG" ){
std::string result= SearchTransactionMSGByNumer(BN,TN);
std::cout<<result<<std::endl;
return result;
}
const string help= "SearchTransaction";
ShowHelpInfo(processAppName, help);
return "call func cdbss client does not match";
}
bool _SearchBlock(char* argv[], uint NumbArgs){
const string processAppName = argv[0];
if (NumbArgs != 3) {
const string help ="SearchBlock";
ShowHelpInfo(processAppName, help);
return false;
}
std::string choice = argv[2];
std::string result = SearchBlByNumer(argv[2]);
std::cout<<result<<std::endl;
return true;
}