From 33e91e1a1e94c2957f59def9fe49f75956a9f699 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 17 May 2019 09:04:38 +0000 Subject: [PATCH] wallet, rpc: add a release field to get_version It does not leak much since you can make a fair guess by RPC version already, and some people want to avoid non release clients when using third parties' nodes (because they'd never lie about it) --- cmake/GenVersion.cmake | 4 ++++ src/rpc/core_rpc_server.cpp | 1 + src/rpc/core_rpc_server_commands_defs.h | 4 +++- src/version.cpp.in | 2 ++ src/version.h | 1 + src/wallet/wallet_rpc_server.cpp | 2 ++ src/wallet/wallet_rpc_server_commands_defs.h | 4 +++- 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmake/GenVersion.cmake b/cmake/GenVersion.cmake index b2ccfbc34..992539507 100644 --- a/cmake/GenVersion.cmake +++ b/cmake/GenVersion.cmake @@ -36,6 +36,7 @@ if(RET) message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.") set(VERSIONTAG "unknown") + set(VERSION_IS_RELEASE "false") configure_file("src/version.cpp.in" "${TO}") else() string(SUBSTRING ${COMMIT} 0 9 COMMIT) @@ -47,6 +48,7 @@ else() if(NOT TAGGEDCOMMIT) message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.") set(VERSIONTAG "${COMMIT}") + set(VERSION_IS_RELEASE "false") else() message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}") @@ -54,9 +56,11 @@ else() if(COMMIT STREQUAL TAGGEDCOMMIT) message(STATUS "You are building a tagged release") set(VERSIONTAG "release") + set(VERSION_IS_RELEASE "true") else() message(STATUS "You are ahead of or behind a tagged release") set(VERSIONTAG "${COMMIT}") + set(VERSION_IS_RELEASE "false") endif() endif() diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 73138686d..1fc4b816f 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2147,6 +2147,7 @@ namespace cryptonote return r; res.version = CORE_RPC_VERSION; + res.release = MONERO_VERSION_IS_RELEASE; res.status = CORE_RPC_STATUS_OK; return true; } diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index aed967efb..325ac4343 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -87,7 +87,7 @@ namespace cryptonote // advance which version they will stop working with // Don't go over 32767 for any of these #define CORE_RPC_VERSION_MAJOR 2 -#define CORE_RPC_VERSION_MINOR 9 +#define CORE_RPC_VERSION_MINOR 10 #define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR) @@ -2053,11 +2053,13 @@ namespace cryptonote { std::string status; uint32_t version; + bool release; bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(version) + KV_SERIALIZE(release) KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; diff --git a/src/version.cpp.in b/src/version.cpp.in index 28ce38df7..9121cdf85 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -2,6 +2,7 @@ #define DEF_MONERO_VERSION "0.14.1.2" #define DEF_MONERO_RELEASE_NAME "Boron Butterfly" #define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG +#define DEF_MONERO_VERSION_IS_RELEASE @VERSION_IS_RELEASE@ #include "version.h" @@ -9,3 +10,4 @@ const char* const MONERO_VERSION_TAG = DEF_MONERO_VERSION_TAG; const char* const MONERO_VERSION = DEF_MONERO_VERSION; const char* const MONERO_RELEASE_NAME = DEF_MONERO_RELEASE_NAME; const char* const MONERO_VERSION_FULL = DEF_MONERO_VERSION_FULL; +const bool MONERO_VERSION_IS_RELEASE = DEF_MONERO_VERSION_IS_RELEASE; diff --git a/src/version.h b/src/version.h index d1d06c790..b740d3360 100644 --- a/src/version.h +++ b/src/version.h @@ -4,3 +4,4 @@ extern const char* const MONERO_VERSION_TAG; extern const char* const MONERO_VERSION; extern const char* const MONERO_RELEASE_NAME; extern const char* const MONERO_VERSION_FULL; +extern const bool MONERO_VERSION_IS_RELEASE; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index c64b662f3..7c87e7114 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -36,6 +36,7 @@ #include "include_base_utils.h" using namespace epee; +#include "version.h" #include "wallet_rpc_server.h" #include "wallet/wallet_args.h" #include "common/command_line.h" @@ -4188,6 +4189,7 @@ namespace tools bool wallet_rpc_server::on_get_version(const wallet_rpc::COMMAND_RPC_GET_VERSION::request& req, wallet_rpc::COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& er, const connection_context *ctx) { res.version = WALLET_RPC_VERSION; + res.release = MONERO_VERSION_IS_RELEASE; return true; } //------------------------------------------------------------------------------------------------------------------------------ diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 4504ac752..2dfe6db85 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -47,7 +47,7 @@ // advance which version they will stop working with // Don't go over 32767 for any of these #define WALLET_RPC_VERSION_MAJOR 1 -#define WALLET_RPC_VERSION_MINOR 13 +#define WALLET_RPC_VERSION_MINOR 14 #define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR) namespace tools @@ -2418,9 +2418,11 @@ namespace wallet_rpc struct response_t { uint32_t version; + bool release; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(version) + KV_SERIALIZE(release) END_KV_SERIALIZE_MAP() }; typedef epee::misc_utils::struct_init response;