diff --git a/src/wallet3/CMakeLists.txt b/src/wallet3/CMakeLists.txt index 3217dc970..4d7bf56a6 100644 --- a/src/wallet3/CMakeLists.txt +++ b/src/wallet3/CMakeLists.txt @@ -1,3 +1,5 @@ +configure_file(version.cpp.in version.cpp @ONLY) + add_library(wallet3 db_schema.cpp default_daemon_comms.cpp @@ -9,6 +11,7 @@ add_library(wallet3 decoy_selection/decoy_selection.cpp wallet.cpp wallet2½.cpp + version.cpp rpc/command_parser.cpp rpc/request_handler.cpp rpc/omq_server.cpp) diff --git a/src/wallet3/rpc/request_handler.cpp b/src/wallet3/rpc/request_handler.cpp index c43ba1552..309ae07f6 100644 --- a/src/wallet3/rpc/request_handler.cpp +++ b/src/wallet3/rpc/request_handler.cpp @@ -4,6 +4,7 @@ #include "command_parser.h" #include #include +#include #include @@ -343,6 +344,10 @@ void RequestHandler::invoke(SUBMIT_MULTISIG& command, rpc_context context) { } void RequestHandler::invoke(GET_VERSION& command, rpc_context context) { + if (auto w = wallet.lock()) + { + command.response["version"] = VERSION_STR; + } } void RequestHandler::invoke(STAKE& command, rpc_context context) { diff --git a/src/wallet3/version.cpp.in b/src/wallet3/version.cpp.in new file mode 100644 index 000000000..e2407eec8 --- /dev/null +++ b/src/wallet3/version.cpp.in @@ -0,0 +1,10 @@ +#include "version.h" + +using namespace std::literals; + +const std::array OXEN_VERSION = {@PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@}; + +const std::string_view VERSION_TAG = "@VERSIONTAG@"sv; +const std::string_view VERSION_STR = "@PROJECT_VERSION@"sv; +const std::string_view VERSION_FULL = "@PROJECT_VERSION@-@VERSIONTAG@"sv; + diff --git a/src/wallet3/version.hpp b/src/wallet3/version.hpp new file mode 100644 index 000000000..35d0a6688 --- /dev/null +++ b/src/wallet3/version.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include +#include +#include + +namespace wallet +{ + // Given a full wallet version of: wallet-1.2.3-abc these are: + extern const std::array VERSION; // [1, 2, 3] + extern const std::string_view VERSION_STR; // "1.2.3" + extern const std::string_view VERSION_TAG; // "abc" + extern const std::string_view VERSION_FULL; // "wallet-1.2.3-abc" +} // namespace wallet