container: plugins: root: bitcoin: support Pluggable entrypoint

This commit is contained in:
2026-01-08 14:28:30 -08:00
parent 31054b86ea
commit 1adb305417

View File

@@ -1,6 +1,6 @@
// docker-finance | modern accounting for the power-user // docker-finance | modern accounting for the power-user
// //
// Copyright (C) 2025 Aaron Fiore (Founder, Evergreen Crypto LLC) // Copyright (C) 2025-2026 Aaron Fiore (Founder, Evergreen Crypto LLC)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@@ -43,61 +43,74 @@ inline std::string get_repo_path()
+ "/bitcoin/"; + "/bitcoin/";
} }
//! \brief Initialize this bitcoin plugin //! \brief Pluggable entrypoint
//! \details Bare-essential initializations, will require manual loading for any further functionality
//! \warning Initializations *MUST* occur here before any other bitcoin lib use
//! \ingroup cpp_plugin_impl //! \ingroup cpp_plugin_impl
//! \since docker-finance 1.1.0 //! \since docker-finance 1.1.0
void load(const std::string& arg = {}) class bitcoin_cc
{ {
namespace common = ::dfi::common; public:
bitcoin_cc() = default;
~bitcoin_cc() = default;
const std::string repo{get_repo_path()}; bitcoin_cc(const bitcoin_cc&) = default;
bitcoin_cc& operator=(const bitcoin_cc&) = default;
// Minimum requirements bitcoin_cc(bitcoin_cc&&) = default;
common::add_include_dir(repo + "src"); bitcoin_cc& operator=(bitcoin_cc&&) = default;
common::add_linked_lib(repo + "build/lib/libbitcoinkernel.so");
// WARNING: assertions *MUST* be enabled before loading any bitcoin headers
common::line("#undef NDEBUG");
common::load(repo + "src/kernel/bitcoinkernel_wrapper.h");
// `dfi`-specific requirements (API, macros, tests, etc.) public:
common::line("#define __DFI_PLUGIN_BITCOIN__"); //! \brief Initialize this bitcoin plugin
common::load(repo + "src/random.h"); //! \details Bare-essential initializations, will require manual loading for any further functionality
// ...add as needed //! \warning Initializations *MUST* occur here before any other bitcoin lib use
static void load(const std::string& arg = {})
{
namespace common = ::dfi::common;
if (!arg.empty()) const std::string repo{get_repo_path()};
common::line(arg);
}
//! \brief Deinitialize this bitcoin plugin // Minimum requirements
//! \details Bare-essential deinitializations, will require manual unloading for any other previously loaded functionality common::add_include_dir(repo + "src");
//! \warning Unloading certain bitcoin headers may result in Cling segfault due to bitcoin library design common::add_linked_lib(repo + "build/lib/libbitcoinkernel.so");
//! \ingroup cpp_plugin_impl // WARNING: assertions *MUST* be enabled before loading any bitcoin headers
//! \since docker-finance 1.1.0 common::line("#undef NDEBUG");
//! \todo It appears that, due to bitcoin design, unloading will result in common::load(repo + "src/kernel/bitcoinkernel_wrapper.h");
//! Cling segfault "*** Break *** illegal instruction". With that said, it's
//! best to exit `root` if you want a clean workspace (instead of unloading this plugin).
void unload(const std::string& arg = {})
{
namespace common = ::dfi::common;
if (!arg.empty()) // `dfi`-specific requirements (API, macros, tests, etc.)
common::line(arg); common::line("#define __DFI_PLUGIN_BITCOIN__");
common::load(repo + "src/random.h");
// ...add as needed
const std::string repo{get_repo_path()}; if (!arg.empty())
common::line(arg);
}
// `dfi`-specific requirements (API, macros, tests, etc.) //! \brief Deinitialize this bitcoin plugin
common::line("#undef __DFI_PLUGIN_BITCOIN__"); //! \details Bare-essential deinitializations, will require manual unloading for any other previously loaded functionality
common::unload(repo + "src/random.h"); //! \warning Unloading certain bitcoin headers may result in Cling segfault due to bitcoin library design
// ...add as needed //! \todo It appears that, due to bitcoin design, unloading will result in
//! Cling segfault "*** Break *** illegal instruction". With that said, it's
//! best to exit `root` if you want a clean workspace (instead of unloading this plugin).
static void unload(const std::string& arg = {})
{
namespace common = ::dfi::common;
// Minimum requirements if (!arg.empty())
common::unload(repo + "src/kernel/bitcoinkernel_wrapper.h"); common::line(arg);
common::line("#define NDEBUG");
// TODO(unassigned): remove_include_dir() const std::string repo{get_repo_path()};
common::remove_linked_lib(repo + "build/lib/libbitcoinkernel.so");
} // `dfi`-specific requirements (API, macros, tests, etc.)
common::line("#undef __DFI_PLUGIN_BITCOIN__");
common::unload(repo + "src/random.h");
// ...add as needed
// Minimum requirements
common::unload(repo + "src/kernel/bitcoinkernel_wrapper.h");
common::line("#define NDEBUG");
// TODO(unassigned): remove_include_dir()
common::remove_linked_lib(repo + "build/lib/libbitcoinkernel.so");
}
};
} // namespace bitcoin } // namespace bitcoin
} // namespace dfi::plugin } // namespace dfi::plugin