Electroneum
core_rpc_server_commands_defs.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2021, The Electroneum Project
2 // Copyrights(c) 2014-2019, The Monero Project
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31 
32 #pragma once
36 #include "crypto/hash.h"
37 #include "rpc/rpc_handler.h"
38 #include "common/varint.h"
39 #include "common/perf_timer.h"
40 
41 namespace
42 {
43  template<typename T>
44  std::string compress_integer_array(const std::vector<T> &v)
45  {
46  std::string s;
47  s.resize(v.size() * (sizeof(T) * 8 / 7 + 1));
48  char *ptr = (char*)s.data();
49  for (const T &t: v)
50  tools::write_varint(ptr, t);
51  s.resize(ptr - s.data());
52  return s;
53  }
54 
55  template<typename T>
56  std::vector<T> decompress_integer_array(const std::string &s)
57  {
58  std::vector<T> v;
59  v.reserve(s.size());
60  int read = 0;
61  const std::string::const_iterator end = s.end();
62  for (std::string::const_iterator i = s.begin(); i != end; std::advance(i, read))
63  {
64  T t;
65  read = tools::read_varint(std::string::const_iterator(i), s.end(), t);
66  CHECK_AND_ASSERT_THROW_MES(read > 0 && read <= 256, "Error decompressing data");
67  v.push_back(t);
68  }
69  return v;
70  }
71 }
72 
73 namespace cryptonote
74 {
75  //-----------------------------------------------
76 #define CORE_RPC_STATUS_OK "OK"
77 #define CORE_RPC_STATUS_BUSY "BUSY"
78 #define CORE_RPC_STATUS_NOT_MINING "NOT MINING"
79 
80 // When making *any* change here, bump minor
81 // If the change is incompatible, then bump major and set minor to 0
82 // This ensures CORE_RPC_VERSION always increases, that every change
83 // has its own version, and that clients can just test major to see
84 // whether they can talk to a given daemon without having to know in
85 // advance which version they will stop working with
86 // Don't go over 32767 for any of these
87 #define CORE_RPC_VERSION_MAJOR 2
88 #define CORE_RPC_VERSION_MINOR 6
89 #define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
90 #define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
91 
93  {
94  struct request_t
95  {
98  };
100 
101  struct response_t
102  {
105  bool untrusted;
107 
114  };
115  typedef epee::misc_utils::struct_init<response_t> response;
116  };
117 
119  {
120 
121  struct request_t
122  {
123  std::list<crypto::hash> block_ids; //*first 10 blocks id goes sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
125  bool prune;
129  KV_SERIALIZE(start_height)
130  KV_SERIALIZE(prune)
131  KV_SERIALIZE_OPT(no_miner_tx, false)
133  };
134  typedef epee::misc_utils::struct_init<request_t> request;
135 
137  {
138  std::vector<uint64_t> indices;
139 
141  KV_SERIALIZE(indices)
143  };
144 
146  {
147  std::vector<tx_output_indices> indices;
148 
150  KV_SERIALIZE(indices)
152  };
153 
154  struct response_t
155  {
156  std::vector<block_complete_entry> blocks;
160  std::vector<block_output_indices> output_indices;
161  bool untrusted;
162 
165  KV_SERIALIZE(start_height)
166  KV_SERIALIZE(current_height)
168  KV_SERIALIZE(output_indices)
171  };
172  typedef epee::misc_utils::struct_init<response_t> response;
173  };
174 
176  {
177  struct request_t
178  {
179  std::vector<uint64_t> heights;
181  KV_SERIALIZE(heights)
183  };
184  typedef epee::misc_utils::struct_init<request_t> request;
185 
186  struct response_t
187  {
188  std::vector<block_complete_entry> blocks;
190  bool untrusted;
191 
197  };
198  typedef epee::misc_utils::struct_init<response_t> response;
199  };
200 
202  {
203  struct request_t
204  {
207  };
209 
210  struct response_t
211  {
212  std::vector<std::string> blks_hashes;
214  bool untrusted;
215 
217  KV_SERIALIZE(blks_hashes)
221  };
222  typedef epee::misc_utils::struct_init<response_t> response;
223  };
225  {
226 
227  struct request_t
228  {
229  std::list<crypto::hash> block_ids; //*first 10 blocks id goes sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
233  KV_SERIALIZE(start_height)
235  };
236  typedef epee::misc_utils::struct_init<request_t> request;
237 
238  struct response_t
239  {
240  std::vector<crypto::hash> m_block_ids;
244  bool untrusted;
245 
248  KV_SERIALIZE(start_height)
249  KV_SERIALIZE(current_height)
253  };
254  typedef epee::misc_utils::struct_init<response_t> response;
255  };
256 
257  //-----------------------------------------------
259  {
260  struct request_t
261  {
262  std::vector<std::string> amounts;
264 
266  KV_SERIALIZE(amounts)
269  };
270  typedef epee::misc_utils::struct_init<request_t> request;
271 
272 
273  struct output {
276  std::string rct; // 64+64+64 characters long (<rct commit> + <encrypted mask> + <rct amount>)
277 
280  KV_SERIALIZE(global_index)
281  KV_SERIALIZE(rct)
283  };
284 
285  struct amount_out {
287  std::vector<output> outputs;
289  KV_SERIALIZE(amount)
290  KV_SERIALIZE(outputs)
292 
293  };
294 
295  struct response_t
296  {
297  std::vector<amount_out> amount_outs;
300  KV_SERIALIZE(amount_outs)
301  KV_SERIALIZE(Error)
303  };
304  typedef epee::misc_utils::struct_init<response_t> response;
305  };
306  //-----------------------------------------------
308  {
309  struct request_t
310  {
314 
317  KV_SERIALIZE(view_key)
318  KV_SERIALIZE(tx)
320  };
321  typedef epee::misc_utils::struct_init<request_t> request;
322 
323 
324  struct response_t
325  {
328 
333  };
334  typedef epee::misc_utils::struct_init<response_t> response;
335  };
336  //-----------------------------------------------
338  {
339  struct request_t
340  {
341  std::vector<std::string> txs_hashes;
343  bool prune;
344  bool split;
345 
347  KV_SERIALIZE(txs_hashes)
348  KV_SERIALIZE(decode_as_json)
349  KV_SERIALIZE_OPT(prune, false)
350  KV_SERIALIZE_OPT(split, false)
352  };
353  typedef epee::misc_utils::struct_init<request_t> request;
354 
355  struct entry
356  {
363  bool in_pool;
367  std::vector<uint64_t> output_indices;
368  bool relayed;
370 
372  KV_SERIALIZE(tx_hash)
373  KV_SERIALIZE(as_hex)
374  KV_SERIALIZE(pruned_as_hex)
375  KV_SERIALIZE(prunable_as_hex)
376  KV_SERIALIZE(prunable_hash)
377  KV_SERIALIZE(as_json)
378  KV_SERIALIZE(in_pool)
379  KV_SERIALIZE(double_spend_seen)
380  if (!this_ref.in_pool)
381  {
382  KV_SERIALIZE(block_height)
383  KV_SERIALIZE(block_timestamp)
384  KV_SERIALIZE(output_indices)
385  }
386  else
387  {
388  KV_SERIALIZE(relayed)
389  }
390  KV_SERIALIZE(nonexistent_utxo_seen)
392  };
393 
394  struct response_t
395  {
396  // older compatibility stuff
397  std::vector<std::string> txs_as_hex; //transactions blobs as hex (old compat)
398  std::vector<std::string> txs_as_json; //transactions decoded as json (old compat)
399 
400  // in both old and new
401  std::vector<std::string> missed_tx; //not found transactions
402 
403  // new style
404  std::vector<entry> txs;
406  bool untrusted;
407 
409  KV_SERIALIZE(txs_as_hex)
410  KV_SERIALIZE(txs_as_json)
411  KV_SERIALIZE(txs)
412  KV_SERIALIZE(missed_tx)
416  };
417  typedef epee::misc_utils::struct_init<response_t> response;
418  };
419 
420  //-----------------------------------------------
422  {
423  enum STATUS {
424  UNSPENT = 0,
427  };
428 
429  struct request_t
430  {
431  std::vector<std::string> key_images;
432 
434  KV_SERIALIZE(key_images)
436  };
437  typedef epee::misc_utils::struct_init<request_t> request;
438 
439 
440  struct response_t
441  {
442  std::vector<u_int> spent_status;
444  bool untrusted;
445 
447  KV_SERIALIZE(spent_status)
451  };
452  typedef epee::misc_utils::struct_init<response_t> response;
453  };
454 
455  //-----------------------------------------------
457  {
458  struct request_t
459  {
464  };
465  typedef epee::misc_utils::struct_init<request_t> request;
466 
467 
468  struct response_t
469  {
470  std::vector<uint64_t> o_indexes;
472  bool untrusted;
474  KV_SERIALIZE(o_indexes)
478  };
479  typedef epee::misc_utils::struct_init<response_t> response;
480  };
481  //-----------------------------------------------
483  {
486 
488  KV_SERIALIZE(amount)
489  KV_SERIALIZE(index)
491  };
492 
494  {
495  struct request_t
496  {
497  std::vector<get_outputs_out> outputs;
498  bool get_txid;
499 
501  KV_SERIALIZE(outputs)
502  KV_SERIALIZE_OPT(get_txid, true)
504  };
505  typedef epee::misc_utils::struct_init<request_t> request;
506 
507  struct outkey
508  {
511  bool unlocked;
514 
518  KV_SERIALIZE(unlocked)
522  };
523 
524  struct response_t
525  {
526  std::vector<outkey> outs;
528  bool untrusted;
529 
531  KV_SERIALIZE(outs)
535  };
536  typedef epee::misc_utils::struct_init<response_t> response;
537  };
538  //-----------------------------------------------
540  {
541  struct request_t
542  {
543  std::vector<get_outputs_out> outputs;
544  bool get_txid;
545 
547  KV_SERIALIZE(outputs)
548  KV_SERIALIZE(get_txid)
550  };
551  typedef epee::misc_utils::struct_init<request_t> request;
552 
553  struct outkey
554  {
557  bool unlocked;
560 
563  KV_SERIALIZE(mask)
564  KV_SERIALIZE(unlocked)
566  KV_SERIALIZE(txid)
568  };
569 
570  struct response_t
571  {
572  std::vector<outkey> outs;
574  bool untrusted;
575 
577  KV_SERIALIZE(outs)
581  };
582  typedef epee::misc_utils::struct_init<response_t> response;
583  };
584  //-----------------------------------------------
586  {
587  struct request_t
588  {
592 
594  KV_SERIALIZE(tx_as_hex)
595  KV_SERIALIZE_OPT(do_not_relay, false)
596  KV_SERIALIZE_OPT(do_sanity_checks, true)
598  };
599  typedef epee::misc_utils::struct_init<request_t> request;
600 
601 
602  struct response_t
603  {
607  bool low_mixin;
611  bool too_big;
612  bool overspend;
614  bool not_rct;
616  bool untrusted;
617 
620  KV_SERIALIZE(reason)
621  KV_SERIALIZE(not_relayed)
622  KV_SERIALIZE(low_mixin)
623  KV_SERIALIZE(double_spend)
624  KV_SERIALIZE(invalid_input)
625  KV_SERIALIZE(invalid_output)
626  KV_SERIALIZE(too_big)
627  KV_SERIALIZE(overspend)
628  KV_SERIALIZE(fee_too_low)
629  KV_SERIALIZE(not_rct)
630  KV_SERIALIZE(sanity_check_failed)
633  };
634  typedef epee::misc_utils::struct_init<response_t> response;
635  };
636  //-----------------------------------------------
638  {
639  struct request_t
640  {
645 
647  KV_SERIALIZE(miner_address)
648  KV_SERIALIZE(threads_count)
649  KV_SERIALIZE(do_background_mining)
650  KV_SERIALIZE(ignore_battery)
652  };
653  typedef epee::misc_utils::struct_init<request_t> request;
654 
655  struct response_t
656  {
658 
662  };
663  typedef epee::misc_utils::struct_init<response_t> response;
664  };
665  //-----------------------------------------------
667  {
668  struct request_t
669  {
670 
673  };
675 
676  struct response_t
677  {
693  bool mainnet;
694  bool testnet;
695  bool stagenet;
707  bool offline;
708  bool untrusted;
715 
720 
724  KV_SERIALIZE(target_height)
725  KV_SERIALIZE(difficulty)
726  KV_SERIALIZE(wide_difficulty)
727  KV_SERIALIZE(difficulty_top64)
728  KV_SERIALIZE(target)
729  KV_SERIALIZE(tx_count)
730  KV_SERIALIZE(tx_pool_size)
731  KV_SERIALIZE(alt_blocks_count)
732  KV_SERIALIZE(outgoing_connections_count)
733  KV_SERIALIZE(incoming_connections_count)
734  KV_SERIALIZE(rpc_connections_count)
735  KV_SERIALIZE(white_peerlist_size)
736  KV_SERIALIZE(grey_peerlist_size)
737  KV_SERIALIZE(mainnet)
738  KV_SERIALIZE(testnet)
739  KV_SERIALIZE(stagenet)
740  KV_SERIALIZE(nettype)
741  KV_SERIALIZE(top_block_hash)
742  KV_SERIALIZE(cumulative_difficulty)
743  KV_SERIALIZE(wide_cumulative_difficulty)
744  KV_SERIALIZE(cumulative_difficulty_top64)
745  KV_SERIALIZE(block_size_limit)
746  KV_SERIALIZE_OPT(block_weight_limit, (uint64_t)0)
747  KV_SERIALIZE(block_size_median)
748  KV_SERIALIZE_OPT(block_weight_median, (uint64_t)0)
749  KV_SERIALIZE(start_time)
750  KV_SERIALIZE(free_space)
751  KV_SERIALIZE(offline)
753  KV_SERIALIZE(bootstrap_daemon_address)
754  KV_SERIALIZE(height_without_bootstrap)
755  KV_SERIALIZE(was_bootstrap_ever_used)
756  KV_SERIALIZE(database_size)
757  KV_SERIALIZE(update_available)
759 
760  KV_SERIALIZE(daemon_release_name)
761  KV_SERIALIZE(daemon_version)
762  KV_SERIALIZE(daemon_version_full)
763  KV_SERIALIZE(daemon_version_tag)
765  };
766  typedef epee::misc_utils::struct_init<response_t> response;
767  };
768 
769 
770  //-----------------------------------------------
772  {
773  struct request_t
774  {
775 
778  };
780 
781 
782  struct response_t
783  {
790 
793  KV_SERIALIZE(start_time)
794  KV_SERIALIZE(total_packets_in)
795  KV_SERIALIZE(total_bytes_in)
796  KV_SERIALIZE(total_packets_out)
797  KV_SERIALIZE(total_bytes_out)
799  };
800  typedef epee::misc_utils::struct_init<response_t> response;
801  };
802 
803  //-----------------------------------------------
805  {
806  struct request_t
807  {
808 
811  };
813 
814 
815  struct response_t
816  {
818 
822  };
823  typedef epee::misc_utils::struct_init<response_t> response;
824  };
825 
826  //-----------------------------------------------
828  {
829  struct request_t
830  {
831 
834  };
836 
837 
838  struct response_t
839  {
841  bool active;
856 
859  KV_SERIALIZE(active)
860  KV_SERIALIZE(speed)
861  KV_SERIALIZE(threads_count)
863  KV_SERIALIZE(pow_algorithm)
864  KV_SERIALIZE(is_background_mining_enabled)
865  KV_SERIALIZE(bg_idle_threshold)
866  KV_SERIALIZE(bg_min_idle_seconds)
867  KV_SERIALIZE(bg_ignore_battery)
868  KV_SERIALIZE(bg_target)
869  KV_SERIALIZE(block_target)
870  KV_SERIALIZE(block_reward)
871  KV_SERIALIZE(difficulty)
872  KV_SERIALIZE(wide_difficulty)
873  KV_SERIALIZE(difficulty_top64)
875  };
876  typedef epee::misc_utils::struct_init<response_t> response;
877  };
878 
879  //-----------------------------------------------
881  {
882  struct request_t
883  {
884 
887  };
889 
890 
891  struct response_t
892  {
894 
898  };
899  typedef epee::misc_utils::struct_init<response_t> response;
900  };
901 
902  //
904  {
905  typedef std::list<std::string> request;
906 
907  struct response_t
908  {
911 
916  };
917  typedef epee::misc_utils::struct_init<response_t> response;
918  };
919 
921  {
922  typedef std::vector<uint64_t> request;
923 
925  };
926 
927 
929  {
930  struct request_t
931  {
932  uint64_t reserve_size; //max 255 bytes
935 
937  KV_SERIALIZE(reserve_size)
938  KV_SERIALIZE(wallet_address)
939  KV_SERIALIZE(prev_block)
941  };
942  typedef epee::misc_utils::struct_init<request_t> request;
943 
944  struct response_t
945  {
956  bool untrusted;
957 
959  KV_SERIALIZE(difficulty)
960  KV_SERIALIZE(wide_difficulty)
961  KV_SERIALIZE(difficulty_top64)
963  KV_SERIALIZE(reserved_offset)
964  KV_SERIALIZE(expected_reward)
965  KV_SERIALIZE(prev_hash)
966  KV_SERIALIZE(blocktemplate_blob)
967  KV_SERIALIZE(blockhashing_blob)
971  };
972  typedef epee::misc_utils::struct_init<response_t> response;
973  };
974 
976  {
977  typedef std::vector<std::string> request;
978 
979  struct response_t
980  {
982 
986  };
987  typedef epee::misc_utils::struct_init<response_t> response;
988  };
989 
991  {
992  struct request_t
993  {
998 
1000  KV_SERIALIZE(amount_of_blocks)
1001  KV_SERIALIZE(wallet_address)
1002  KV_SERIALIZE(prev_block)
1003  KV_SERIALIZE_OPT(starting_nonce, (uint32_t)0)
1005  };
1006  typedef epee::misc_utils::struct_init<request_t> request;
1007 
1008  struct response_t
1009  {
1011  std::vector<std::string> blocks;
1013 
1019  };
1020  typedef epee::misc_utils::struct_init<response_t> response;
1021  };
1022 
1024  {
1047 
1049  KV_SERIALIZE(major_version)
1050  KV_SERIALIZE(minor_version)
1051  KV_SERIALIZE(timestamp)
1052  KV_SERIALIZE(prev_hash)
1053  KV_SERIALIZE(nonce)
1054  KV_SERIALIZE(orphan_status)
1056  KV_SERIALIZE(depth)
1058  KV_SERIALIZE(difficulty)
1059  KV_SERIALIZE(wide_difficulty)
1060  KV_SERIALIZE(difficulty_top64)
1061  KV_SERIALIZE(cumulative_difficulty)
1062  KV_SERIALIZE(wide_cumulative_difficulty)
1063  KV_SERIALIZE(cumulative_difficulty_top64)
1064  KV_SERIALIZE(reward)
1065  KV_SERIALIZE(block_size)
1066  KV_SERIALIZE_OPT(block_weight, (uint64_t)0)
1067  KV_SERIALIZE(num_txes)
1068  KV_SERIALIZE(pow_hash)
1069  KV_SERIALIZE_OPT(long_term_weight, (uint64_t)0)
1070  KV_SERIALIZE(miner_tx_hash)
1072  };
1073 
1075  {
1076  struct request_t
1077  {
1079 
1081  KV_SERIALIZE_OPT(fill_pow_hash, false);
1083  };
1084  typedef epee::misc_utils::struct_init<request_t> request;
1085 
1086  struct response_t
1087  {
1091 
1097  };
1098  typedef epee::misc_utils::struct_init<response_t> response;
1099 
1100  };
1101 
1103  {
1104  struct request_t
1105  {
1108 
1111  KV_SERIALIZE_OPT(fill_pow_hash, false);
1113  };
1114  typedef epee::misc_utils::struct_init<request_t> request;
1115 
1116  struct response_t
1117  {
1121 
1127  };
1128  typedef epee::misc_utils::struct_init<response_t> response;
1129  };
1130 
1132  {
1133  struct request_t
1134  {
1137 
1140  KV_SERIALIZE_OPT(fill_pow_hash, false);
1142  };
1143  typedef epee::misc_utils::struct_init<request_t> request;
1144 
1145  struct response_t
1146  {
1150 
1156  };
1157  typedef epee::misc_utils::struct_init<response_t> response;
1158  };
1159 
1161  {
1162  struct request_t
1163  {
1167 
1171  KV_SERIALIZE_OPT(fill_pow_hash, false);
1173  };
1174  typedef epee::misc_utils::struct_init<request_t> request;
1175 
1176  struct response_t
1177  {
1181  std::vector<std::string> tx_hashes;
1185 
1188  KV_SERIALIZE(miner_tx_hash)
1189  KV_SERIALIZE(tx_hashes)
1191  KV_SERIALIZE(blob)
1195  };
1196  typedef epee::misc_utils::struct_init<response_t> response;
1197  };
1198 
1199  struct peer {
1207 
1208  peer() = default;
1209 
1210  peer(uint64_t id, const std::string &host, uint64_t last_seen, uint32_t pruning_seed, uint16_t rpc_port)
1211  : id(id), host(host), ip(0), port(0), rpc_port(rpc_port), last_seen(last_seen), pruning_seed(pruning_seed)
1212  {}
1213  peer(uint64_t id, uint32_t ip, uint16_t port, uint64_t last_seen, uint32_t pruning_seed, uint16_t rpc_port)
1214  : id(id), host(std::to_string(ip)), ip(ip), port(port), rpc_port(rpc_port), last_seen(last_seen), pruning_seed(pruning_seed)
1215  {}
1216 
1218  KV_SERIALIZE(id)
1219  KV_SERIALIZE(host)
1220  KV_SERIALIZE(ip)
1222  KV_SERIALIZE_OPT(rpc_port, (uint16_t)0)
1223  KV_SERIALIZE(last_seen)
1224  KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
1226  };
1227 
1229  {
1230  struct request_t
1231  {
1234  };
1236 
1237  struct response_t
1238  {
1240  std::vector<peer> white_list;
1241  std::vector<peer> gray_list;
1242 
1245  KV_SERIALIZE(white_list)
1246  KV_SERIALIZE(gray_list)
1248  };
1249  typedef epee::misc_utils::struct_init<response_t> response;
1250  };
1251 
1253  {
1254  struct request_t
1255  {
1256  bool visible;
1257 
1259  KV_SERIALIZE(visible)
1261  };
1262  typedef epee::misc_utils::struct_init<request_t> request;
1263 
1264  struct response_t
1265  {
1270  };
1271  typedef epee::misc_utils::struct_init<response_t> response;
1272  };
1273 
1275  {
1276  struct request_t
1277  {
1279 
1281  KV_SERIALIZE(level)
1283  };
1284  typedef epee::misc_utils::struct_init<request_t> request;
1285 
1286  struct response_t
1287  {
1292  };
1293  typedef epee::misc_utils::struct_init<response_t> response;
1294  };
1295 
1297  {
1298  struct request_t
1299  {
1301 
1303  KV_SERIALIZE(categories)
1305  };
1306  typedef epee::misc_utils::struct_init<request_t> request;
1307 
1308  struct response_t
1309  {
1312 
1315  KV_SERIALIZE(categories)
1317  };
1318  typedef epee::misc_utils::struct_init<response_t> response;
1319  };
1320 
1321  struct tx_info
1322  {
1324  std::string tx_json; // TODO - expose this data directly
1334  bool relayed;
1340 
1342  KV_SERIALIZE(id_hash)
1343  KV_SERIALIZE(tx_json)
1344  KV_SERIALIZE(blob_size)
1345  KV_SERIALIZE_OPT(weight, (uint64_t)0)
1346  KV_SERIALIZE(fee)
1347  KV_SERIALIZE(max_used_block_id_hash)
1348  KV_SERIALIZE(max_used_block_height)
1349  KV_SERIALIZE(kept_by_block)
1350  KV_SERIALIZE(last_failed_height)
1351  KV_SERIALIZE(last_failed_id_hash)
1352  KV_SERIALIZE(receive_time)
1353  KV_SERIALIZE(relayed)
1354  KV_SERIALIZE(last_relayed_time)
1355  KV_SERIALIZE(do_not_relay)
1356  KV_SERIALIZE(double_spend_seen)
1357  KV_SERIALIZE(tx_blob)
1358  KV_SERIALIZE(nonexistent_utxo_seen)
1360  };
1361 
1363  {
1365  std::vector<std::string> txs_hashes;
1366 
1368  KV_SERIALIZE(id_hash)
1369  KV_SERIALIZE(txs_hashes)
1371  };
1372 
1374  {
1375  struct request_t
1376  {
1379  };
1381 
1382  struct response_t
1383  {
1385  std::vector<tx_info> transactions;
1386  std::vector<spent_key_image_info> spent_key_images;
1388 
1391  KV_SERIALIZE(transactions)
1392  KV_SERIALIZE(spent_key_images)
1395  };
1396  typedef epee::misc_utils::struct_init<response_t> response;
1397  };
1398 
1400  {
1401  struct request_t
1402  {
1405  };
1407 
1408  struct response_t
1409  {
1411  std::vector<crypto::hash> tx_hashes;
1413 
1419  };
1420  typedef epee::misc_utils::struct_init<response_t> response;
1421  };
1422 
1424  {
1425  struct request_t
1426  {
1429  };
1431 
1432  struct response_t
1433  {
1435  std::vector<std::string> tx_hashes;
1437 
1440  KV_SERIALIZE(tx_hashes)
1443  };
1444  typedef epee::misc_utils::struct_init<response_t> response;
1445  };
1446 
1448  {
1452  };
1453 
1455  {
1456  struct request_t
1457  {
1460  };
1462 
1463  struct response_t
1464  {
1466  std::vector<tx_backlog_entry> backlog;
1468 
1474  };
1475  typedef epee::misc_utils::struct_init<response_t> response;
1476  };
1477 
1479  {
1482 
1484  KV_SERIALIZE(txs)
1485  KV_SERIALIZE(bytes)
1487  };
1488 
1490  {
1502  std::vector<txpool_histo> histo;
1505 
1506  txpool_stats(): bytes_total(0), bytes_min(0), bytes_max(0), bytes_med(0), fee_total(0), oldest(0), txs_total(0), num_failing(0), num_10m(0), num_not_relayed(0), histo_98pc(0), num_double_spends(0), num_nonexistent_utxos(0) {}
1507 
1509  KV_SERIALIZE(bytes_total)
1510  KV_SERIALIZE(bytes_min)
1511  KV_SERIALIZE(bytes_max)
1512  KV_SERIALIZE(bytes_med)
1513  KV_SERIALIZE(fee_total)
1514  KV_SERIALIZE(oldest)
1515  KV_SERIALIZE(txs_total)
1516  KV_SERIALIZE(num_failing)
1517  KV_SERIALIZE(num_10m)
1518  KV_SERIALIZE(num_not_relayed)
1519  KV_SERIALIZE(histo_98pc)
1521  KV_SERIALIZE(num_double_spends)
1522  KV_SERIALIZE(num_nonexistent_utxos)
1524  };
1525 
1527  {
1528  struct request_t
1529  {
1532  };
1534 
1535  struct response_t
1536  {
1540 
1543  KV_SERIALIZE(pool_stats)
1546  };
1547  typedef epee::misc_utils::struct_init<response_t> response;
1548  };
1549 
1551  {
1552  struct request_t
1553  {
1556  KV_SERIALIZE(etn_address)
1558  };
1559  typedef epee::misc_utils::struct_init<request_t> request;
1560 
1561  struct response_t
1562  {
1565 
1567  KV_SERIALIZE(balance)
1570  };
1571  typedef epee::misc_utils::struct_init<response_t> response;
1572  };
1573 
1575  {
1576  struct request_t
1577  {
1581  bool desc;
1583  KV_SERIALIZE(etn_address)
1584  KV_SERIALIZE(start_out_id)
1585  KV_SERIALIZE(batch_size)
1588  };
1589  typedef epee::misc_utils::struct_init<request_t> request;
1590 
1591  struct response_t
1592  {
1596  std::vector<std::string> txs;
1597 
1600  KV_SERIALIZE(next_out_id)
1601  KV_SERIALIZE(last_page)
1602  KV_SERIALIZE(txs)
1604  };
1605  typedef epee::misc_utils::struct_init<response_t> response;
1606  };
1607 
1609  {
1610  struct request_t
1611  {
1614  };
1616 
1617  struct response_t
1618  {
1620  std::list<connection_info> connections;
1621 
1624  KV_SERIALIZE(connections)
1626  };
1627  typedef epee::misc_utils::struct_init<response_t> response;
1628  };
1629 
1631  {
1632  struct request_t
1633  {
1637 
1639  KV_SERIALIZE(start_height)
1640  KV_SERIALIZE(end_height)
1641  KV_SERIALIZE_OPT(fill_pow_hash, false);
1643  };
1644  typedef epee::misc_utils::struct_init<request_t> request;
1645 
1646  struct response_t
1647  {
1649  std::vector<block_header_response> headers;
1651 
1654  KV_SERIALIZE(headers)
1657  };
1658  typedef epee::misc_utils::struct_init<response_t> response;
1659  };
1660 
1662  {
1663  struct request_t
1664  {
1667  };
1669 
1670  struct response_t
1671  {
1673 
1677  };
1678  typedef epee::misc_utils::struct_init<response_t> response;
1679  };
1680 
1682  {
1683  struct request_t
1684  {
1687  };
1689 
1690  struct response_t
1691  {
1693 
1697  };
1698  typedef epee::misc_utils::struct_init<response_t> response;
1699  };
1700 
1702  {
1703  struct request_t
1704  {
1707  };
1709 
1710  struct response_t
1711  {
1716 
1719  KV_SERIALIZE(limit_up)
1720  KV_SERIALIZE(limit_down)
1723  };
1724  typedef epee::misc_utils::struct_init<response_t> response;
1725  };
1726 
1728  {
1729  struct request_t
1730  {
1731  int64_t limit_down; // all limits (for get and set) are kB/s
1733 
1735  KV_SERIALIZE(limit_down)
1736  KV_SERIALIZE(limit_up)
1738  };
1739  typedef epee::misc_utils::struct_init<request_t> request;
1740 
1741  struct response_t
1742  {
1746 
1749  KV_SERIALIZE(limit_up)
1750  KV_SERIALIZE(limit_down)
1752  };
1753  typedef epee::misc_utils::struct_init<response_t> response;
1754  };
1755 
1757  {
1758  struct request_t
1759  {
1762  KV_SERIALIZE(out_peers)
1764  };
1765  typedef epee::misc_utils::struct_init<request_t> request;
1766 
1767  struct response_t
1768  {
1770 
1774  };
1775  typedef epee::misc_utils::struct_init<response_t> response;
1776  };
1777 
1779  {
1780  struct request_t
1781  {
1784  KV_SERIALIZE(in_peers)
1786  };
1787  typedef epee::misc_utils::struct_init<request_t> request;
1788 
1789  struct response_t
1790  {
1792 
1796  };
1797  typedef epee::misc_utils::struct_init<response_t> response;
1798  };
1799 
1801  {
1802  struct request_t
1803  {
1806  };
1808 
1809  struct response_t
1810  {
1812 
1816  };
1817  typedef epee::misc_utils::struct_init<response_t> response;
1818  };
1819 
1821  {
1822  struct request_t
1823  {
1826  };
1828 
1829  struct response_t
1830  {
1832 
1836  };
1837  typedef epee::misc_utils::struct_init<response_t> response;
1838  };
1839 
1841  {
1842  struct request_t
1843  {
1845 
1849  };
1850  typedef epee::misc_utils::struct_init<request_t> request;
1851 
1852  struct response_t
1853  {
1855  bool enabled;
1864 
1867  KV_SERIALIZE(enabled)
1868  KV_SERIALIZE(window)
1869  KV_SERIALIZE(votes)
1871  KV_SERIALIZE(voting)
1873  KV_SERIALIZE(earliest_height)
1877  };
1878  typedef epee::misc_utils::struct_init<response_t> response;
1879  };
1880 
1882  {
1883  struct ban
1884  {
1888 
1890  KV_SERIALIZE(host)
1891  KV_SERIALIZE(ip)
1892  KV_SERIALIZE(seconds)
1894  };
1895 
1896  struct request_t
1897  {
1900  };
1902 
1903  struct response_t
1904  {
1906  std::vector<ban> bans;
1907 
1910  KV_SERIALIZE(bans)
1912  };
1913  typedef epee::misc_utils::struct_init<response_t> response;
1914  };
1915 
1917  {
1918  struct ban
1919  {
1922  bool ban;
1924 
1926  KV_SERIALIZE(host)
1927  KV_SERIALIZE(ip)
1928  KV_SERIALIZE(ban)
1929  KV_SERIALIZE(seconds)
1931  };
1932 
1933  struct request_t
1934  {
1935  std::vector<ban> bans;
1936 
1938  KV_SERIALIZE(bans)
1940  };
1941  typedef epee::misc_utils::struct_init<request_t> request;
1942 
1943  struct response_t
1944  {
1946 
1950  };
1951  typedef epee::misc_utils::struct_init<response_t> response;
1952  };
1953 
1955  {
1956  struct request_t
1957  {
1958  std::vector<std::string> txids;
1959 
1961  KV_SERIALIZE(txids)
1963  };
1964  typedef epee::misc_utils::struct_init<request_t> request;
1965 
1966  struct response_t
1967  {
1969 
1973  };
1974  typedef epee::misc_utils::struct_init<response_t> response;
1975  };
1976 
1978  {
1979  struct request_t
1980  {
1981  std::vector<uint64_t> amounts;
1984  bool unlocked;
1986 
1988  KV_SERIALIZE(amounts);
1989  KV_SERIALIZE(min_count);
1990  KV_SERIALIZE(max_count);
1991  KV_SERIALIZE(unlocked);
1992  KV_SERIALIZE(recent_cutoff);
1994  };
1995  typedef epee::misc_utils::struct_init<request_t> request;
1996 
1997  struct entry
1998  {
2003 
2005  KV_SERIALIZE(amount);
2006  KV_SERIALIZE(total_instances);
2007  KV_SERIALIZE(unlocked_instances);
2008  KV_SERIALIZE(recent_instances);
2010 
2011  entry(uint64_t amount, uint64_t total_instances, uint64_t unlocked_instances, uint64_t recent_instances):
2012  amount(amount), total_instances(total_instances), unlocked_instances(unlocked_instances), recent_instances(recent_instances) {}
2013  entry() {}
2014  };
2015 
2016  struct response_t
2017  {
2019  std::vector<entry> histogram;
2021 
2024  KV_SERIALIZE(histogram)
2027  };
2028  typedef epee::misc_utils::struct_init<response_t> response;
2029  };
2030 
2032  {
2033  struct request_t
2034  {
2037  };
2039 
2040  struct response_t
2041  {
2045 
2051  };
2052  typedef epee::misc_utils::struct_init<response_t> response;
2053  };
2054 
2056  {
2057  struct request_t
2058  {
2061 
2066  };
2067  typedef epee::misc_utils::struct_init<request_t> request;
2068 
2069  struct response_t
2070  {
2074 
2077  KV_SERIALIZE(emission_amount)
2078  KV_SERIALIZE(fee_amount)
2080  };
2081  typedef epee::misc_utils::struct_init<response_t> response;
2082  };
2083 
2085  {
2086  struct request_t
2087  {
2089 
2091  KV_SERIALIZE(grace_blocks)
2093  };
2094  typedef epee::misc_utils::struct_init<request_t> request;
2095 
2096  struct response_t
2097  {
2102 
2105  KV_SERIALIZE(fee)
2106  KV_SERIALIZE_OPT(quantization_mask, (uint64_t)1)
2109  };
2110  typedef epee::misc_utils::struct_init<response_t> response;
2111  };
2112 
2114  {
2115  struct request_t
2116  {
2119  };
2121 
2122  struct chain_info
2123  {
2130  std::vector<std::string> block_hashes;
2132 
2134  KV_SERIALIZE(block_hash)
2136  KV_SERIALIZE(length)
2137  KV_SERIALIZE(difficulty)
2138  KV_SERIALIZE(wide_difficulty)
2139  KV_SERIALIZE(difficulty_top64)
2140  KV_SERIALIZE(block_hashes)
2141  KV_SERIALIZE(main_chain_parent_block)
2143  };
2144 
2145  struct response_t
2146  {
2148  std::list<chain_info> chains;
2149 
2152  KV_SERIALIZE(chains)
2154  };
2155  typedef epee::misc_utils::struct_init<response_t> response;
2156  };
2157 
2159  {
2160  struct request_t
2161  {
2164 
2166  KV_SERIALIZE(command);
2169  };
2170  typedef epee::misc_utils::struct_init<request_t> request;
2171 
2172  struct response_t
2173  {
2175  bool update;
2181 
2184  KV_SERIALIZE(update)
2186  KV_SERIALIZE(user_uri)
2187  KV_SERIALIZE(auto_uri)
2189  KV_SERIALIZE(path)
2191  };
2192  typedef epee::misc_utils::struct_init<response_t> response;
2193  };
2194 
2196  {
2197  struct request_t
2198  {
2199  std::vector<std::string> txids;
2200 
2202  KV_SERIALIZE(txids)
2204  };
2205  typedef epee::misc_utils::struct_init<request_t> request;
2206 
2207  struct response_t
2208  {
2210 
2214  };
2215  typedef epee::misc_utils::struct_init<response_t> response;
2216  };
2217 
2219  {
2220  struct request_t
2221  {
2224  };
2226 
2227  struct peer
2228  {
2230 
2234  };
2235 
2236  struct span
2237  {
2245 
2247  KV_SERIALIZE(start_block_height)
2248  KV_SERIALIZE(nblocks)
2249  KV_SERIALIZE(connection_id)
2250  KV_SERIALIZE(rate)
2251  KV_SERIALIZE(speed)
2252  KV_SERIALIZE(size)
2253  KV_SERIALIZE(remote_address)
2255  };
2256 
2257  struct response_t
2258  {
2263  std::list<peer> peers;
2264  std::list<span> spans;
2266 
2270  KV_SERIALIZE(target_height)
2271  KV_SERIALIZE(next_needed_pruning_seed)
2272  KV_SERIALIZE(peers)
2273  KV_SERIALIZE(spans)
2274  KV_SERIALIZE(overview)
2276  };
2277  typedef epee::misc_utils::struct_init<response_t> response;
2278  };
2279 
2281  {
2282  struct request_t
2283  {
2284  std::vector<uint64_t> amounts;
2288  bool binary;
2289  bool compress;
2290 
2292  KV_SERIALIZE(amounts)
2293  KV_SERIALIZE_OPT(from_height, (uint64_t)0)
2294  KV_SERIALIZE_OPT(to_height, (uint64_t)0)
2295  KV_SERIALIZE_OPT(cumulative, false)
2296  KV_SERIALIZE_OPT(binary, true)
2297  KV_SERIALIZE_OPT(compress, false)
2299  };
2300  typedef epee::misc_utils::struct_init<request_t> request;
2301 
2303  {
2307  bool binary;
2308  bool compress;
2309 
2311  KV_SERIALIZE(amount)
2312  KV_SERIALIZE_N(data.start_height, "start_height")
2313  KV_SERIALIZE(binary)
2314  KV_SERIALIZE(compress)
2315  if (this_ref.binary)
2316  {
2317  if (is_store)
2318  {
2319  if (this_ref.compress)
2320  {
2321  const_cast<std::string&>(this_ref.compressed_data) = compress_integer_array(this_ref.data.distribution);
2322  KV_SERIALIZE(compressed_data)
2323  }
2324  else
2326  }
2327  else
2328  {
2329  if (this_ref.compress)
2330  {
2331  KV_SERIALIZE(compressed_data)
2332  const_cast<std::vector<uint64_t>&>(this_ref.data.distribution) = decompress_integer_array<uint64_t>(this_ref.compressed_data);
2333  }
2334  else
2336  }
2337  }
2338  else
2339  KV_SERIALIZE_N(data.distribution, "distribution")
2340  KV_SERIALIZE_N(data.base, "base")
2342  };
2343 
2344  struct response_t
2345  {
2347  std::vector<distribution> distributions;
2349 
2352  KV_SERIALIZE(distributions)
2355  };
2356  typedef epee::misc_utils::struct_init<response_t> response;
2357  };
2358 
2360  {
2361  struct request_t
2362  {
2364 
2366  KV_SERIALIZE(nblocks);
2368  };
2369  typedef epee::misc_utils::struct_init<request_t> request;
2370 
2371  struct response_t
2372  {
2375 
2380  };
2381  typedef epee::misc_utils::struct_init<response_t> response;
2382  };
2383 
2385  {
2386  struct request_t
2387  {
2388  bool check;
2389 
2391  KV_SERIALIZE_OPT(check, false)
2393  };
2394  typedef epee::misc_utils::struct_init<request_t> request;
2395 
2396  struct response_t
2397  {
2398  bool pruned;
2401 
2404  KV_SERIALIZE(pruned)
2405  KV_SERIALIZE(pruning_seed)
2407  };
2408  typedef epee::misc_utils::struct_init<response_t> response;
2409  };
2410 
2412  {
2413  struct request_t
2414  {
2416 
2418  KV_SERIALIZE(validator_key)
2420  };
2421  typedef epee::misc_utils::struct_init<request_t> request;
2422 
2423  struct response_t
2424  {
2426 
2430  };
2431  typedef epee::misc_utils::struct_init<response_t> response;
2432  };
2433 
2435  {
2436  struct request_t
2437  {
2440  };
2442 
2443  struct response_t
2444  {
2448 
2454  };
2455  typedef epee::misc_utils::struct_init<response_t> response;
2456  };
2457 
2459  {
2460  struct request_t
2461  {
2464 
2469  };
2470  typedef epee::misc_utils::struct_init<request_t> request;
2471 
2472  struct response_t
2473  {
2476 
2481  };
2482  typedef epee::misc_utils::struct_init<response_t> response;
2483  };
2484 
2486  {
2487  struct request_t
2488  {
2490  int version = 0;
2491  std::vector<std::string> signatures;
2492  std::vector<std::string> pubkeys;
2493 
2495  KV_SERIALIZE(blob)
2497  KV_SERIALIZE(signatures)
2498  KV_SERIALIZE(pubkeys)
2500  };
2501  typedef epee::misc_utils::struct_init<request_t> request;
2502 
2503  struct response_t
2504  {
2507  };
2509  };
2510 
2511 }
return true
else if(0==res)
uint8_t threshold
Definition: blockchain.cpp:92
std::string publicKey
std::string privateKey
std::string message("Message requiring signing")
const uint32_t T[512]
const char * key
Definition: hmac_keccak.cpp:39
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
#define KV_SERIALIZE(varialble)
#define KV_SERIALIZE_CONTAINER_POD_AS_BLOB_N(varialble, val_name)
#define KV_SERIALIZE_OPT(variable, default_value)
#define KV_SERIALIZE_CONTAINER_POD_AS_BLOB(varialble)
#define END_KV_SERIALIZE_MAP()
#define BEGIN_KV_SERIALIZE_MAP()
#define KV_SERIALIZE_N(varialble, val_name)
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Definition: misc_log_ex.h:173
POD_CLASS signature
Definition: crypto.h:108
POD_CLASS public_key
Definition: crypto.h:76
POD_CLASS hash
Definition: hash.h:50
Holds cryptonote related classes and helpers.
Definition: ban.cpp:40
std::string blobdata
Definition: blobdatatype.h:39
std::string to_string(t_connection_type type)
mdb_size_t count(MDB_cursor *cur)
error
Tracks LMDB error codes.
Definition: error.h:45
version
Supported socks variants.
Definition: socks.h:58
::std::string string
Definition: gtest-port.h:1097
std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value, void >::type write_varint(OutputIt &&dest, T i)
writes a varint to a stream.
Definition: varint.h:70
boost::endian::big_uint16_t port
Definition: socks.cpp:60
boost::endian::big_uint32_t ip
Definition: socks.cpp:61
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
#define false
Definition: stdbool.h:38
unsigned short uint16_t
Definition: stdint.h:125
signed __int64 int64_t
Definition: stdint.h:135
unsigned int uint32_t
Definition: stdint.h:126
signed int int32_t
Definition: stdint.h:123
unsigned char uint8_t
Definition: stdint.h:124
unsigned __int64 uint64_t
Definition: stdint.h:136
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< response_t > response
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
peer(uint64_t id, const std::string &host, uint64_t last_seen, uint32_t pruning_seed, uint16_t rpc_port)
peer(uint64_t id, uint32_t ip, uint16_t port, uint64_t last_seen, uint32_t pruning_seed, uint16_t rpc_port)
std::vector< std::uint64_t > distribution
Definition: rpc_handler.h:46
uint64_t weight
uint64_t fee
uint64_t time_in_pool
std::vector< txpool_histo > histo
Definition: blake256.h:37
const char * address
Definition: multisig.cpp:37
rapidjson::Document json
Definition: transport.cpp:49
provides the implementation of varint's