Add /get_version, based on openmonero with a few extra additions (#209)

This commit is contained in:
Lee *!* Clagett
2025-11-26 18:57:36 -05:00
committed by Lee *!* Clagett
parent c65a1f488b
commit 8cf0976557
7 changed files with 188 additions and 7 deletions

View File

@@ -37,10 +37,12 @@
#include "config.h"
#include "db/string.h"
#include "error.h"
#include "lws_version.h"
#include "time_helper.h" // monero/contrib/epee/include
#include "ringct/rctOps.h" // monero/src
#include "span.h" // monero/contrib/epee/include
#include "util/random_outputs.h"
#include "version.h" // monero/src
#include "wire.h"
#include "wire/adapted/crypto.h"
#include "wire/error.h"
@@ -362,6 +364,36 @@ namespace lws
);
}
rpc::get_version_response::get_version_response(const db::block_id height, const std::uint32_t max_subaddresses)
: server_type(lws::version::name),
server_version(lws::version::id),
last_git_commit_hash(lws::version::commit),
last_git_commit_date(lws::version::date),
git_branch_name(lws::version::branch),
monero_version_full(MONERO_VERSION_FULL),
blockchain_height(height),
api(lws::version::api::combined),
max_subaddresses(max_subaddresses),
network(lws::rpc::network_type(lws::config::network)),
testnet(config::network == cryptonote::TESTNET)
{}
void rpc::write_bytes(wire::json_writer& dest, const get_version_response& self)
{
wire::object(dest,
WIRE_FIELD(server_type),
WIRE_FIELD(server_version),
WIRE_FIELD(last_git_commit_hash),
WIRE_FIELD(last_git_commit_date),
WIRE_FIELD(git_branch_name),
WIRE_FIELD(monero_version_full),
WIRE_FIELD_COPY(blockchain_height),
WIRE_FIELD(api),
WIRE_FIELD_COPY(max_subaddresses),
wire::field("network_type", self.network),
WIRE_FIELD_COPY(testnet)
);
}
void rpc::read_bytes(wire::json_reader& source, import_request& self)
{
std::string address;

View File

@@ -224,6 +224,35 @@ namespace rpc
void write_bytes(wire::json_writer&, const get_subaddrs_response&);
struct get_version_request
{
get_version_request() = delete;
};
inline void read_bytes(const wire::reader&, const get_version_request&)
{}
struct get_version_response
{
//! Defaults to current network in unavailable state
get_version_response(lws::db::block_id height, std::uint32_t max_subaddresses);
const std::string server_type;
const std::string server_version;
const std::string last_git_commit_hash;
const std::string last_git_commit_date;
const std::string git_branch_name;
const std::string monero_version_full;
const db::block_id blockchain_height;
const std::uint32_t api;
const std::uint32_t max_subaddresses;
const network_type network;
const bool testnet;
};
void write_bytes(wire::json_writer&, const get_version_response&);
struct import_request
{
import_request() = delete;