rpc for get_version

This commit is contained in:
Sean Darcy 2022-03-29 15:02:42 +11:00 committed by Thomas Winget
parent 9a7f7d6704
commit 90433d0b71
4 changed files with 32 additions and 0 deletions

View File

@ -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)

View File

@ -4,6 +4,7 @@
#include "command_parser.h"
#include <wallet3/wallet.hpp>
#include <wallet3/db_schema.hpp>
#include <wallet3/version.hpp>
#include <cryptonote_core/cryptonote_tx_utils.h>
@ -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) {

View File

@ -0,0 +1,10 @@
#include "version.h"
using namespace std::literals;
const std::array<uint16_t, 3> 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;

14
src/wallet3/version.hpp Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include <cstdint>
#include <array>
#include <string_view>
namespace wallet
{
// Given a full wallet version of: wallet-1.2.3-abc these are:
extern const std::array<uint16_t, 3> 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