Skip to content

Commit

Permalink
kernel: Add version getter
Browse files Browse the repository at this point in the history
  • Loading branch information
stickies-v committed Dec 21, 2024
1 parent f157b0c commit 6fe6ce4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/kernel/bitcoinkernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <kernel/bitcoinkernel.h>

#include <chain.h>
#include <clientversion.h>
#include <coins.h>
#include <consensus/amount.h>
#include <consensus/validation.h>
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions src/kernel/bitcoinkernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 6fe6ce4

Please sign in to comment.