diff --git a/CMakeLists.txt b/CMakeLists.txt index 94970857fac8d..3d525193b0fb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,8 @@ endif() option(WITH_SV2 "Enable Stratum v2 functionality." OFF) +option(BUILD_SV2_LIB "Build experimental bitcoinsv2 library." OFF) + cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF) if(BUILD_GUI) set(qt_components Core Gui Widgets LinguistTools) @@ -245,6 +247,7 @@ if(BUILD_FOR_FUZZING) set(WITH_MINIUPNPC OFF) set(WITH_ZMQ OFF) set(WITH_SV2 OFF) + set(BUILD_SV2_LIB OFF) set(BUILD_TESTS OFF) set(BUILD_GUI_TESTS OFF) set(BUILD_BENCH OFF) @@ -632,6 +635,7 @@ message(" USDT tracing ........................ ${WITH_USDT}") message(" QR code (GUI) ....................... ${WITH_QRENCODE}") message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}") message(" Stratum v2 .......................... ${WITH_SV2}") +message(" libbitcoinsv2 (experimental) ........ ${BUILD_SV2_LIB}") message("Tests:") message(" test_bitcoin ........................ ${BUILD_TESTS}") message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}") diff --git a/libbitcoinsv2.pc.in b/libbitcoinsv2.pc.in new file mode 100644 index 0000000000000..391325e3c64b0 --- /dev/null +++ b/libbitcoinsv2.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PACKAGE_NAME@ sv2 library +Description: Experimental library for the Bitcoin Core Stratum v2 functionality. +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lbitcoinsv2 +Libs.private: -L${libdir} @LIBS_PRIVATE@ +Cflags: -I${includedir} diff --git a/src/sv2/CMakeLists.txt b/src/sv2/CMakeLists.txt index e61f2f3560834..98fe441ce5b83 100644 --- a/src/sv2/CMakeLists.txt +++ b/src/sv2/CMakeLists.txt @@ -14,3 +14,11 @@ target_link_libraries(bitcoin_sv2 bitcoin_crypto $<$:ws2_32> ) + +if (BUILD_SV2_LIB) + install(FILES bitcoinsv2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + configure_file(${PROJECT_SOURCE_DIR}/libbitcoinsv2.pc.in ${PROJECT_BINARY_DIR}/libbitcoinsv2.pc @ONLY) + install(FILES ${PROJECT_BINARY_DIR}/libbitcoinsv2.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +endif() diff --git a/src/sv2/bitcoinsv2.h b/src/sv2/bitcoinsv2.h new file mode 100644 index 0000000000000..d0c696453d80c --- /dev/null +++ b/src/sv2/bitcoinsv2.h @@ -0,0 +1,63 @@ +// Copyright (c) 2024-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_SV2_BITCOINSV2_H +#define BITCOIN_SV2_BITCOINSV2_H + +#ifndef __cplusplus +#include +#include +#include +#else +#include +#include +#endif // __cplusplus + + +#if !defined(BITCOINSV2_GNUC_PREREQ) +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +#define BITCOINSV2_GNUC_PREREQ(_maj, _min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((_maj) << 16) + (_min)) +#else +#define BITCOINSV2_GNUC_PREREQ(_maj, _min) 0 +#endif +#endif + +/* Warning attributes */ +#if defined(__GNUC__) && BITCOINSV2_GNUC_PREREQ(3, 4) +#define BITCOINSV2_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) +#else +#define BITCOINSV2_WARN_UNUSED_RESULT +#endif +#if !defined(BITCOINSV2_BUILD) && defined(__GNUC__) && BITCOINSV2_GNUC_PREREQ(3, 4) +#define BITCOINSV2_ARG_NONNULL(_x) __attribute__((__nonnull__(_x))) +#else +#define BITCOINSV2_ARG_NONNULL(_x) +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/** + * ------ Context ------ + * + * The library provides Stratum v2 functionality. + * + * ------ Error handling ------ + * + * TODO + * + * ------ Pointer and argument conventions ------ + * + * TODO + */ + +// TODO: some actual methods + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // BITCOIN_SV2_BITCOINSV2_H