From 3a792e9a8e10cb870f36b03ab4042473d3021192 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 9 Apr 2024 22:52:41 +0200 Subject: [PATCH] added wallet API complete documentation --- .../include/net/http_server_handlers_map2.h | 386 ++++++++------ .../serialization/keyvalue_serialization.h | 9 +- .../portable_storage_to_description.h | 17 +- src/common/command_line.cpp | 2 +- src/common/command_line.h | 4 +- src/currency_core/currency_basic.h | 10 +- src/currency_core/offers_service_basics.h | 85 ++-- src/daemon/daemon.cpp | 10 +- src/rpc/core_rpc_server_commands_defs.h | 10 +- src/simplewallet/simplewallet.cpp | 40 +- src/wallet/wallet_public_structs_defs.h | 481 ++++++++++-------- src/wallet/wallet_rpc_server.cpp | 2 +- src/wallet/wallet_rpc_server.h | 32 +- src/wallet/wallets_manager.cpp | 3 +- 14 files changed, 632 insertions(+), 459 deletions(-) diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h index 0200b558..1452aa57 100644 --- a/contrib/epee/include/net/http_server_handlers_map2.h +++ b/contrib/epee/include/net/http_server_handlers_map2.h @@ -34,148 +34,7 @@ -template -typename_t get_documentation_json_struct() -{ - return AUTO_VAL_INIT_T(typename_t); -} - - -template -bool auto_doc_t(const std::string& prefix_name, std::string& generate_reference) -{ - if (!generate_reference.size()) return true; - request_t req = get_documentation_json_struct(); - response_t res = get_documentation_json_struct(); - - std::string req_str; - std::string req_str_descr; - epee::serialization::portable_storage_extended_doc ps; - req.store(ps, nullptr); - ps.dump_as_json(req_str); - ps.dump_as_decriptions(req_str_descr); - - - std::string res_str; - std::string res_str_descr; - epee::serialization::portable_storage_extended_doc ps_res; - res.store(ps_res, nullptr); - ps_res.dump_as_json(res_str); - ps_res.dump_as_decriptions(res_str_descr); - - - std::stringstream ss; - ss << prefix_name << ENDL - << "REQUEST: " << ENDL << req_str << ENDL << req_str_descr << "--------------------------------" << ENDL - << "RESPONSE: " << ENDL << res_str << ENDL << res_str_descr << "################################" << ENDL; - generate_reference += ss.str(); - return true; -} - - -template -bool auto_doc(const std::string& prefix_name, std::string& generate_reference) -{ - return auto_doc_t(prefix_name, generate_reference); -} - -namespace epee { - namespace net_utils { - namespace http { - struct i_chain_handler - { - virtual bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, epee::net_utils::http::http_response_info& response_info, - epee::net_utils::connection_context_base& m_conn_context, bool& call_found, std::string& generate_reference) = 0; - }; - } - } -} - - - - -#define CHAIN_HTTP_TO_MAP2(context_type) bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \ - epee::net_utils::http::http_response_info& response, \ - context_type& m_conn_context) \ -{\ - response.m_response_code = 200; \ - response.m_response_comment = "Ok"; \ - std::string reference_stub; \ - bool call_found = false; \ - if(!handle_http_request_map(query_info, response, m_conn_context, call_found, reference_stub) && response.m_response_code == 200) \ - { response.m_response_code = 500; response.m_response_comment = "Internal Server Error"; return true; } \ - if (!call_found) \ - { response.m_response_code = 404; response.m_response_comment = "Not Found"; return true; } \ - return true; \ -} - -#define BEGIN_URI_MAP2() template bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \ - epee::net_utils::http::http_response_info& response_info, \ - t_context& m_conn_context, bool& call_found, std::string& generate_reference) { \ - call_found = false; \ - if(false) return true; //just a stub to have "else if" - -#define BEGIN_URI_MAP2_VIRTUAL() virtual bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \ - epee::net_utils::http::http_response_info& response_info, \ - epee::net_utils::connection_context_base& m_conn_context, bool& call_found, std::string& generate_reference) { \ - call_found = false; \ - if(false) return true; //just a stub to have "else if" - - -#define MAP_URI2(pattern, callback) else if(std::string::npos != query_info.m_URI.find(pattern)) return callback(query_info, response_info, m_conn_context); - -#define MAP_URI_AUTO_XML2(s_pattern, callback_f, command_type) //TODO: don't think i ever again will use xml - ambiguous and "overtagged" format - -#define MAP_URI_AUTO_JON2(s_pattern, callback_f, command_type) \ - else if(auto_doc(s_pattern "[JSON]", generate_reference) && query_info.m_URI == s_pattern) \ - { \ - call_found = true; \ - uint64_t ticks = misc_utils::get_tick_count(); \ - boost::value_initialized req; \ - bool res = epee::serialization::load_t_from_json(static_cast(req), query_info.m_body); \ - CHECK_AND_ASSERT_MES(res, false, "Failed to parse json: \r\n" << query_info.m_body); \ - uint64_t ticks1 = epee::misc_utils::get_tick_count(); \ - boost::value_initialized resp;\ - res = callback_f(static_cast(req), static_cast(resp), m_conn_context); \ - CHECK_AND_ASSERT_MES(res, false, "Failed to call " << #callback_f << "() while handling " << s_pattern); \ - uint64_t ticks2 = epee::misc_utils::get_tick_count(); \ - epee::serialization::store_t_to_json(static_cast(resp), response_info.m_body); \ - uint64_t ticks3 = epee::misc_utils::get_tick_count(); \ - response_info.m_mime_tipe = "application/json"; \ - response_info.m_header_info.m_content_type = " application/json"; \ - LOG_PRINT("[HTTP/JSON][" << epee::string_tools::get_ip_string_from_int32(m_conn_context.m_remote_ip ) << "][" << query_info.m_URI << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \ - } - -#define MAP_URI_AUTO_BIN2(s_pattern, callback_f, command_type) \ - else if(auto_doc(s_pattern "[BIN]", generate_reference) && query_info.m_URI == s_pattern) \ - { \ - call_found = true; \ - uint64_t ticks = misc_utils::get_tick_count(); \ - boost::value_initialized req; \ - bool res = epee::serialization::load_t_from_binary(static_cast(req), query_info.m_body); \ - CHECK_AND_ASSERT_MES(res, false, "Failed to parse bin body data, body size=" << query_info.m_body.size()); \ - uint64_t ticks1 = misc_utils::get_tick_count(); \ - boost::value_initialized resp;\ - res = callback_f(static_cast(req), static_cast(resp), m_conn_context); \ - CHECK_AND_ASSERT_MES(res, false, "Failed to call " << #callback_f << "() while handling " << s_pattern); \ - uint64_t ticks2 = misc_utils::get_tick_count(); \ - epee::serialization::store_t_to_binary(static_cast(resp), response_info.m_body); \ - uint64_t ticks3 = epee::misc_utils::get_tick_count(); \ - response_info.m_mime_tipe = " application/octet-stream"; \ - response_info.m_header_info.m_content_type = " application/octet-stream"; \ - LOG_PRINT( "[HTTP/BIN][" << epee::string_tools::get_ip_string_from_int32(m_conn_context.m_remote_ip ) << "][" << query_info.m_URI << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \ - } - -#define CHAIN_TO_PHANDLER(pi_chain_handler) else if (pi_chain_handler && pi_chain_handler->handle_http_request_map(query_info, response_info, m_conn_context, call_found, generate_reference) && call_found) { return true;} - -#define CHAIN_URI_MAP2(callback) else {callback(query_info, response_info, m_conn_context);call_found = true;} - -#define END_URI_MAP2() return true;} - - - - -namespace epee +namespace epee { namespace json_rpc { @@ -204,7 +63,7 @@ namespace epee KV_SERIALIZE(message) END_KV_SERIALIZE_MAP() }; - + struct dummy_error { BEGIN_KV_SERIALIZE_MAP() @@ -264,20 +123,241 @@ namespace epee } } -template -struct json_command_type_t + +template +typename_t get_documentation_json_struct() { - typedef typename epee::json_rpc::request request; - typedef typename epee::json_rpc::request response; + return AUTO_VAL_INIT_T(typename_t); +} + +struct documentation_entry +{ + std::string uri; + bool is_binary = false; //if not - then it's JSON + std::string json_method_name; + std::string request_json_example; + std::string request_json_descriptions; + + std::string response_json_example; + std::string response_json_descriptions; + + std::string method_general_decription; }; -#define JSON_RPC_REFERENCE_MARKER "JSON_RPC" +struct documentation +{ + bool do_generate_documentation = false; + std::list entries; +}; + + +// Primary template +template +struct has_static_member_description { +private: + // SFINAE test function + template + static auto test(int) -> decltype(U::description, std::true_type{}); + + // Fallback function + template + static auto test(...) -> std::false_type; + +public: + // Member constant indicating whether T has a static member + static constexpr bool value = decltype(test(0))::value; +}; -#define BEGIN_JSON_RPC_MAP(uri) else if(query_info.m_URI == JSON_RPC_REFERENCE_MARKER || query_info.m_URI == uri) \ + +template +const char* get_command_description() +{ + if constexpr (has_static_member_description::value) + { + return T::description; + } + else + { + return "NO DESCRIPTION"; + } +} + +template +void f(T) {} // Definition #2 + + +template +bool auto_doc(const std::string& uri, const std::string& method, bool is_json, documentation& docs) +{ + if (!docs.do_generate_documentation) return true; + + docs.entries.resize(docs.entries.size()+1); + docs.entries.back().is_binary = !is_json; + docs.entries.back().json_method_name = method; + docs.entries.back().method_general_decription = get_command_description(); + + if constexpr (is_json_rpc_method) + { + //json rpc-like call + typedef typename epee::json_rpc::request request_t; + typedef typename epee::json_rpc::request response_t; + request_t req = AUTO_VAL_INIT(req); //get_documentation_json_struct(); + response_t res = AUTO_VAL_INIT(res); //get_documentation_json_struct(); + + + epee::serialization::portable_storage_extended_doc ps; + req.store(ps, nullptr); + ps.dump_as_json(docs.entries.back().request_json_example); + ps.dump_as_decriptions(docs.entries.back().request_json_descriptions); + + epee::serialization::portable_storage_extended_doc ps_res; + res.store(ps_res, nullptr); + ps_res.dump_as_json(docs.entries.back().response_json_example); + ps_res.dump_as_decriptions(docs.entries.back().response_json_descriptions); + + } + else + { + //json/bin uri/based + typedef command_type_t::request request_t; + typedef command_type_t::response response_t; + + request_t req = AUTO_VAL_INIT(req); //get_documentation_json_struct(); + response_t res = AUTO_VAL_INIT(res); //get_documentation_json_struct(); + + + epee::serialization::portable_storage_extended_doc ps; + req.store(ps, nullptr); + ps.dump_as_json(docs.entries.back().request_json_example); + ps.dump_as_decriptions(docs.entries.back().request_json_descriptions); + + epee::serialization::portable_storage_extended_doc ps_res; + res.store(ps_res, nullptr); + ps_res.dump_as_json(docs.entries.back().response_json_example); + ps_res.dump_as_decriptions(docs.entries.back().response_json_descriptions); + } + + +// std::stringstream ss; +// ss << prefix_name << ENDL +// << "REQUEST: " << ENDL << req_str << ENDL << req_str_descr << "--------------------------------" << ENDL +// << "RESPONSE: " << ENDL << res_str << ENDL << res_str_descr << "################################" << ENDL; +// generate_reference += ss.str(); + return true; + + //return auto_doc_t(prefix_name, generate_reference); +} + +namespace epee { + namespace net_utils { + namespace http { + struct i_chain_handler + { + virtual bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, epee::net_utils::http::http_response_info& response_info, + epee::net_utils::connection_context_base& m_conn_context, bool& call_found, documentation& docs = documentation()) = 0; + }; + } + } +} + + + + +#define CHAIN_HTTP_TO_MAP2(context_type) bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \ + epee::net_utils::http::http_response_info& response, \ + context_type& m_conn_context) \ +{\ + response.m_response_code = 200; \ + response.m_response_comment = "Ok"; \ + bool call_found = false; \ + if(!handle_http_request_map(query_info, response, m_conn_context, call_found) && response.m_response_code == 200) \ + { response.m_response_code = 500; response.m_response_comment = "Internal Server Error"; return true; } \ + if (!call_found) \ + { response.m_response_code = 404; response.m_response_comment = "Not Found"; return true; } \ + return true; \ +} + +#define BEGIN_URI_MAP2() template bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \ + epee::net_utils::http::http_response_info& response_info, \ + t_context& m_conn_context, bool& call_found, documentation& docs = documentation()) { \ + call_found = false; \ + if(false) return true; //just a stub to have "else if" + +#define BEGIN_URI_MAP2_VIRTUAL() virtual bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \ + epee::net_utils::http::http_response_info& response_info, \ + epee::net_utils::connection_context_base& m_conn_context, bool& call_found, documentation& docs = documentation()) { \ + call_found = false; \ + if(false) return true; //just a stub to have "else if" + + +#define MAP_URI2(pattern, callback) else if(std::string::npos != query_info.m_URI.find(pattern)) return callback(query_info, response_info, m_conn_context); + +#define MAP_URI_AUTO_XML2(s_pattern, callback_f, command_type) //TODO: don't think i ever again will use xml - ambiguous and "overtagged" format + +#define MAP_URI_AUTO_JON2(s_pattern, callback_f, command_type) \ + else if(auto_doc(s_pattern, "", true, docs) && query_info.m_URI == s_pattern) \ { \ - if(query_info.m_URI == JSON_RPC_REFERENCE_MARKER) {generate_reference = "JSON RPC URL: " uri "\n";} \ + call_found = true; \ + uint64_t ticks = misc_utils::get_tick_count(); \ + boost::value_initialized req; \ + bool res = epee::serialization::load_t_from_json(static_cast(req), query_info.m_body); \ + CHECK_AND_ASSERT_MES(res, false, "Failed to parse json: \r\n" << query_info.m_body); \ + uint64_t ticks1 = epee::misc_utils::get_tick_count(); \ + boost::value_initialized resp;\ + res = callback_f(static_cast(req), static_cast(resp), m_conn_context); \ + CHECK_AND_ASSERT_MES(res, false, "Failed to call " << #callback_f << "() while handling " << s_pattern); \ + uint64_t ticks2 = epee::misc_utils::get_tick_count(); \ + epee::serialization::store_t_to_json(static_cast(resp), response_info.m_body); \ + uint64_t ticks3 = epee::misc_utils::get_tick_count(); \ + response_info.m_mime_tipe = "application/json"; \ + response_info.m_header_info.m_content_type = " application/json"; \ + LOG_PRINT("[HTTP/JSON][" << epee::string_tools::get_ip_string_from_int32(m_conn_context.m_remote_ip ) << "][" << query_info.m_URI << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \ + } + +#define MAP_URI_AUTO_BIN2(s_pattern, callback_f, command_type) \ + else if(auto_doc(s_pattern, "", false, docs) && query_info.m_URI == s_pattern) \ + { \ + call_found = true; \ + uint64_t ticks = misc_utils::get_tick_count(); \ + boost::value_initialized req; \ + bool res = epee::serialization::load_t_from_binary(static_cast(req), query_info.m_body); \ + CHECK_AND_ASSERT_MES(res, false, "Failed to parse bin body data, body size=" << query_info.m_body.size()); \ + uint64_t ticks1 = misc_utils::get_tick_count(); \ + boost::value_initialized resp;\ + res = callback_f(static_cast(req), static_cast(resp), m_conn_context); \ + CHECK_AND_ASSERT_MES(res, false, "Failed to call " << #callback_f << "() while handling " << s_pattern); \ + uint64_t ticks2 = misc_utils::get_tick_count(); \ + epee::serialization::store_t_to_binary(static_cast(resp), response_info.m_body); \ + uint64_t ticks3 = epee::misc_utils::get_tick_count(); \ + response_info.m_mime_tipe = " application/octet-stream"; \ + response_info.m_header_info.m_content_type = " application/octet-stream"; \ + LOG_PRINT( "[HTTP/BIN][" << epee::string_tools::get_ip_string_from_int32(m_conn_context.m_remote_ip ) << "][" << query_info.m_URI << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \ + } + +#define CHAIN_TO_PHANDLER(pi_chain_handler) else if (pi_chain_handler && pi_chain_handler->handle_http_request_map(query_info, response_info, m_conn_context, call_found, docs) && call_found) { return true;} + +#define CHAIN_URI_MAP2(callback) else {callback(query_info, response_info, m_conn_context);call_found = true;} + +#define END_URI_MAP2() return true;} + + + +//template +//struct json_command_type_t +//{ +// typedef typename epee::json_rpc::request request; +// typedef typename epee::json_rpc::request response; +//}; + +//#define JSON_RPC_REFERENCE_MARKER "JSON_RPC" + +// if(query_info.m_URI == JSON_RPC_REFERENCE_MARKER) {generate_reference = "JSON RPC URL: " uri "\n";} \ + +#define BEGIN_JSON_RPC_MAP(uri) else if(docs.do_generate_documentation || query_info.m_URI == uri) \ + { \ + const char* current_zone_json_uri = uri;\ LOG_PRINT_L4("[JSON_REQUEST_BODY]: " << ENDL << query_info.m_body); \ uint64_t ticks = epee::misc_utils::get_tick_count(); \ epee::serialization::portable_storage ps; \ @@ -336,7 +416,7 @@ struct json_command_type_t LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); #define MAP_JON_RPC_WE(method_name, callback_f, command_type) \ - else if(auto_doc>("[" method_name "]", generate_reference) && callback_name == method_name) \ + else if(auto_doc(current_zone_json_uri, method_name, true, docs) && callback_name == method_name) \ { \ call_found = true; \ PREPARE_OBJECTS_FROM_JSON(command_type) \ @@ -354,7 +434,7 @@ struct json_command_type_t } #define MAP_JON_RPC_WERI(method_name, callback_f, command_type) \ - else if(auto_doc>("[" method_name "]", generate_reference) && callback_name == method_name) \ + else if(auto_doc(current_zone_json_uri, method_name, true, docs) && callback_name == method_name) \ { \ call_found = true; \ PREPARE_OBJECTS_FROM_JSON(command_type) \ @@ -372,7 +452,7 @@ struct json_command_type_t } #define MAP_JON_RPC(method_name, callback_f, command_type) \ - else if(auto_doc>(std::string("[") + method_name + "]", generate_reference) && callback_name == method_name) \ + else if(auto_doc(current_zone_json_uri, method_name, true, docs) && callback_name == method_name) \ { \ call_found = true; \ PREPARE_OBJECTS_FROM_JSON(command_type) \ diff --git a/contrib/epee/include/serialization/keyvalue_serialization.h b/contrib/epee/include/serialization/keyvalue_serialization.h index 494046cc..91f1aeda 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization.h +++ b/contrib/epee/include/serialization/keyvalue_serialization.h @@ -103,12 +103,9 @@ public: \ //#define DOC_DSCR(description) , description #define DOC_EXMP(substitute) , substitute -#define DOC_EXMP_AUTO_1(arg_1) , KV_MAKE_ALIAS_NAME() (arg_1) -#define DOC_EXMP_AUTO_2(arg_1, arg_2) , KV_MAKE_ALIAS_NAME() (arg_1, arg_2) +//#define DOC_EXMP_AUTO_1(arg_1) , KV_MAKE_ALIAS_NAME() (arg_1) +//#define DOC_EXMP_AUTO_2(arg_1, arg_2) , KV_MAKE_ALIAS_NAME() (arg_1, arg_2) #define DOC_END ); } - - - #define DOC_EXMP_AUTO(...) , epee::create_t_object(__VA_ARGS__) @@ -164,7 +161,7 @@ public: \ #define KV_SERIALIZE(varialble) KV_SERIALIZE_N(varialble, #varialble) #define KV_SERIALIZE_DOC(varialble) KV_SERIALIZE_N_DOC( varialble, #varialble) -#define DOC_COMMAND(desciption_text) inline static const char* description; +#define DOC_COMMAND(desciption_text) inline static const char* description = desciption_text; #define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_N(varialble, #varialble) diff --git a/contrib/epee/include/storages/portable_storage_to_description.h b/contrib/epee/include/storages/portable_storage_to_description.h index c38c3f62..2d87d5d7 100644 --- a/contrib/epee/include/storages/portable_storage_to_description.h +++ b/contrib/epee/include/storages/portable_storage_to_description.h @@ -51,13 +51,13 @@ namespace epee template static void handle_array_start(t_stream& strm, size_t indent) { - strm << "["; + //strm << "["; } template static void handle_array_end(t_stream& strm, size_t indent) { - strm << "]"; + //strm << "]"; } template @@ -71,8 +71,11 @@ namespace epee template static void handle_print_key(t_stream& strm, const std::string& key, const std::string& description, size_t indent) { - const std::string indent_str = make_indent(indent); - strm << indent_str << "\"" << key << "\"" << ": " << description; + if (description.size()) + { + const std::string indent_str = make_indent(indent); + strm << indent_str << "\"" << key << "\"" << ": " << description << eol; + } } template @@ -84,19 +87,19 @@ namespace epee template static void handle_section_entry_separator(t_stream& strm, size_t indent) { - strm << ","; + //strm << ","; } template static void handle_array_entry_separator(t_stream& strm, size_t indent) { - strm << ","; + //strm << ","; } template static void handle_line_break(t_stream& strm, size_t indent) { - strm << eol; + //strm << eol; } }; diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index a7b9a5ff..a596dfd9 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -25,7 +25,7 @@ namespace command_line const arg_descriptor arg_console ( "no-console", "Disable daemon console commands" ); const arg_descriptor arg_show_details ( "currency-details", "Display currency details" ); - const arg_descriptor arg_show_rpc_autodoc ( "show_rpc_autodoc", "Display rpc auto-generated documentation template" ); + const arg_descriptor arg_generate_rpc_autodoc ( "generate_rpc_autodoc", "Make auto-generated RPC API documentation documents at the given path" ); const arg_descriptor arg_disable_upnp ( "disable-upnp", "Disable UPnP (enhances local network privacy)"); const arg_descriptor arg_disable_ntp ( "disable-ntp", "Disable NTP, could enhance to time synchronization issue but increase network privacy, consider using disable-stop-if-time-out-of-sync with it"); diff --git a/src/common/command_line.h b/src/common/command_line.h index 905b1067..0b326917 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -220,7 +220,7 @@ namespace command_line extern const arg_descriptor arg_log_level; extern const arg_descriptor arg_console; extern const arg_descriptor arg_show_details; - extern const arg_descriptor arg_show_rpc_autodoc; + //extern const arg_descriptor arg_show_rpc_autodoc; extern const arg_descriptor arg_disable_upnp; extern const arg_descriptor arg_disable_ntp; extern const arg_descriptor arg_disable_stop_if_time_out_of_sync; @@ -233,4 +233,6 @@ namespace command_line extern const arg_descriptor arg_validate_predownload; extern const arg_descriptor arg_predownload_link; extern const arg_descriptor arg_deeplink; + extern const arg_descriptor arg_generate_rpc_autodoc; + } diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 85b65544..80ddef17 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -589,11 +589,11 @@ namespace currency END_SERIALIZE() BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(service_id) - KV_SERIALIZE(instruction) - KV_SERIALIZE_BLOB_AS_HEX_STRING(body) - KV_SERIALIZE_CONTAINER_POD_AS_HEX(security) - KV_SERIALIZE(flags) + KV_SERIALIZE(service_id) DOC_DSCR("Service ID, identificator that diferent one service from another") DOC_EXMP("C") DOC_END + KV_SERIALIZE(instruction) DOC_DSCR("Instruction that make sence for this particular service") DOC_EXMP("K") DOC_END + KV_SERIALIZE_BLOB_AS_HEX_STRING(body) DOC_DSCR("Hex-encoded body of the attachment") DOC_EXMP("dcfd7e055a6a3043ea3541a571a57a63e25dcc64e4a270f14fa9a58ac5dbec85dcfd7e055a6a3043ea3541a571a57a63e25dcc64e4a270f14fa9a58ac5dbec85") DOC_END + KV_SERIALIZE_CONTAINER_POD_AS_HEX(security) DOC_DSCR("Hex-encoded public key of the owner, optional") DOC_EXMP("d8f6e37f28a632c06b0b3466db1b9d2d1b36a580ee35edfd971dc1423bc412a5") DOC_END + KV_SERIALIZE(flags) DOC_DSCR("Flags that help wallet to automatically process some properties of the attachment(combination of TX_SERVICE_ATTACHMENT_ENCRYPT_BODY=1, TX_SERVICE_ATTACHMENT_DEFLATE_BODY=2, TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE=4,TX_SERVICE_ATTACHMENT_ENCRYPT_ADD_PROOF=8 )") DOC_END END_KV_SERIALIZE_MAP() }; diff --git a/src/currency_core/offers_service_basics.h b/src/currency_core/offers_service_basics.h index 1dffe367..a2ca2e7c 100644 --- a/src/currency_core/offers_service_basics.h +++ b/src/currency_core/offers_service_basics.h @@ -37,21 +37,21 @@ namespace bc_services //----------------- BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_N(offer_type, "ot") - KV_SERIALIZE_CUSTOM_N(amount_primary, std::string, bc_services::transform_amount_to_string, bc_services::transform_string_to_amount, "ap") - KV_SERIALIZE_CUSTOM_N(amount_target, std::string, bc_services::transform_amount_to_string, bc_services::transform_string_to_amount, "at") - KV_SERIALIZE_N(bonus, "b") - KV_SERIALIZE_N(target, "t") - KV_SERIALIZE_N(primary, "p") - KV_SERIALIZE_N(location_country, "lco") - KV_SERIALIZE_N(location_city, "lci") - KV_SERIALIZE_N(contacts, "cnt") - KV_SERIALIZE_N(comment, "com") - KV_SERIALIZE_N(payment_types, "pt") - KV_SERIALIZE_N(deal_option, "do") - KV_SERIALIZE_N(category, "cat") - KV_SERIALIZE_N(expiration_time, "et") - KV_SERIALIZE_N(preview_url, "url") + KV_SERIALIZE_N(offer_type, "ot") DOC_DSCR("Type of the offer: OFFER_TYPE_PRIMARY_TO_TARGET(SELL ORDER) - 0, OFFER_TYPE_TARGET_TO_PRIMARY(BUY ORDER) - 1 etc.") DOC_EXMP(0) DOC_END + KV_SERIALIZE_CUSTOM_N(amount_primary, std::string, bc_services::transform_amount_to_string, bc_services::transform_string_to_amount, "ap") DOC_DSCR("Amount of the currency") DOC_EXMP("100000") DOC_END + KV_SERIALIZE_CUSTOM_N(amount_target, std::string, bc_services::transform_amount_to_string, bc_services::transform_string_to_amount, "at") DOC_DSCR("Smount of other currency or goods") DOC_EXMP("10000000") DOC_END + KV_SERIALIZE_N(bonus, "b") DOC_DSCR("Bonus associated with the offer") DOC_EXMP(false) DOC_END + KV_SERIALIZE_N(target, "t") DOC_DSCR("Target: currency / goods") DOC_EXMP("USDT") DOC_END + KV_SERIALIZE_N(primary, "p") DOC_DSCR("Currency for goods") DOC_EXMP("ZANO") DOC_END + KV_SERIALIZE_N(location_country, "lco") DOC_DSCR("Country of the offer location") DOC_EXMP("Montenegro") DOC_END + KV_SERIALIZE_N(location_city, "lci") DOC_DSCR("City of the offer location") DOC_EXMP("Kolasin") DOC_END + KV_SERIALIZE_N(contacts, "cnt") DOC_DSCR("Contacts related to the offer") DOC_EXMP("Ranko +38211111111") DOC_END + KV_SERIALIZE_N(comment, "com") DOC_DSCR("Comment associated with the offer") DOC_EXMP("Dobr dan") DOC_END + KV_SERIALIZE_N(payment_types, "pt") DOC_DSCR("Types of payment accepted for the offer") DOC_EXMP("zano") DOC_END + KV_SERIALIZE_N(deal_option, "do") DOC_DSCR("Deal option for the offer") DOC_EXMP("full amount, by parts") DOC_END + KV_SERIALIZE_N(category, "cat") DOC_DSCR("Category of the offer") DOC_EXMP("") DOC_END + KV_SERIALIZE_N(expiration_time, "et") DOC_DSCR("Expiration time of the offer") DOC_EXMP(0) DOC_END + KV_SERIALIZE_N(preview_url, "url") DOC_DSCR("URL for previewing the offer") DOC_EXMP("") DOC_END END_KV_SERIALIZE_MAP() }; @@ -69,12 +69,12 @@ namespace bc_services mutable bool stopped; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(tx_hash) - KV_SERIALIZE_POD_AS_HEX_STRING(tx_original_hash) - KV_SERIALIZE(index_in_tx) - KV_SERIALIZE(timestamp) - KV_SERIALIZE(fee) - KV_SERIALIZE_POD_AS_HEX_STRING(security) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_hash) DOC_DSCR("Transaction hash represented as a hexadecimal string") DOC_EXMP("cc608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(tx_original_hash) DOC_DSCR("Origin transaction hash represented as a hexadecimal string(if offer updated)") DOC_EXMP("cc608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852") DOC_END + KV_SERIALIZE(index_in_tx) DOC_DSCR("Index of the tx_service_attachment entrie in transaction") DOC_EXMP(0) DOC_END + KV_SERIALIZE(timestamp) DOC_DSCR("Timestamp of the transaction") DOC_EXMP(1712683857) DOC_END + KV_SERIALIZE(fee) DOC_DSCR("Fee associated with the transaction") DOC_EXMP(10000000000) DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(security) DOC_DSCR("Onwer's public key for access control") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END KV_CHAIN_BASE(offer_details) END_KV_SERIALIZE_MAP() }; @@ -163,32 +163,33 @@ namespace bc_services bool bonus; std::string category; std::string keyword; - bool fake; + //bool fake; uint64_t current_time; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(order_by) - KV_SERIALIZE(reverse) - KV_SERIALIZE(offset) - KV_SERIALIZE(limit) - KV_SERIALIZE(timestamp_start) - KV_SERIALIZE(timestamp_stop) - KV_SERIALIZE(offer_type_mask) - KV_SERIALIZE(amount_low_limit) - KV_SERIALIZE(amount_up_limit) - KV_SERIALIZE_CUSTOM(rate_low_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double) - KV_SERIALIZE_CUSTOM(rate_up_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double) - KV_SERIALIZE(payment_types) - KV_SERIALIZE(location_country) - KV_SERIALIZE(location_city) - KV_SERIALIZE(target) - KV_SERIALIZE(primary) - KV_SERIALIZE(bonus) - KV_SERIALIZE(category) - KV_SERIALIZE(keyword) - KV_SERIALIZE(fake) + KV_SERIALIZE(order_by) DOC_DSCR("Field to order the results by one on this: ORDER_BY_TIMESTAMP=0,ORDER_BY_AMOUNT_PRIMARY=1,ORDER_BY_AMOUNT_TARGET=2,ORDER_BY_AMOUNT_RATE=3,ORDER_BY_PAYMENT_TYPES=4,ORDER_BY_CONTACTS=5,ORDER_BY_LOCATION=6,ORDER_BY_NAME=7") DOC_EXMP(0) DOC_END + KV_SERIALIZE(reverse) DOC_DSCR("Flag to indicate whether the results should be sorted in reverse order") DOC_EXMP(false) DOC_END + KV_SERIALIZE(offset) DOC_DSCR("Offset for pagination") DOC_EXMP(0) DOC_END + KV_SERIALIZE(limit) DOC_DSCR("Maximum number of results to return") DOC_EXMP(100) DOC_END + KV_SERIALIZE(timestamp_start) DOC_DSCR("Start timestamp for filtering results") DOC_EXMP(0) DOC_END + KV_SERIALIZE(timestamp_stop) DOC_DSCR("Stop timestamp for filtering results") DOC_EXMP(0) DOC_END + KV_SERIALIZE(offer_type_mask) DOC_DSCR("Mask representing the types of offers to include in the results, conbination of this: OFFER_TYPE_MASK_PRIMARY_TO_TARGET 0x00000001, OFFER_TYPE_MASK_TARGET_TO_PRIMARY 0x00000002, OFFER_TYPE_MASK_GOODS_TO_PRIMARY 0x00000004, OFFER_TYPE_MASK_PRIMARY_TO_GOODS 0x00000008") DOC_EXMP(0) DOC_END + KV_SERIALIZE(amount_low_limit) DOC_DSCR("Lower limit for the amount of offers") DOC_EXMP(0) DOC_END + KV_SERIALIZE(amount_up_limit) DOC_DSCR("Upper limit for the amount of offers") DOC_EXMP(0) DOC_END + KV_SERIALIZE_CUSTOM(rate_low_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double) DOC_DSCR("Lower limit for the rate") DOC_EXMP("0.1") DOC_END + KV_SERIALIZE_CUSTOM(rate_up_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double) DOC_DSCR("Upper limit for the rate") DOC_EXMP("0.1") DOC_END + KV_SERIALIZE(payment_types) DOC_DSCR("Types of payment accepted for the offers(in a free form as it is in contract)") DOC_END + KV_SERIALIZE(location_country) DOC_DSCR("Country of the location for the offers") DOC_END + KV_SERIALIZE(location_city) DOC_DSCR("City of the location for the offers") DOC_END + KV_SERIALIZE(target) DOC_DSCR("Target entity of the offers") DOC_END + KV_SERIALIZE(primary) DOC_DSCR("Primary field for the offers") DOC_END + KV_SERIALIZE(bonus) DOC_DSCR("Bonus associated with the offers") DOC_EXMP(false) DOC_END + KV_SERIALIZE(category) DOC_DSCR("Category of the offers") DOC_END + KV_SERIALIZE(keyword) DOC_DSCR("Keyword for searching offers") DOC_EXMP("tubes") DOC_END + //KV_SERIALIZE(fake) DOC_DSCR("Flag indicating whether the offer is fake") DOC_EXMP() DOC_END END_KV_SERIALIZE_MAP() + }; diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 2be409f2..eb697db8 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -155,7 +155,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_cmd_sett, command_line::arg_log_level); command_line::add_arg(desc_cmd_sett, command_line::arg_console); command_line::add_arg(desc_cmd_only, command_line::arg_show_details); - command_line::add_arg(desc_cmd_only, command_line::arg_show_rpc_autodoc); + command_line::add_arg(desc_cmd_only, command_line::arg_generate_rpc_autodoc); command_line::add_arg(desc_cmd_sett, command_line::arg_disable_stop_if_time_out_of_sync); command_line::add_arg(desc_cmd_sett, command_line::arg_disable_stop_on_low_free_space); command_line::add_arg(desc_cmd_sett, command_line::arg_enable_offers_service); @@ -272,15 +272,17 @@ int main(int argc, char* argv[]) if (stratum_enabled) stratum_server_ptr = std::make_shared(&ccore); - if (command_line::get_arg(vm, command_line::arg_show_rpc_autodoc)) + if (command_line::has_arg(vm, command_line::arg_generate_rpc_autodoc)) { LOG_PRINT_L0("Dumping RPC auto-generated documents!"); epee::net_utils::http::http_request_info query_info; epee::net_utils::http::http_response_info response_info; epee::net_utils::connection_context_base conn_context; - std::string generate_reference = std::string("RPC_COMMANDS_LIST:\n"); + //std::string generate_reference = std::string("RPC_COMMANDS_LIST:\n"); + documentation doc; + doc.do_generate_documentation = true; bool call_found = false; - rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, generate_reference); + rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, doc); //std::string json_rpc_reference; //query_info.m_URI = JSON_RPC_REFERENCE_MARKER; //query_info.m_body = "{\"jsonrpc\": \"2.0\", \"method\": \"nonexisting_method\", \"params\": {}},"; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 945846e7..27388f04 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1687,11 +1687,13 @@ namespace currency struct COMMAND_RPC_GET_OFFERS_EX { + DOC_COMMAND("Fetch from daemon offers listed in the marketplace with given filters"); + struct request { bc_services::core_offers_filter filter; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(filter) + KV_SERIALIZE(filter) DOC_DSCR("Filter options.") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1702,9 +1704,9 @@ namespace currency uint64_t total_offers; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - KV_SERIALIZE(offers) - KV_SERIALIZE(total_offers) + KV_SERIALIZE(status) DOC_DSCR("Status of the operation") DOC_EXMP("OK") DOC_END + KV_SERIALIZE(offers) DOC_DSCR("List of offers related to the operation") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(total_offers) DOC_DSCR("Total number of offers") DOC_EXMP(1) DOC_END END_KV_SERIALIZE_MAP() }; }; diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index e4375a56..6f230939 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2807,7 +2807,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_params, arg_set_timeout); command_line::add_arg(desc_params, arg_voting_config_file); command_line::add_arg(desc_params, arg_no_password_confirmations); - command_line::add_arg(desc_params, command_line::arg_show_rpc_autodoc); + command_line::add_arg(desc_params, command_line::arg_generate_rpc_autodoc); tools::wallet_rpc_server::init_options(desc_params); @@ -2863,24 +2863,50 @@ int main(int argc, char* argv[]) } - if (command_line::get_arg(vm, command_line::arg_show_rpc_autodoc)) + if (command_line::has_arg(vm, command_line::arg_generate_rpc_autodoc)) { LOG_PRINT_L0("Dumping RPC auto-generated documents!"); epee::net_utils::http::http_request_info query_info; epee::net_utils::http::http_response_info response_info; epee::net_utils::connection_context_base conn_context; - std::string generate_reference = std::string("WALLET_RPC_COMMANDS_LIST:\n"); + //std::string generate_reference = std::string("WALLET_RPC_COMMANDS_LIST:\n"); bool call_found = false; tools::wallet_rpc_server wallet_rpc_server(std::shared_ptr(new tools::wallet2())); //wallet_rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, generate_reference); - std::string json_rpc_reference = generate_reference; - query_info.m_URI = JSON_RPC_REFERENCE_MARKER; + //::string json_rpc_reference = generate_reference; + documentation docs; + docs.do_generate_documentation = true; +// query_info.m_URI = JSON_RPC_REFERENCE_MARKER; query_info.m_body = "{\"jsonrpc\": \"2.0\", \"method\": \"nonexisting_method\", \"params\": {}},"; - wallet_rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, json_rpc_reference); + wallet_rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, docs); + + std::string path_to_generate = command_line::get_arg(vm, command_line::arg_generate_rpc_autodoc); + for (const auto& de : docs.entries) + { + std::stringstream ss; + ss << de.method_general_decription << ENDL; + ss << "URL: ```http:://127.0.0.1:11211" << de.uri << "```" << ENDL; - LOG_PRINT_L0(json_rpc_reference); + ss << "### Request: " << ENDL << "```json" << ENDL << de.request_json_example << ENDL << "```" << ENDL; + ss << "### Request description: " << ENDL << "```" << ENDL << de.request_json_descriptions << ENDL << "```" << ENDL; + ss << "### Response: " << ENDL << "```json" << ENDL << de.response_json_example << ENDL << "```" << ENDL; + ss << "### Response description: " << ENDL << "```" << ENDL << de.response_json_descriptions << ENDL << "```" << ENDL; + + std::string filename = de.json_method_name; + if (!filename.size()) + { + filename = de.uri; + } + filename += ".md"; + bool r = epee::file_io_utils::save_string_to_file(path_to_generate + "/" + filename, ss.str()); + if (!r) + { + LOG_ERROR("Failed to save file " << filename); + return 1; + } + } return 0; } diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 61538912..a274ad7f 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -123,9 +123,9 @@ namespace wallet_public crypto::public_key asset_id = currency::native_coin_asset_id; // not blinded, not premultiplied by 1/8 BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(amount) - KV_SERIALIZE(is_income) - KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) + KV_SERIALIZE(amount) DOC_DSCR("Amount of asset the had been transfered") DOC_EXMP(1000000000000) DOC_END + KV_SERIALIZE(is_income) DOC_DSCR("Indicates if transfer was income our outgoing") DOC_EXMP(false) DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Asset id") DOC_EXMP("cc608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852") DOC_END END_KV_SERIALIZE_MAP() BEGIN_BOOST_SERIALIZATION() @@ -168,27 +168,29 @@ namespace wallet_public std::vector selected_indicies; std::list marketplace_entries; + + BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(tx_hash) - KV_SERIALIZE(height) - KV_SERIALIZE(unlock_time) - KV_SERIALIZE(tx_blob_size) - KV_SERIALIZE_BLOB_AS_HEX_STRING(payment_id) - KV_SERIALIZE(comment) - KV_SERIALIZE(timestamp) - KV_SERIALIZE(employed_entries) - KV_SERIALIZE(fee) - KV_SERIALIZE(is_service) - KV_SERIALIZE(is_mixing) - KV_SERIALIZE(is_mining) - KV_SERIALIZE(tx_type) - KV_SERIALIZE(show_sender) - KV_SERIALIZE(contract) - KV_SERIALIZE(service_entries) - KV_SERIALIZE(transfer_internal_index) - KV_SERIALIZE(remote_addresses) - KV_SERIALIZE(remote_aliases) - KV_SERIALIZE(subtransfers) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_hash) DOC_DSCR("Transaction ID(hash)") DOC_EXMP("5509650e12c8f901e6731a2bfaf3abfd64409e3e1366d3d94cd11db8beddb0c3") DOC_END + KV_SERIALIZE(height) DOC_DSCR("Height of the block that included transaction(0 i transaction is unconfirmed)") DOC_EXMP(0) DOC_END + KV_SERIALIZE(unlock_time) DOC_DSCR("Unlock time of this transfer (if present)") DOC_EXMP(0) DOC_END + KV_SERIALIZE(tx_blob_size) DOC_DSCR("Size of transaction in bytes") DOC_EXMP(0) DOC_END + KV_SERIALIZE_BLOB_AS_HEX_STRING(payment_id) DOC_DSCR("HEX-encoded payment id blob, if it was present") DOC_EXMP("00000000ff00ff00") DOC_END + KV_SERIALIZE(comment) DOC_DSCR("Some human-readable comment") DOC_EXMP("Comment here") DOC_END + KV_SERIALIZE(timestamp) DOC_DSCR("Timestamp of the block that included transaction in blockchain, 0 for unconfirmed") DOC_EXMP(1712590951) DOC_END + KV_SERIALIZE(employed_entries) DOC_DSCR("Mark entries from transaction that was connected to this wallet") DOC_END + KV_SERIALIZE(fee) DOC_DSCR("Transaction fee") DOC_EXMP(10000000000) DOC_END + KV_SERIALIZE(is_service) DOC_DSCR("Tells if this transaction is used as utility by one of Zano services(contracts, ionic swaps, etc)") DOC_EXMP(false) DOC_END + KV_SERIALIZE(is_mixing) DOC_DSCR("Tells if this transaction using mixins or not(auditble wallets normally don't use mixins)") DOC_EXMP(false) DOC_END + KV_SERIALIZE(is_mining) DOC_DSCR("Tells if this transaction is coinbase transaction(ie generated by PoW mining or by PoS staking)") DOC_EXMP(false) DOC_END + KV_SERIALIZE(tx_type) DOC_DSCR("Could be one of this: GUI_TX_TYPE_NORMAL=0, GUI_TX_TYPE_PUSH_OFFER=1, GUI_TX_TYPE_UPDATE_OFFER=2, GUI_TX_TYPE_CANCEL_OFFER=3, GUI_TX_TYPE_NEW_ALIAS=4,GUI_TX_TYPE_UPDATE_ALIAS=5,GUI_TX_TYPE_COIN_BASE=6,GUI_TX_TYPE_ESCROW_PROPOSAL=7,GUI_TX_TYPE_ESCROW_TRANSFER=8,GUI_TX_TYPE_ESCROW_RELEASE_NORMAL=9,GUI_TX_TYPE_ESCROW_RELEASE_BURN=10,GUI_TX_TYPE_ESCROW_CANCEL_PROPOSAL=11,GUI_TX_TYPE_ESCROW_RELEASE_CANCEL=12,GUI_TX_TYPE_HTLC_DEPOSIT=13,GUI_TX_TYPE_HTLC_REDEEM=14") DOC_EXMP(0) DOC_END + KV_SERIALIZE(show_sender) DOC_DSCR("If sender is included in tx") DOC_EXMP(false) DOC_END + KV_SERIALIZE(contract) DOC_DSCR("Escrow contract if it's part of transaction") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(service_entries) DOC_DSCR("Additional entries that might be stored in transaction but not part of it's consensus") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(transfer_internal_index) DOC_DSCR("Index of this entry in the wallet's array of transaction's history") DOC_EXMP(12) DOC_END + KV_SERIALIZE(remote_addresses) DOC_DSCR("Remote addresses of this transfer(destination if it's outgoing transfer or sender if it's incoming transaction)") DOC_EXMP_AUTO(1, "ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END + KV_SERIALIZE(remote_aliases) DOC_DSCR("Aliases for remot addresses, of discovered") DOC_EXMP_AUTO(1, "roger") DOC_END + KV_SERIALIZE(subtransfers) DOC_DSCR("Essential part of transfer entry: amounts that been transfered in this transaction grouped by asset id") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() BEGIN_BOOST_SERIALIZATION() @@ -283,8 +285,8 @@ namespace wallet_public //bool is_income = false; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_EPHEMERAL_N(uint64_t, wallet_transfer_info_to_amount, "amount") - KV_SERIALIZE_EPHEMERAL_N(bool, wallet_transfer_info_to_is_income, "is_income") + KV_SERIALIZE_EPHEMERAL_N(uint64_t, wallet_transfer_info_to_amount, "amount") DOC_DSCR("Native coins amount") DOC_EXMP(1000000000000) DOC_END + KV_SERIALIZE_EPHEMERAL_N(bool, wallet_transfer_info_to_is_income, "is_income") DOC_DSCR("If trnasfer entrie is income (taken from native subtransfer)") DOC_EXMP(false) DOC_END //KV_SERIALIZE(amount) KV_CHAIN_BASE(wallet_transfer_info) END_KV_SERIALIZE_MAP() @@ -346,9 +348,9 @@ namespace wallet_public uint64_t t; uint64_t h; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(a) - KV_SERIALIZE(t) - KV_SERIALIZE(h) + KV_SERIALIZE(a) DOC_DSCR("Mined amount(block reward)") DOC_EXMP(1000000000000) DOC_END + KV_SERIALIZE(t) DOC_DSCR("Timestamp") DOC_EXMP(1712683857) DOC_END + KV_SERIALIZE(h) DOC_DSCR("height") DOC_EXMP(102000) DOC_END END_KV_SERIALIZE_MAP() }; @@ -357,7 +359,7 @@ namespace wallet_public { std::vector mined_entries; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(mined_entries) + KV_SERIALIZE(mined_entries) DOC_DSCR("Mined blocks entries.") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; @@ -368,8 +370,8 @@ namespace wallet_public std::string seed_password; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(seed_phrase) - KV_SERIALIZE(seed_password) + KV_SERIALIZE(seed_phrase) DOC_DSCR("Mnemonic seed phrase used for wallet recovery or generation.") DOC_EXMP("girlfriend unlike mutter tightly social silent expect constant bid nowhere reach flower bite salt lightning conversation dog rush quietly become usually midnight each secret offer class") DOC_END + KV_SERIALIZE(seed_password) DOC_DSCR("Password used to encrypt or decrypt the mnemonic seed phrase, if applicable.") DOC_EXMP("0101010103") DOC_END END_KV_SERIALIZE_MAP() }; @@ -381,15 +383,17 @@ namespace wallet_public bool tracking; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(syntax_correct) - KV_SERIALIZE(require_password) - KV_SERIALIZE(hash_sum_matched) - KV_SERIALIZE(tracking) + KV_SERIALIZE(syntax_correct) DOC_DSCR("Indicates whether the syntax is correct.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(require_password) DOC_DSCR("Indicates whether a password is required.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(hash_sum_matched) DOC_DSCR("Indicates whether the hash sum matches.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(tracking) DOC_DSCR("Indicates whether tracking is enabled.") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; struct COMMAND_RPC_GET_BALANCE { + DOC_COMMAND("Return the balances across all whitelisted assets of the wallet"); + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -412,6 +416,8 @@ namespace wallet_public struct COMMAND_RPC_GET_ADDRESS { + DOC_COMMAND("Obtains wallet's public address"); + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -423,7 +429,7 @@ namespace wallet_public std::string address; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(address) + KV_SERIALIZE(address) DOC_DSCR("string; standard public address of the wallet.") DOC_EXMP("ZxDNaMeZjwCjnHuU5gUNyrP1pM3U5vckbakzzV6dEHyDYeCpW8XGLBFTshcaY8LkG9RQn7FsQx8w2JeJzJwPwuDm2NfixPAXf") DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -432,6 +438,8 @@ namespace wallet_public struct COMMAND_RPC_GET_WALLET_INFO { + DOC_COMMAND("Returns wallet helpful wallet information"); + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -450,26 +458,28 @@ namespace wallet_public uint64_t current_height; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(address) - KV_SERIALIZE(path) - KV_SERIALIZE(transfers_count) - KV_SERIALIZE(transfer_entries_count) - KV_SERIALIZE(is_whatch_only) - KV_SERIALIZE(has_bare_unspent_outputs) - KV_SERIALIZE(utxo_distribution) - KV_SERIALIZE(current_height) + KV_SERIALIZE(address) DOC_DSCR("string; standard public address of the wallet.") DOC_EXMP("ZxDNaMeZjwCjnHuU5gUNyrP1pM3U5vckbakzzV6dEHyDYeCpW8XGLBFTshcaY8LkG9RQn7FsQx8w2JeJzJwPwuDm2NfixPAXf") DOC_END + KV_SERIALIZE(path) DOC_DSCR("Path to wallet file location") DOC_EXMP("/some/path/to/wallet/file.zan") DOC_END + KV_SERIALIZE(transfers_count) DOC_DSCR("Represent number of transactions that happened to this wallet(basically tx history)") DOC_EXMP(11) DOC_END + KV_SERIALIZE(transfer_entries_count) DOC_DSCR("Represent number of internal entries count(each entry represent tx output that have been addressed to this wallet)") DOC_EXMP(24) DOC_END + KV_SERIALIZE(is_whatch_only) DOC_DSCR("Shows if the wallet is watch-only") DOC_EXMP(false) DOC_END + KV_SERIALIZE(has_bare_unspent_outputs) DOC_DSCR("Shows if the wallet still has UTXO from pre-zarcanum era") DOC_EXMP(false) DOC_END + KV_SERIALIZE(utxo_distribution) DOC_DSCR("UTXO distribution for this particular wallet: disabled right now") DOC_EXMP_AUTO(1, "1") DOC_END + KV_SERIALIZE(current_height) DOC_DSCR("Current wallet/daemon height") DOC_EXMP(112132) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_GET_WALLET_RESTORE_INFO { + DOC_COMMAND("Return wallet seed, which could be password-protected(seed secured with passphrase) or open(unsecured seed). If no password provided it returns open (unsecured) seed. "); + struct request { std::string seed_password; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(seed_password) + KV_SERIALIZE(seed_password) DOC_DSCR("Password to secure wallet's seed") DOC_EXMP("010101012") DOC_END END_KV_SERIALIZE_MAP() }; @@ -478,13 +488,15 @@ namespace wallet_public std::string seed_phrase; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(seed_phrase) + KV_SERIALIZE(seed_phrase) DOC_DSCR("Wallet's seed(secured with password if it was provided in argument)") DOC_EXMP("girlfriend unlike offer mutter tightly social silent expect constant bid nowhere reach flower bite salt becomeconversation dog rush quietly become usually lightning midnight each secret class") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_GET_SEED_PHRASE_INFO { + DOC_COMMAND("This call is used to validate seed phrase and to fetch additional information about it"); + typedef seed_info_param request; typedef seed_phrase_info response; }; @@ -509,6 +521,8 @@ namespace wallet_public struct COMMAND_RPC_GET_MINING_HISTORY { + DOC_COMMAND("Returns wallet statistic on mining. As an argument 'v' it receive timestamp from which history is reviewed"); + typedef currency::struct_with_one_t_type request; typedef wallet_public::mining_history response; }; @@ -519,6 +533,8 @@ namespace wallet_public struct COMMAND_RPC_GET_RECENT_TXS_AND_INFO2 { + DOC_COMMAND("Returns wallet history of transactions V2(post-zarcanum version)"); + struct request { @@ -541,12 +557,12 @@ namespace wallet_public std::string order; // "FROM_BEGIN_TO_END" or "FROM_END_TO_BEGIN" BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(offset) - KV_SERIALIZE(count) - KV_SERIALIZE(update_provision_info) - KV_SERIALIZE(exclude_mining_txs) - KV_SERIALIZE(exclude_unconfirmed) - KV_SERIALIZE(order) + KV_SERIALIZE(offset) DOC_DSCR("Offset from what index to start fetching transfers entries(if filters are used then last_item_index could be used from previous call)") DOC_EXMP(0) DOC_END + KV_SERIALIZE(count) DOC_DSCR("How many items to fetch, if items fetched is less then count, then it enumeration is over") DOC_EXMP(100) DOC_END + KV_SERIALIZE(update_provision_info) DOC_DSCR("If update pi is required, could be false only if need to optimize performance(appliable for a veru big wallets)") DOC_EXMP(true) DOC_END + KV_SERIALIZE(exclude_mining_txs) DOC_DSCR("Exclude mining/staking transactions from results(last_item_index should be used for subsequential calls)") DOC_EXMP(false) DOC_END + KV_SERIALIZE(exclude_unconfirmed) DOC_DSCR("Do not include uncomfirmed transactions in results (it also not included is offset is non zero)") DOC_EXMP(false) DOC_END + KV_SERIALIZE(order) DOC_DSCR("Order: \"FROM_BEGIN_TO_END\" or \"FROM_END_TO_BEGIN\"") DOC_EXMP("FROM_END_TO_BEGIN") DOC_END END_KV_SERIALIZE_MAP() }; @@ -569,6 +585,8 @@ namespace wallet_public struct COMMAND_RPC_GET_RECENT_TXS_AND_INFO { + DOC_COMMAND("Returns wallet history of transactions"); + typedef COMMAND_RPC_GET_RECENT_TXS_AND_INFO2::request request; struct response @@ -579,27 +597,26 @@ namespace wallet_public uint64_t last_item_index; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(pi) - KV_SERIALIZE(transfers) - KV_SERIALIZE(total_transfers) - KV_SERIALIZE(last_item_index) + KV_SERIALIZE(pi) DOC_DSCR("Additiona details about balance state") DOC_END + KV_SERIALIZE(transfers) DOC_DSCR("Transfers history array") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(total_transfers) DOC_DSCR("Total number of transfers in the tx history") DOC_EXMP(1) DOC_END + KV_SERIALIZE(last_item_index) DOC_DSCR("Index of last returned item(might be needed if filters are used)") DOC_EXMP(1) DOC_END END_KV_SERIALIZE_MAP() }; }; - - - struct COMMAND_RPC_REGISTER_ALIAS { + DOC_COMMAND("Register an alias for the address"); + struct request { currency::alias_rpc_details al; crypto::secret_key authority_key; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(al) - KV_SERIALIZE_POD_AS_HEX_STRING(authority_key) + KV_SERIALIZE(al) DOC_DSCR("Alias details") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(authority_key) DOC_DSCR("Key for registering aliases shorter than 6 letters (team)") DOC_END END_KV_SERIALIZE_MAP() }; @@ -608,7 +625,7 @@ namespace wallet_public crypto::hash tx_id; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) DOC_DSCR("If success - transactions that performs registration(alias becomes available after few confirmations)") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -620,14 +637,16 @@ namespace wallet_public std::string address; crypto::public_key asset_id = currency::native_coin_asset_id; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(amount) - KV_SERIALIZE(address) - KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) + KV_SERIALIZE(amount) DOC_DSCR("Amount to transfer to destination") DOC_EXMP(10000000000000) DOC_END + KV_SERIALIZE(address) DOC_DSCR("Destination address") DOC_EXMP("ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Asset id to transfer") DOC_EXMP("cc608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852") DOC_END END_KV_SERIALIZE_MAP() }; struct COMMAND_RPC_TRANSFER { + DOC_COMMAND("Make new payment transaction from the wallet"); + struct request { std::list destinations; @@ -642,15 +661,15 @@ namespace wallet_public bool service_entries_permanent; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(destinations) - KV_SERIALIZE(fee) - KV_SERIALIZE(mixin) - KV_SERIALIZE(payment_id) - KV_SERIALIZE(comment) - KV_SERIALIZE(push_payer) - KV_SERIALIZE(hide_receiver) - KV_SERIALIZE(service_entries) - KV_SERIALIZE(service_entries_permanent) + KV_SERIALIZE(destinations) DOC_DSCR("List of destinations") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(fee) DOC_DSCR("Fee to be paid on behalf of sender's wallet(paid in native coins)") DOC_EXMP_AUTO(10000000000) DOC_END + KV_SERIALIZE(mixin) DOC_DSCR("Specifies number of mixins(decoys) that would be used to create input, actual for pre-zarcanum outputs, for post-zarcanum outputs instead of this option, number that is defined by network hard rules(15+)") DOC_EXMP(15) DOC_END + KV_SERIALIZE(payment_id) DOC_DSCR("Hex-encoded payment_id, that normally used for user database by exchanges") DOC_EXMP_AUTO("1dfe5a88ff9effb3") DOC_END + KV_SERIALIZE(comment) DOC_DSCR("Text comment that is displayed in UI") DOC_EXMP_AUTO("Thanks for the coffe") DOC_END + KV_SERIALIZE(push_payer) DOC_DSCR("Reveal information about sender of this transaction, basically add sender address to transaction in encrypted way, so only receiver can see who sent transaction") DOC_EXMP(false) DOC_END + KV_SERIALIZE(hide_receiver) DOC_DSCR("This add to transaction information about remote address(destination), might be needed when the wallet restored from seed phrase and fully resynched, if this option were true, then sender won't be able to see remote address for sent transactions anymore.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(service_entries) DOC_DSCR("Service entries that might be used by different apps that works on top of Zano network, not part of consensus") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(service_entries_permanent) DOC_DSCR("Point to wallet that service_entries should be placed to 'extra' section of transaction(which won't be pruned after checkpoints)") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; @@ -670,6 +689,8 @@ namespace wallet_public struct COMMAND_RPC_STORE { + DOC_COMMAND("Store wallet's data to file"); + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -681,7 +702,7 @@ namespace wallet_public uint64_t wallet_file_size; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(wallet_file_size) + KV_SERIALIZE(wallet_file_size) DOC_DSCR("Resulting file size in bytes") DOC_EXMP(232243) DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -695,24 +716,27 @@ namespace wallet_public uint64_t unlock_time; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payment_id) - KV_SERIALIZE(tx_hash) - KV_SERIALIZE(amount) - KV_SERIALIZE(block_height) - KV_SERIALIZE(unlock_time) + KV_SERIALIZE(payment_id) DOC_DSCR("Payment id that related to this payment") DOC_EXMP("1dfe5a88ff9effb3") DOC_END + KV_SERIALIZE(tx_hash) DOC_DSCR("Transaction ID that is holding this payment") DOC_EXMP("01220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a93") DOC_END + KV_SERIALIZE(amount) DOC_DSCR("Amount of native coins transfered") DOC_EXMP(100000000000) DOC_END + KV_SERIALIZE(block_height) DOC_DSCR("Block height that holds transaction") DOC_EXMP(12321) DOC_END + KV_SERIALIZE(unlock_time) DOC_DSCR("Timestamp/blocknumber after which this money would become availabe, recommended don't count transfers that has this field not 0") DOC_EXMP(0) DOC_END END_KV_SERIALIZE_MAP() }; struct COMMAND_RPC_GET_PAYMENTS { + DOC_COMMAND("Gets list of incoming transfers by a given payment ID"); + + struct request { std::string payment_id; // hex-encoded bool allow_locked_transactions; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payment_id) - KV_SERIALIZE(allow_locked_transactions) + KV_SERIALIZE(payment_id) DOC_DSCR("Payment id that is used to identify transfers") DOC_EXMP("1dfe5a88ff9effb3") DOC_END + KV_SERIALIZE(allow_locked_transactions) DOC_DSCR("Says to wallet if locked transfers should be included or not (false is strongly recomennded)") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; @@ -721,13 +745,16 @@ namespace wallet_public std::list payments; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payments) + KV_SERIALIZE(payments) DOC_DSCR("Array of payments that connected to given payment_id") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_GET_BULK_PAYMENTS { + DOC_COMMAND("Gets list of incoming transfers by a given multiple payment_ids"); + + struct request { std::vector payment_ids; @@ -735,30 +762,25 @@ namespace wallet_public bool allow_locked_transactions; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payment_ids) - KV_SERIALIZE(min_block_height) - KV_SERIALIZE(allow_locked_transactions) + KV_SERIALIZE(payment_ids) DOC_DSCR("Payment ids that is used to identify transfers") DOC_EXMP_AUTO(2, "1dfe5a88ff9effb3") DOC_END + KV_SERIALIZE(min_block_height) DOC_DSCR("Minimal block height to consider") DOC_EXMP(0) DOC_END + KV_SERIALIZE(allow_locked_transactions) DOC_DSCR("Says to wallet if locked transfers should be included or not (false is strongly recomennded)") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; - struct response - { - std::list payments; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payments) - END_KV_SERIALIZE_MAP() - }; + typedef COMMAND_RPC_GET_PAYMENTS::response response; }; struct COMMAND_RPC_MAKE_INTEGRATED_ADDRESS { + DOC_COMMAND("Generate integrated address"); + struct request { std::string payment_id; // hex-encoded BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payment_id) + KV_SERIALIZE(payment_id) DOC_DSCR("Hex-encoded Payment ID to be associated with the this address. If empty then wallet would generate new payment id using system random library") DOC_EXMP("1dfe5a88ff9effb3") DOC_END END_KV_SERIALIZE_MAP() }; @@ -768,20 +790,22 @@ namespace wallet_public std::string payment_id; // hex-encoded BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(integrated_address) - KV_SERIALIZE(payment_id) + KV_SERIALIZE(integrated_address) DOC_DSCR("Integrated address combining a standard address and payment ID, if applicable.") DOC_EXMP("iZ2EMyPD7g28hgBfboZeCENaYrHBYZ1bLFi5cgWvn4WJLaxfgs4kqG6cJi9ai2zrXWSCpsvRXit14gKjeijx6YPCLJEv6Fx4rVm1hdAGQFis") DOC_END + KV_SERIALIZE(payment_id) DOC_DSCR("Payment ID associated with the this address.") DOC_EXMP("1dfe5a88ff9effb3") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS { + DOC_COMMAND("Decode integrated address"); + struct request { std::string integrated_address; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(integrated_address) + KV_SERIALIZE(integrated_address) DOC_DSCR("Integrated address combining a standard address and payment ID, if applicable.") DOC_EXMP("iZ2EMyPD7g28hgBfboZeCENaYrHBYZ1bLFi5cgWvn4WJLaxfgs4kqG6cJi9ai2zrXWSCpsvRXit14gKjeijx6YPCLJEv6Fx4rVm1hdAGQFis") DOC_END END_KV_SERIALIZE_MAP() }; @@ -791,14 +815,16 @@ namespace wallet_public std::string payment_id; // hex-encoded BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(standard_address) - KV_SERIALIZE(payment_id) + KV_SERIALIZE(standard_address) DOC_DSCR("Standart address.") DOC_EXMP("ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END + KV_SERIALIZE(payment_id) DOC_DSCR("Hex-encoded payment id") DOC_EXMP("1dfe5a88ff9effb3") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_SWEEP_BELOW { + DOC_COMMAND("Tries to transfer all coins with amount below the given limit to the given address"); + struct request { uint64_t mixin; @@ -808,11 +834,11 @@ namespace wallet_public uint64_t fee; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(mixin) - KV_SERIALIZE(address) - KV_SERIALIZE(amount) - KV_SERIALIZE(payment_id_hex) - KV_SERIALIZE(fee) + KV_SERIALIZE(mixin) DOC_DSCR("Number of outputs from the blockchain to mix with when sending a transaction to improve privacy.") DOC_EXMP(15) DOC_END + KV_SERIALIZE(address) DOC_DSCR("Public address for sending or receiving native coins.") DOC_EXMP("ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END + KV_SERIALIZE(amount) DOC_DSCR("Threshold amount of native coins to sweep.") DOC_EXMP(1000000000000) DOC_END + KV_SERIALIZE(payment_id_hex) DOC_DSCR("Payment ID associated with the transaction in hexadecimal format.") DOC_EXMP("1dfe5a88ff9effb3") DOC_END + KV_SERIALIZE(fee) DOC_DSCR("Transaction fee required for processing the transaction.") DOC_EXMP(10000000000) DOC_END END_KV_SERIALIZE_MAP() }; @@ -826,18 +852,21 @@ namespace wallet_public uint64_t amount_swept; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_hash) - KV_SERIALIZE(tx_unsigned_hex) - KV_SERIALIZE(outs_total) - KV_SERIALIZE(amount_total) - KV_SERIALIZE(outs_swept) - KV_SERIALIZE(amount_swept) + KV_SERIALIZE(tx_hash) DOC_DSCR("Transaction ID (hash) format.") DOC_EXMP("01220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a93") DOC_END + KV_SERIALIZE(tx_unsigned_hex) DOC_DSCR("Unsigned transaction data in hexadecimal format.") DOC_EXMP("8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a736") DOC_END + KV_SERIALIZE(outs_total) DOC_DSCR("Total number of outputs in the transaction.") DOC_EXMP(10) DOC_END + KV_SERIALIZE(amount_total) DOC_DSCR("Total amount of native coins involved in the transaction.") DOC_EXMP(100000000000) DOC_END + KV_SERIALIZE(outs_swept) DOC_DSCR("Number of outputs swept in the transaction.") DOC_EXMP(112) DOC_END + KV_SERIALIZE(amount_swept) DOC_DSCR("Amount of native coins swept in the transaction.") DOC_EXMP(101000000000) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_GET_BARE_OUTS_STATS { + DOC_COMMAND("Return information about wallet's pre-zarcanum era outputs. Those outputs should be converted to post-zarcanum varian with trnasfering it sooner or later. (Only outputs that have been created in Zarcanum era can participaet in staking)"); + + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -852,16 +881,19 @@ namespace wallet_public uint64_t txs_count; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(total_bare_outs) - KV_SERIALIZE(total_amount) - KV_SERIALIZE(expected_total_fee) - KV_SERIALIZE(txs_count) + KV_SERIALIZE(total_bare_outs) DOC_DSCR("Total number of inspent bare outputs in the wallet.") DOC_EXMP(112) DOC_END + KV_SERIALIZE(total_amount) DOC_DSCR("Total amount of native coins involved in bare outputs.") DOC_EXMP(12000000000000) DOC_END + KV_SERIALIZE(expected_total_fee) DOC_DSCR("Expected total transaction fee required for processing the transaction.") DOC_EXMP(10000000000) DOC_END + KV_SERIALIZE(txs_count) DOC_DSCR("Total number of transactions needed to convert all bare outputs .") DOC_EXMP(2) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_SWEEP_BARE_OUTS { + DOC_COMMAND("Execute transactions needed be convert all bare(pre-zarcanum) outputs to post-zarcanum outputs. (Only outputs that have been created in Zarcanum era can participaet in staking)"); + + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -876,22 +908,24 @@ namespace wallet_public uint64_t txs_sent; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(bare_outs_swept) - KV_SERIALIZE(amount_swept) - KV_SERIALIZE(fee_spent) - KV_SERIALIZE(txs_sent) + KV_SERIALIZE(bare_outs_swept) DOC_DSCR("Number of bare outputs swept in the transactions.") DOC_EXMP(112) DOC_END + KV_SERIALIZE(amount_swept) DOC_DSCR("Amount of native coins swept in the transactions.") DOC_EXMP(12000000000000) DOC_END + KV_SERIALIZE(fee_spent) DOC_DSCR("Total fee spent on the transactions.") DOC_EXMP(10000000000) DOC_END + KV_SERIALIZE(txs_sent) DOC_DSCR("Total number of transactions sent.") DOC_EXMP(2) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_SIGN_TRANSFER { + DOC_COMMAND("Sign transaction with the wallet's keys"); + struct request { std::string tx_unsigned_hex; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_unsigned_hex) + KV_SERIALIZE(tx_unsigned_hex) DOC_DSCR("Unsigned transaction hex-encoded blob.") DOC_EXMP("8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a736") DOC_END END_KV_SERIALIZE_MAP() }; @@ -901,22 +935,22 @@ namespace wallet_public std::string tx_hash; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_signed_hex) - KV_SERIALIZE(tx_hash) + KV_SERIALIZE(tx_signed_hex) DOC_DSCR("Signed transaction hex-encoded blob.") DOC_EXMP("8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a736") DOC_END + KV_SERIALIZE(tx_hash) DOC_DSCR("Signed transaction hash.") DOC_EXMP("01220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a93") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_SUBMIT_TRANSFER { + DOC_COMMAND("Relay signed transaction over the network"); + struct request { - //std::string tx_unsigned_hex; std::string tx_signed_hex; BEGIN_KV_SERIALIZE_MAP() - //KV_SERIALIZE(tx_unsigned_hex) - KV_SERIALIZE(tx_signed_hex) + KV_SERIALIZE(tx_signed_hex) DOC_DSCR("Signed transaction hex-encoded blob.") DOC_EXMP("8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a7368304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9334f158a736") DOC_END END_KV_SERIALIZE_MAP() }; @@ -925,7 +959,7 @@ namespace wallet_public std::string tx_hash; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_hash) + KV_SERIALIZE(tx_hash) DOC_DSCR("Signed transaction hash.") DOC_EXMP("01220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a93") DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -1163,10 +1197,18 @@ namespace wallet_public }; //-------------------- - typedef currency::COMMAND_RPC_GET_OFFERS_EX COMMAND_MARKETPLACE_GET_MY_OFFERS; + struct COMMAND_MARKETPLACE_GET_MY_OFFERS + { + DOC_COMMAND("Fetch wallet's offers listed in the marketplace with given filters"); + + typedef currency::COMMAND_RPC_GET_OFFERS_EX::request request; + typedef currency::COMMAND_RPC_GET_OFFERS_EX::response response; + }; struct COMMAND_MARKETPLACE_PUSH_OFFER { + DOC_COMMAND("Creates new offer and publish it on the blockchain"); + struct request { bc_services::offer_details_ex od; @@ -1183,14 +1225,16 @@ namespace wallet_public uint64_t tx_blob_size; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_hash) - KV_SERIALIZE(tx_blob_size) + KV_SERIALIZE(tx_hash) DOC_DSCR("Transaction hash") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END + KV_SERIALIZE(tx_blob_size) DOC_DSCR("Size of the transaction blob") DOC_EXMP(1234) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER { + DOC_COMMAND("Updates existing offer that this wallet created, and publish updated version on the blockchain"); + struct request { crypto::hash tx_id; @@ -1198,8 +1242,8 @@ namespace wallet_public bc_services::offer_details_ex od; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) - KV_SERIALIZE(no) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) DOC_DSCR("Transaction ID represented as a hexadecimal string") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END + KV_SERIALIZE(no) DOC_DSCR("Number of offer entrie inside transacton(likely 0)") DOC_EXMP(0) DOC_END KV_SERIALIZE(od) END_KV_SERIALIZE_MAP() }; @@ -1211,14 +1255,16 @@ namespace wallet_public uint64_t tx_blob_size; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_hash) - KV_SERIALIZE(tx_blob_size) + KV_SERIALIZE(tx_hash) DOC_DSCR("Transaction hash") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END + KV_SERIALIZE(tx_blob_size) DOC_DSCR("Size of the transaction blob") DOC_EXMP(1232) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_MARKETPLACE_CANCEL_OFFER { + DOC_COMMAND("Cancel existing offer that this wallet created(it actually create transaction that says that existing order got canceled)"); + struct request { crypto::hash tx_id; @@ -1226,9 +1272,9 @@ namespace wallet_public uint64_t fee; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) - KV_SERIALIZE(no) - KV_SERIALIZE(fee) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) DOC_DSCR("Transaction ID represented as a hexadecimal string") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END + KV_SERIALIZE(no) DOC_DSCR("Number of offer entrie inside transacton(likely 0)") DOC_EXMP(0) DOC_END + KV_SERIALIZE(fee) DOC_DSCR("Fee for operation") DOC_EXMP(10000000000) DOC_END END_KV_SERIALIZE_MAP() }; @@ -1239,36 +1285,33 @@ namespace wallet_public uint64_t tx_blob_size; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(tx_hash) - KV_SERIALIZE(tx_blob_size) + KV_SERIALIZE(tx_hash) DOC_DSCR("Transaction hash") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END + KV_SERIALIZE(tx_blob_size) DOC_DSCR("Size of the transaction blob") DOC_EXMP(1232) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_SEARCH_FOR_TRANSACTIONS { + DOC_COMMAND("Search for transacrions in the wallet by few parameters"); struct request { crypto::hash tx_id; bool in; bool out; - //bool pending; - //bool failed; bool pool; bool filter_by_height; uint64_t min_height; uint64_t max_height; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) - KV_SERIALIZE(in) - KV_SERIALIZE(out) - //KV_SERIALIZE(pending) - //KV_SERIALIZE(failed) - KV_SERIALIZE(pool) - KV_SERIALIZE(filter_by_height) - KV_SERIALIZE(min_height) - KV_SERIALIZE(max_height) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) DOC_DSCR("Transaction ID represented as a hexadecimal string.") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END + KV_SERIALIZE(in) DOC_DSCR("Search over incoming transactions.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(out) DOC_DSCR("Search over outgoing transactions.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(pool) DOC_DSCR("Search over pool transactions.") DOC_EXMP(false) DOC_END + KV_SERIALIZE(filter_by_height) DOC_DSCR("Do filter transactions by height or not.") DOC_EXMP(true) DOC_END + KV_SERIALIZE(min_height) DOC_DSCR("Minimum height for filtering transactions.") DOC_EXMP(11000) DOC_END + KV_SERIALIZE(max_height) DOC_DSCR("Maximum height for filtering transactions.") DOC_EXMP(20000) DOC_END END_KV_SERIALIZE_MAP() }; @@ -1276,38 +1319,32 @@ namespace wallet_public { std::list in; std::list out; - //std::list pending; - //std::list failed; std::list pool; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(in) - KV_SERIALIZE(out) - //KV_SERIALIZE(pending) - //KV_SERIALIZE(failed) - KV_SERIALIZE(pool) + KV_SERIALIZE(in) DOC_DSCR("List of incoming transactions.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(out) DOC_DSCR("List of outgoing transactions.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(pool) DOC_DSCR("List of pool transactions.") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_RPC_SEARCH_FOR_TRANSACTIONS_LEGACY - { + { + DOC_COMMAND("Search for transacrions in the wallet by few parameters(legacy version)"); + typedef COMMAND_RPC_SEARCH_FOR_TRANSACTIONS::request request; struct response { std::list in; std::list out; - //std::list pending; - //std::list failed; std::list pool; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(in) - KV_SERIALIZE(out) - //KV_SERIALIZE(pending) - //KV_SERIALIZE(failed) - KV_SERIALIZE(pool) + KV_SERIALIZE(in) DOC_DSCR("List of incoming transactions.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(out) DOC_DSCR("List of outgoing transactions.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(pool) DOC_DSCR("List of pool transactions.") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -1475,17 +1512,15 @@ namespace wallet_public { std::vector to_finalizer; //assets that addressed to receiver of proposal (aka Bob, aka "finalizer") and funded by side that creating proposal (aka Alice, aka "initiator") std::vector to_initiator; //assets addressed to initiator of proposal (aka Alice, aka "initiator") and expected to be funded by the side that receiving proposal (aka Bob, aka "finalizer") - uint64_t mixins; + //uint64_t mixins; uint64_t fee_paid_by_a; //uint64_t expiration_time; BEGIN_KV_SERIALIZE_MAP() - - KV_SERIALIZE(to_finalizer) - KV_SERIALIZE(to_initiator) - KV_SERIALIZE(mixins) - KV_SERIALIZE(fee_paid_by_a) - //KV_SERIALIZE(expiration_time) + KV_SERIALIZE(to_finalizer) DOC_DSCR("Assets sent to the finalizer") DOC_EXMP_AUTO(1, asset_funds{ epee::transform_str_to_t_pod("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc"), 1000000000000}) DOC_END + KV_SERIALIZE(to_initiator) DOC_DSCR("Assets sent to the initiator") DOC_EXMP_AUTO(1, asset_funds{ currency::native_coin_asset_id, 10000000000}) DOC_END + //KV_SERIALIZE(mixins) DOC_DSCR("Number of mixins used") DOC_EXMP() DOC_END + KV_SERIALIZE(fee_paid_by_a) DOC_DSCR("Fee paid by party A(initiator)") DOC_EXMP(10000000000) DOC_END END_KV_SERIALIZE_MAP() }; @@ -1529,13 +1564,16 @@ namespace wallet_public struct COMMAND_IONIC_SWAP_GENERATE_PROPOSAL { + DOC_COMMAND("Generates ionic swap proposal according to details provided in request, result present as hex-encoded blob, that should be passed to recepient to validate this proposal and executing on it") + struct request { ionic_swap_proposal_info proposal; std::string destination_address; + BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(proposal) - KV_SERIALIZE(destination_address) + KV_SERIALIZE(proposal) DOC_DSCR("Proposal details") DOC_END + KV_SERIALIZE(destination_address) DOC_DSCR("Destination address") DOC_EXMP("ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1545,19 +1583,22 @@ namespace wallet_public std::string hex_raw_proposal; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(hex_raw_proposal) + KV_SERIALIZE(hex_raw_proposal) DOC_DSCR("Hex-encoded proposal raw data(encrypted with common shared key). Includes half-created transaction template and some extra information that would be needed counterparty to finialize and sign transaction") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO { + DOC_COMMAND("Reads hex-encoded ionic swap proposal info, generated by other user and addressed to this wallet") + + struct request { std::string hex_raw_proposal; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(hex_raw_proposal) + KV_SERIALIZE(hex_raw_proposal) DOC_DSCR("Hex-encoded proposal raw data(encrypted with common shared key). Includes half-created transaction template and some extra information that would be needed counterparty to finialize and sign transaction") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1567,19 +1608,22 @@ namespace wallet_public ionic_swap_proposal_info proposal; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(proposal) + KV_SERIALIZE(proposal) DOC_DSCR("Proposal details") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL { + DOC_COMMAND("This essential command actually execute proposal that was sent by counter party, by completing and signing transaction template that was in proposal, and sending it to the network.") + + struct request { std::string hex_raw_proposal; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(hex_raw_proposal) + KV_SERIALIZE(hex_raw_proposal) DOC_DSCR("Hex-encoded proposal raw data(encrypted with common shared key). Includes half-created transaction template and some extra information that would be needed counterparty to finialize and sign transaction") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1589,7 +1633,7 @@ namespace wallet_public crypto::hash result_tx_id; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(result_tx_id) + KV_SERIALIZE_POD_AS_HEX_STRING(result_tx_id) DOC_DSCR("Result transaction id") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -1607,14 +1651,14 @@ namespace wallet_public bool has_bare_unspent_outputs; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(balances) - KV_SERIALIZE(mined_total) - KV_SERIALIZE(address) - KV_SERIALIZE(view_sec_key) - KV_SERIALIZE(path) - KV_SERIALIZE(is_auditable) - KV_SERIALIZE(is_watch_only) - KV_SERIALIZE(has_bare_unspent_outputs) + KV_SERIALIZE(balances) DOC_DSCR("Balances hold by this wallet") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(mined_total) DOC_DSCR("Total amount mined") DOC_EXMP(1000000000000) DOC_END + KV_SERIALIZE(address) DOC_DSCR("Address") DOC_EXMP("ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END + KV_SERIALIZE(view_sec_key) DOC_DSCR("View secret key") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END + KV_SERIALIZE(path) DOC_DSCR("Path to wallet file") DOC_EXMP("/some/path/to/wallet/file.zan") DOC_END + KV_SERIALIZE(is_auditable) DOC_DSCR("Flag indicating whether the wallet is auditable") DOC_EXMP(false) DOC_END + KV_SERIALIZE(is_watch_only) DOC_DSCR("Flag indicating whether the wallet is watch-only") DOC_EXMP(false) DOC_END + KV_SERIALIZE(has_bare_unspent_outputs) DOC_DSCR("Flag indicating whether the wallet has bare unspent outputs(pre-zarcanum outputs)") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; @@ -1643,13 +1687,15 @@ namespace wallet_public BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(wi) - KV_SERIALIZE(wallet_id) + KV_SERIALIZE(wallet_id) DOC_DSCR("Wallet ID") DOC_EXMP() DOC_END END_KV_SERIALIZE_MAP() }; struct COMMAND_MW_GET_WALLETS { + DOC_COMMAND("Get loaded wallets list, userful for multi-wallet API") + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -1661,19 +1707,21 @@ namespace wallet_public std::vector wallets; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(wallets) + KV_SERIALIZE(wallets) DOC_DSCR("Array of wallets") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_MW_SELECT_WALLET { + DOC_COMMAND("Select curent active wallet, after that all wallet RPC call would be addressed to this wallet") + struct request { uint64_t wallet_id; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(wallet_id) + KV_SERIALIZE(wallet_id) DOC_DSCR("Wallet id") DOC_EXMP_AUTO(2) DOC_END END_KV_SERIALIZE_MAP() }; @@ -1682,19 +1730,21 @@ namespace wallet_public { std::string status; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) + KV_SERIALIZE(status) DOC_DSCR("Result (OK if success)") DOC_EXMP(API_RETURN_CODE_OK) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_SIGN_MESSAGE { + DOC_COMMAND("Trivially sign base64 encoded data message using wallet spend key") + struct request { std::string buff; //base64 encoded data BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(buff) + KV_SERIALIZE(buff) DOC_DSCR("base64 encoded data message to be signed") DOC_EXMP("ZGNjc2Ztc2xrZm12O2xrZm12OydlbGtmdm0nbGtmbXY=") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1705,20 +1755,22 @@ namespace wallet_public crypto::public_key pkey = currency::null_pkey; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(sig) - KV_SERIALIZE_POD_AS_HEX_STRING(pkey) + KV_SERIALIZE_POD_AS_HEX_STRING(sig) DOC_DSCR("Signature represented as a hexadecimal string") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(pkey) DOC_DSCR("Wallet's public key represented as a hexadecimal string") DOC_EXMP("97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_ENCRYPT_DATA { + DOC_COMMAND("Trivially encrypt base64 encoded data message with chacha using wallet spend key") + struct request { std::string buff; //base64 encoded data BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(buff) + KV_SERIALIZE(buff) DOC_DSCR("base64 encoded data message to be encrypted") DOC_EXMP("ZGNjc2Ztc2xrZm12O2xrZm12OydlbGtmdm0nbGtmbXY=") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1726,19 +1778,20 @@ namespace wallet_public { std::string res_buff; //base64 encoded encrypted data BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(res_buff) + KV_SERIALIZE(res_buff) DOC_DSCR("base64 encoded resulted data message") DOC_EXMP("ZGNjc2Ztc2xrZm12O2xrZm12OydlbGtmdm0nbGtmbXY=") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_DECRYPT_DATA { + DOC_COMMAND("Trivially decrypt base64 encoded data message with chacha using wallet spend key") struct request { std::string buff; //base64 encoded encrypted data BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(buff) + KV_SERIALIZE(buff) DOC_DSCR("base64 encoded data message to be decrypted") DOC_EXMP("ZGNjc2Ztc2xrZm12O2xrZm12OydlbGtmdm0nbGtmbXY=") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1748,22 +1801,23 @@ namespace wallet_public std::string res_buff; //base64 encoded data BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(res_buff) + KV_SERIALIZE(res_buff) DOC_DSCR("base64 encoded resulted data message") DOC_EXMP("ZGNjc2Ztc2xrZm12O2xrZm12OydlbGtmdm0nbGtmbXY=") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_PROXY_TO_DAEMON { + DOC_COMMAND("Proxy call to daemon(node), might be not effective in some cases, so need to be carefull with use of it") + struct request { - std::string uri; std::string base64_body; //base64 encoded body BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(uri) - KV_SERIALIZE(base64_body) + KV_SERIALIZE(uri) DOC_DSCR("URI for daemon API") DOC_EXMP("/json_rpc") DOC_END + KV_SERIALIZE(base64_body) DOC_DSCR("Base64 encoded request body") DOC_EXMP("ewogICAgImpzb25ycGMiOiAiMi4wIiwKICAgICJpZCI6IDAsCiAgICAibWV0aG9kIjogImdldF9taW5pbmdfaGlzdG9yeSIKfQ==") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1773,8 +1827,8 @@ namespace wallet_public int32_t response_code; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(base64_body) - KV_SERIALIZE(response_code) + KV_SERIALIZE(base64_body) DOC_DSCR("Base64 encoded daemon response body") DOC_EXMP("ewogICJpZCI6IDAsCiAgImpzb25ycGMiOiAiMi4wIiwKICAicmVzdWx0IjogewogICAgInBheW1lbnRzIjogWwogICAgICB7CiAgICAgICAgInBheW1lbnRfaWQiOiAiMDAwMDAwMDBmZjAwZmYwMCIsCiAgICAgICAgImFtb3VudCI6IDEwMDAwMDAwMCwKICAgICAgICAiYmxvY2tfaGVpZ2h0IjogMjAyNTU2LAogICAgICAgICJ0eF9oYXNoIjogIjAxMjIwZTgzMDRkNDZiOTQwYTg2ZTM4M2Q1NWNhNTg4N2IzNGYxNThhNzM2NWJiY2RkMTdjNWEzMDU4MTRhOTMiLAogICAgICAgICJ1bmxvY2tfdGltZSI6IDAKICAgICAgfSwKICAgICAgewogICAgICAgICJwYXltZW50X2lkIjogIjAwMDAwMDAwZmYwMGZmMDEiLAogICAgICAgICJhbW91bnQiOiAxMDAwMDAwMDAsCiAgICAgICAgImJsb2NrX2hlaWdodCI6IDIwMjU1NiwKICAgICAgICAidHhfaGFzaCI6ICIwYjVlYjk2ODVjMGMxMWRiNzdlMmNkZDk4NzljOGQzYjgxNTUyM2M2ZTRiZjAzZGNlZTYyYzU4M2I3ZTFmNzcyIiwKICAgICAgICAidW5sb2NrX3RpbWUiOiAwCiAgICAgIH0KICAgIF0KICB9Cn0=") DOC_END + KV_SERIALIZE(response_code) DOC_DSCR("Response code") DOC_EXMP(200) DOC_END END_KV_SERIALIZE_MAP() }; }; @@ -1821,6 +1875,9 @@ namespace wallet_public struct COMMAND_ASSETS_WHITELIST_GET { + DOC_COMMAND("Get whitelisted assets for this wallet, assets descriptors present in any of the lists in results would be present in balance() call results(if those assets are part of the wallet transfers). Assets that are not included in those lists won't be included in balance even if the wallet own inputs with such assets.") + + struct request { BEGIN_KV_SERIALIZE_MAP() @@ -1836,21 +1893,23 @@ namespace wallet_public BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(local_whitelist) - KV_SERIALIZE(global_whitelist) - KV_SERIALIZE(own_assets) + KV_SERIALIZE(local_whitelist) DOC_DSCR("Local whitelist, assets that hase been added to this wallet file manually(!)") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(global_whitelist) DOC_DSCR("Global whitelist, well-known assets with adoption, mantained by the team and community") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(own_assets) DOC_DSCR("Own assets, the ones that is under control of this wallet") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_ASSETS_WHITELIST_ADD { + DOC_COMMAND("Add given asset id to local whitelist. This whitelist is stored with the wallet file and reset in case of wallet resync or restoring wallet from seed phrase.") + struct request { crypto::public_key asset_id = currency::null_pkey; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Asset id that needed to be added to local whitelist, asset_id must exist in the network") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1861,20 +1920,22 @@ namespace wallet_public currency::asset_descriptor_base asset_descriptor; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - KV_SERIALIZE(asset_descriptor) + KV_SERIALIZE(status) DOC_DSCR("Status of the asset") DOC_EXMP("OK") DOC_END + KV_SERIALIZE(asset_descriptor) DOC_DSCR("Details of the asset, recieved from node") DOC_END END_KV_SERIALIZE_MAP() }; }; struct COMMAND_ASSETS_WHITELIST_REMOVE { + DOC_COMMAND("Remove given asset id from local whitelist. This whitelist is stored with the wallet file and reset in case of wallet resync or restoring wallet from seed phrase.") + struct request { crypto::public_key asset_id = currency::null_pkey; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Asset id to be removed from local whitelist") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END END_KV_SERIALIZE_MAP() }; @@ -1884,7 +1945,7 @@ namespace wallet_public std::string status; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) + KV_SERIALIZE(status) DOC_DSCR("Command result (OK if success)") DOC_EXMP(API_RETURN_CODE_OK) DOC_END END_KV_SERIALIZE_MAP() }; }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 9a8dd1d1..4428ee3a 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -284,7 +284,7 @@ namespace tools response.m_response_comment = "Internal Server Error"; return true; } - if (!handle_http_request_map(query_info, response, m_conn_context, call_found, reference_stub) && response.m_response_code == 200) + if (!handle_http_request_map(query_info, response, m_conn_context, call_found) && response.m_response_code == 200) { response.m_response_code = 500; response.m_response_comment = "Internal Server Error"; diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index 7e8f4843..e5451a37 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -117,22 +117,22 @@ namespace tools MAP_JON_RPC_WE("get_mining_history", on_get_mining_history, wallet_public::COMMAND_RPC_GET_MINING_HISTORY) MAP_JON_RPC_WE("register_alias", on_register_alias, wallet_public::COMMAND_RPC_REGISTER_ALIAS) //contracts API - MAP_JON_RPC_WE("contracts_send_proposal", on_contracts_send_proposal, wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL) - MAP_JON_RPC_WE("contracts_accept_proposal", on_contracts_accept_proposal, wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL) - MAP_JON_RPC_WE("contracts_get_all", on_contracts_get_all, wallet_public::COMMAND_CONTRACTS_GET_ALL) - MAP_JON_RPC_WE("contracts_release", on_contracts_release, wallet_public::COMMAND_CONTRACTS_RELEASE) - MAP_JON_RPC_WE("contracts_request_cancel", on_contracts_request_cancel, wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL) - MAP_JON_RPC_WE("contracts_accept_cancel", on_contracts_accept_cancel, wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL) + //MAP_JON_RPC_WE("contracts_send_proposal", on_contracts_send_proposal, wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL) + //MAP_JON_RPC_WE("contracts_accept_proposal", on_contracts_accept_proposal, wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL) + //MAP_JON_RPC_WE("contracts_get_all", on_contracts_get_all, wallet_public::COMMAND_CONTRACTS_GET_ALL) + //MAP_JON_RPC_WE("contracts_release", on_contracts_release, wallet_public::COMMAND_CONTRACTS_RELEASE) + //MAP_JON_RPC_WE("contracts_request_cancel", on_contracts_request_cancel, wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL) + //MAP_JON_RPC_WE("contracts_accept_cancel", on_contracts_accept_cancel, wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL) //marketplace API MAP_JON_RPC_WE("marketplace_get_offers_ex", on_marketplace_get_my_offers, wallet_public::COMMAND_MARKETPLACE_GET_MY_OFFERS) MAP_JON_RPC_WE("marketplace_push_offer", on_marketplace_push_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER) MAP_JON_RPC_WE("marketplace_push_update_offer", on_marketplace_push_update_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER) MAP_JON_RPC_WE("marketplace_cancel_offer", on_marketplace_cancel_offer, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER) //HTLC API - MAP_JON_RPC_WE("atomics_create_htlc_proposal", on_create_htlc_proposal, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL) - MAP_JON_RPC_WE("atomics_get_list_of_active_htlc", on_get_list_of_active_htlc, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC) - MAP_JON_RPC_WE("atomics_redeem_htlc", on_redeem_htlc, wallet_public::COMMAND_REDEEM_HTLC) - MAP_JON_RPC_WE("atomics_check_htlc_redeemed", on_check_htlc_redeemed, wallet_public::COMMAND_CHECK_HTLC_REDEEMED) + //MAP_JON_RPC_WE("atomics_create_htlc_proposal", on_create_htlc_proposal, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL) + //MAP_JON_RPC_WE("atomics_get_list_of_active_htlc", on_get_list_of_active_htlc, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC) + //MAP_JON_RPC_WE("atomics_redeem_htlc", on_redeem_htlc, wallet_public::COMMAND_REDEEM_HTLC) + //MAP_JON_RPC_WE("atomics_check_htlc_redeemed", on_check_htlc_redeemed, wallet_public::COMMAND_CHECK_HTLC_REDEEMED) //IONIC_SWAPS API MAP_JON_RPC_WE("ionic_swap_generate_proposal", on_ionic_swap_generate_proposal, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL) @@ -145,16 +145,16 @@ namespace tools MAP_JON_RPC_WE("assets_whitelist_remove", on_assets_whitelist_remove, wallet_public::COMMAND_ASSETS_WHITELIST_REMOVE) //MULTIWALLET APIs - MAP_JON_RPC_WE("mw_get_wallets", on_mw_get_wallets, wallet_public::COMMAND_MW_GET_WALLETS) - MAP_JON_RPC_WE("mw_select_wallet", on_mw_select_wallet, wallet_public::COMMAND_MW_SELECT_WALLET) + MAP_JON_RPC_WE("mw_get_wallets", on_mw_get_wallets, wallet_public::COMMAND_MW_GET_WALLETS) + MAP_JON_RPC_WE("mw_select_wallet", on_mw_select_wallet, wallet_public::COMMAND_MW_SELECT_WALLET) //basic crypto operations - MAP_JON_RPC_WE("sign_message", on_sign_message, wallet_public::COMMAND_SIGN_MESSAGE) - MAP_JON_RPC_WE("encrypt_data", on_encrypt_data, wallet_public::COMMAND_ENCRYPT_DATA) - MAP_JON_RPC_WE("decrypt_data", on_decrypt_data, wallet_public::COMMAND_DECRYPT_DATA) + MAP_JON_RPC_WE("sign_message", on_sign_message, wallet_public::COMMAND_SIGN_MESSAGE) + MAP_JON_RPC_WE("encrypt_data", on_encrypt_data, wallet_public::COMMAND_ENCRYPT_DATA) + MAP_JON_RPC_WE("decrypt_data", on_decrypt_data, wallet_public::COMMAND_DECRYPT_DATA) //utility call - MAP_JON_RPC_WE("proxy_to_daemon", on_proxy_to_daemon, wallet_public::COMMAND_PROXY_TO_DAEMON) + MAP_JON_RPC_WE("proxy_to_daemon", on_proxy_to_daemon, wallet_public::COMMAND_PROXY_TO_DAEMON) END_JSON_RPC_MAP() END_URI_MAP2() diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 1e1ab4a0..30e469d3 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1663,11 +1663,10 @@ std::string wallets_manager::invoke(uint64_t wallet_id, std::string params) epee::net_utils::http::http_request_info query_info = AUTO_VAL_INIT(query_info); epee::net_utils::http::http_response_info response_info = AUTO_VAL_INIT(response_info); epee::net_utils::connection_context_base stub_conn_context = AUTO_VAL_INIT(stub_conn_context); - std::string reference_stub; bool call_found = false; query_info.m_URI = "/json_rpc"; query_info.m_body = params; - wo.rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found, reference_stub); + wo.rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found); return response_info.m_body; }