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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
#include <inttypes.h>
#include "zano_wallet2_api_c.h"
#include <unistd.h>
#include <cstring>
#include <thread>
#include "helpers.hpp"
#include "../../../../zano/src/wallet/plain_wallet_api.h"
#include "zano_checksum.h"
#ifdef __cplusplus
extern "C"
{
#endif
// namespace plain_wallet
// {
// typedef int64_t hwallet;
// std::string init(const std::string& address, const std::string& working_dir, int log_level);
const char* ZANO_PlainWallet_init(const char* address, const char* working_dir, int log_level) {
DEBUG_START()
std::string str = plain_wallet::init(std::string(address), std::string(working_dir), log_level);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string init(const std::string& ip, const std::string& port, const std::string& working_dir, int log_level);
const char* ZANO_PlainWallet_init2(const char* ip, const char* port, const char* working_dir, int log_level) {
DEBUG_START()
std::string str = plain_wallet::init(std::string(ip), std::string(port), std::string(working_dir), log_level);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string reset();
const char* ZANO_PlainWallet_reset() {
DEBUG_START()
std::string str = plain_wallet::reset();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string set_log_level(int log_level);
const char* ZANO_PlainWallet_setLogLevel(int log_level) {
DEBUG_START()
std::string str = plain_wallet::set_log_level(log_level);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_version();
const char* ZANO_PlainWallet_getVersion() {
DEBUG_START()
std::string str = plain_wallet::get_version();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_wallet_files();
const char* ZANO_PlainWallet_getWalletFiles() {
DEBUG_START()
std::string str = plain_wallet::get_wallet_files();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_export_private_info(const std::string& target_dir);
const char* ZANO_PlainWallet_getExportPrivateInfo(const char* target_dir) {
DEBUG_START()
std::string str = plain_wallet::get_export_private_info(std::string(target_dir));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string delete_wallet(const std::string& file_name);
const char* ZANO_PlainWallet_deleteWallet(const char* file_name) {
DEBUG_START()
std::string str = plain_wallet::delete_wallet(std::string(file_name));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_address_info(const std::string& addr);
const char* ZANO_PlainWallet_getAddressInfo(const char* addr) {
DEBUG_START()
std::string str = plain_wallet::get_address_info(std::string(addr));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_appconfig(const std::string& encryption_key);
const char* ZANO_PlainWallet_getAppconfig(const char* encryption_key) {
DEBUG_START()
std::string str = plain_wallet::get_appconfig(std::string(encryption_key));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string set_appconfig(const std::string& conf_str, const std::string& encryption_key);
const char* ZANO_PlainWallet_setAppconfig(const char* conf_str, const char* encryption_key) {
DEBUG_START()
std::string str = plain_wallet::set_appconfig(std::string(conf_str), std::string(encryption_key));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string generate_random_key(uint64_t lenght);
const char* ZANO_PlainWallet_generateRandomKey(uint64_t lenght) {
DEBUG_START()
std::string str = plain_wallet::generate_random_key(lenght);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_logs_buffer();
const char* ZANO_PlainWallet_getLogsBuffer() {
DEBUG_START()
std::string str = plain_wallet::get_logs_buffer();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string truncate_log();
const char* ZANO_PlainWallet_truncateLog() {
DEBUG_START()
std::string str = plain_wallet::truncate_log();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_connectivity_status();
const char* ZANO_PlainWallet_getConnectivityStatus() {
DEBUG_START()
std::string str = plain_wallet::get_connectivity_status();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string open(const std::string& path, const std::string& password);
const char* ZANO_PlainWallet_open(const char* path, const char* password) {
DEBUG_START()
std::string str = plain_wallet::open(std::string(path), std::string(password));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string restore(const std::string& seed, const std::string& path, const std::string& password, const std::string& seed_password);
const char* ZANO_PlainWallet_restore(const char* seed, const char* path, const char* password, const char* seed_password) {
DEBUG_START()
std::string str = plain_wallet::restore(std::string(seed), std::string(path), std::string(password), std::string(seed_password));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string generate(const std::string& path, const std::string& password);
const char* ZANO_PlainWallet_generate(const char* path, const char* password) {
DEBUG_START()
std::string str = plain_wallet::generate(std::string(path), std::string(password));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_opened_wallets();
const char* ZANO_PlainWallet_getOpenWallets() {
DEBUG_START()
std::string str = plain_wallet::get_opened_wallets();
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string get_wallet_status(hwallet h);
const char* ZANO_PlainWallet_getWalletStatus(int64_t h) {
DEBUG_START()
std::string str = plain_wallet::get_wallet_status(h);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string close_wallet(hwallet h);
const char* ZANO_PlainWallet_closeWallet(int64_t h) {
DEBUG_START()
std::string str = plain_wallet::close_wallet(h);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string invoke(hwallet h, const std::string& params);
const char* ZANO_PlainWallet_invoke(int64_t h, const char* params) {
DEBUG_START()
std::string str = plain_wallet::invoke(h, std::string(params));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// //async api
// std::string async_call(const std::string& method_name, uint64_t instance_id, const std::string& params);
const char* ZANO_PlainWallet_asyncCall(const char* method_name, uint64_t instance_id, const char* params) {
DEBUG_START()
std::string str = plain_wallet::async_call(std::string(method_name), instance_id, std::string(params));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string try_pull_result(uint64_t);
const char* ZANO_PlainWallet_tryPullResult(uint64_t instance_id) {
DEBUG_START()
std::string str = plain_wallet::try_pull_result(instance_id);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string sync_call(const std::string& method_name, uint64_t instance_id, const std::string& params);
const char* ZANO_PlainWallet_syncCall(const char* method_name, uint64_t instance_id, const char* params) {
DEBUG_START()
std::string str = plain_wallet::sync_call(std::string(method_name), instance_id, std::string(params));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// //cake wallet api extension
// bool is_wallet_exist(const std::string& path);
bool ZANO_PlainWallet_isWalletExist(const char* path) {
DEBUG_START()
return plain_wallet::is_wallet_exist(std::string(path));
DEBUG_END()
}
// std::string get_wallet_info(hwallet h);
const char* ZANO_PlainWallet_getWalletInfo(int64_t h) {
DEBUG_START()
std::string str = plain_wallet::get_wallet_info(h);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// std::string reset_wallet_password(hwallet h, const std::string& password);
const char* ZANO_PlainWallet_resetWalletPassword(int64_t h, const char* password) {
DEBUG_START()
std::string str = plain_wallet::reset_wallet_password(h, std::string(password));
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
DEBUG_END()
}
// uint64_t get_current_tx_fee(uint64_t priority); // 0 (default), 1 (unimportant), 2 (normal), 3 (elevated), 4 (priority)
uint64_t ZANO_PlainWallet_getCurrentTxFee(uint64_t priority) {
DEBUG_START()
return plain_wallet::get_current_tx_fee(priority);
DEBUG_END()
}
// }
void ZANO_free(void* ptr) {
free(ptr);
}
const char* ZANO_checksum_wallet2_api_c_h() {
return ZANO_wallet2_api_c_h_sha256;
}
const char* ZANO_checksum_wallet2_api_c_cpp() {
return ZANO_wallet2_api_c_cpp_sha256;
}
const char* ZANO_checksum_wallet2_api_c_exp() {
return ZANO_wallet2_api_c_exp_sha256;
}
#ifdef __cplusplus
}
#endif
|