From 6fe6ce4558feef2c9e235b77f88218c188c7c46c Mon Sep 17 00:00:00 2001 From: stickies-v Date: Sun, 22 Dec 2024 00:06:23 +0100 Subject: [PATCH] kernel: Add version getter --- src/kernel/bitcoinkernel.cpp | 15 +++++++++++++++ src/kernel/bitcoinkernel.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp index 3c0da648069b1..1b60090611fb1 100644 --- a/src/kernel/bitcoinkernel.cpp +++ b/src/kernel/bitcoinkernel.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -385,6 +386,13 @@ const CBlockUndo* cast_const_block_undo(const kernel_BlockUndo* undo) } // namespace +kernel_Version* kernel_get_version() +{ + const auto version_str{FormatFullVersion()}; + auto version = new kernel_Version{version_str.data(), version_str.length()}; + return version; +} + kernel_Transaction* kernel_transaction_create(const unsigned char* raw_transaction, size_t raw_transaction_len) { try { @@ -396,6 +404,13 @@ kernel_Transaction* kernel_transaction_create(const unsigned char* raw_transacti } } +void kernel_version_destroy(kernel_Version* version) +{ + if (version) { + delete version; + } +} + void kernel_transaction_destroy(kernel_Transaction* transaction) { if (transaction) { diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h index 11b3327dbd702..0e8b8981e8451 100644 --- a/src/kernel/bitcoinkernel.h +++ b/src/kernel/bitcoinkernel.h @@ -435,6 +435,15 @@ typedef struct { size_t size; } kernel_ByteArray; +typedef struct { + const char* version; + size_t version_len; +} kernel_Version; + +kernel_Version* kernel_get_version(); + +void kernel_version_destroy(kernel_Version* version); + /** @name Transaction * Functions for working with transactions. */