### Install Datum Gateway Dependencies on Clear Linux Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Command to install the necessary development bundles for compiling the DATUM Gateway on Clear Linux. ```bash sudo swupd bundle-add c-basic cmake pkgconf devpkg-curl devpkg-jansson devpkg-libsodium devpkg-libmicrohttpd psmisc ``` -------------------------------- ### Install Project Files (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Installs project files such as README.md, network diagram SVG, usernames documentation, and example configuration JSON to the appropriate installation directories. ```cmake install(TARGETS datum_gateway DESTINATION bin) install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) install(FILES doc/DATUM_recommended_setup-network_diagram.svg DESTINATION ${CMAKE_INSTALL_DOCDIR}/doc) install(FILES doc/usernames.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) set(PREGEN_DOC ${CMAKE_SOURCE_DIR}/doc/example_datum_gateway_config.json) install(FILES ${PREGEN_DOC} DESTINATION ${CMAKE_INSTALL_DOCDIR}) ``` -------------------------------- ### Install Datum Gateway Dependencies on FreeBSD Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Command to install the required packages for compiling the DATUM Gateway on FreeBSD. ```bash sudo pkg install cmake pkgconf curl jansson libsodium libmicrohttpd argp-standalone libepoll-shim ``` -------------------------------- ### Build and Install DATUM Gateway from Source (Bash) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt These bash commands outline the process of compiling the DATUM Gateway from its source code on Debian/Ubuntu and Fedora/RHEL systems. It includes installing necessary dependencies and then building and installing the gateway binary. Finally, it shows how to run the gateway with a specified configuration file. ```bash # Install dependencies (Debian/Ubuntu) sudo apt install cmake pkgconf libcurl4-openssl-dev libjansson-dev \ libsodium-dev libmicrohttpd-dev psmisc # Install dependencies (Fedora/RHEL) sudo dnf install cmake pkgconf libcurl-devel jansson-devel \ libsodium-devel libmicrohttpd-devel psmisc # Build cmake . && make # Install sudo make install # Run with configuration file ./datum_gateway -c /path/to/datum_gateway_config.json ``` -------------------------------- ### Install Datum Gateway Dependencies on Debian/Ubuntu Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Command to install the necessary libraries and development packages for compiling the DATUM Gateway on Debian or Ubuntu systems. ```bash sudo apt install cmake pkgconf libcurl4-openssl-dev libjansson-dev libsodium-dev libmicrohttpd-dev psmisc ``` -------------------------------- ### Install Datum Gateway Dependencies on Fedora/Amazon Linux Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Command to install the required libraries and development packages for compiling the DATUM Gateway on Fedora or Amazon Linux systems. ```bash sudo dnf install cmake pkgconf libcurl-devel jansson-devel libsodium-devel libmicrohttpd-devel psmisc ``` -------------------------------- ### Install Datum Gateway Dependencies on Arch Linux Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Command to install the required packages for compiling the DATUM Gateway on Arch Linux. ```bash sudo pacman -Syu base-devel cmake pkgconf curl jansson libsodium libmicrohttpd psmisc ``` -------------------------------- ### Install Datum Gateway Dependencies on Alma Linux Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Commands to install necessary dependencies for compiling the DATUM Gateway on Alma Linux, including enabling the CodeReady Builder repository. ```bash sudo dnf install epel-release dnf-plugins-core sudo dnf config-manager --set-enabled crb sudo dnf install cmake pkgconf libcurl-devel jansson-devel libsodium-devel libmicrohttpd-devel psmisc ``` -------------------------------- ### Install Datum Gateway Dependencies on Alpine Linux Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Command to install the necessary libraries and development packages, including a standalone argp library, for compiling the DATUM Gateway on Alpine Linux. ```bash sudo apk add build-base cmake pkgconf argp-standalone curl-dev jansson-dev libsodium-dev libmicrohttpd-dev psmisc ``` -------------------------------- ### Connect Miners to DATUM Gateway Stratum Server (Bash) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt These examples demonstrate how to connect mining hardware to the DATUM Gateway's Stratum v1 server. They illustrate basic connection strings using IP addresses and ports, specifying username and password. The examples also cover configurations for using only a worker name (when `pool_address` is set in the gateway config) and for including a revenue sharing modifier. ```bash # Basic connection with worker name stratum+tcp://gateway-ip:23334 username: bc1qyouraddress.worker1 password: x # Worker name only (uses pool_address from config) stratum+tcp://gateway-ip:23334 username: .worker1 password: x # With revenue sharing modifier stratum+tcp://gateway-ip:23334 username: bc1qyouraddress.worker1~modifier_name password: x ``` -------------------------------- ### Install Datum Gateway Dependencies on Oracle Linux Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Commands to install required dependencies for compiling the DATUM Gateway on Oracle Linux, including enabling the CodeReady Builder repository. ```bash sudo dnf install epel-release dnf-plugins-core sudo dnf config-manager --set-enabled ol9_codeready_builder sudo dnf install cmake pkgconf libcurl-devel jansson-devel libsodium-devel libmicrohttpd-devel psmisc ``` -------------------------------- ### Compile Datum Gateway Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md Commands to configure and compile the DATUM Gateway after installing all dependencies. ```bash cmake . make ``` -------------------------------- ### Verify Example Documentation with CMake Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt This CMake command executes a script to verify pre-generated documentation. It passes the target file path of 'datum_gateway', paths for generated and pre-generated documentation, and the project source directory to the verification script. The purpose is to ensure documentation consistency. ```cmake COMMAND ${CMAKE_COMMAND} -DDATUM_GATEWAY=$ -DGENERATED_DOC=${GENERATED_DOC} -DPREGEN_DOC=${PREGEN_DOC} -P ${PROJECT_SOURCE_DIR}/cmake/script/VerifyExample.cmake COMMENT "Verifying pre-generated documentation is up-to-date" VERBATIM ) endif() ``` -------------------------------- ### Post-Build Custom Command for Documentation (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Defines a post-build custom command for the 'datum_gateway' target that generates an example configuration JSON file. This command is executed after the target has been successfully built. ```cmake if(NOT CMAKE_CROSSCOMPILING) set(GENERATED_DOC ${CMAKE_BINARY_DIR}/CMakeFiles/generated_example_datum_gateway_config.json) add_custom_command( TARGET datum_gateway POST_BUILD ``` -------------------------------- ### GET /NOTIFY Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Triggers an immediate block template refresh when new blocks arrive on the Bitcoin network. ```APIDOC ## GET /NOTIFY ### Description Triggers an immediate block template refresh when new blocks arrive on the network. This endpoint can be invoked manually via HTTP GET or configured as a `blocknotify` script in `bitcoin.conf`. ### Method GET ### Endpoint /NOTIFY ### Parameters None ### Request Example ```bash # Manual trigger via HTTP GET curl http://gateway-ip:7152/NOTIFY # From bitcoin.conf blocknotify blocknotify=wget -q -O /dev/null http://gateway-ip:7152/NOTIFY ``` ### Response #### Success Response (200) - **None** (Indicates successful execution) #### Error Response - **Error** (string) - Description of the error. ``` -------------------------------- ### Trigger Block Template Refresh via API (Bash) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This snippet shows how to trigger an immediate block template refresh on the Datum Gateway. It includes examples using `curl` for a manual trigger, configuring `bitcoin.conf`'s `blocknotify` directive with `wget`, and using `killall` for same-host notifications. ```bash # Manual trigger via HTTP GET curl http://gateway-ip:7152/NOTIFY # From bitcoin.conf blocknotify blocknotify=wget -q -O /dev/null http://gateway-ip:7152/NOTIFY # Using killall (same-host only) blocknotify=killall -USR1 datum_gateway ``` -------------------------------- ### Submit Administrative Actions via POST API (JavaScript) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This JavaScript code provides a helper function `sendPostRequest` to submit administrative actions to the Datum Gateway's API. It handles CSRF token injection and basic error handling for unauthorized access or other HTTP errors. Examples include kicking idle miners and updating configuration settings. ```javascript // Web interface POST helper (from www/assets/post.js) async function sendPostRequest(url, data) { data.csrf = '%s'; // Auto-populated CSRF token var r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); if (r.ok) return; if (r.status == 401) { alert('This action requires admin access.'); } else { alert('Error ' + r.status); } } // Example: Kick idle miner await sendPostRequest('/api/kick-miner', { miner_id: 12345 }); // Example: Update configuration await sendPostRequest('/api/update-config', { section: 'stratum', key: 'listen_port', value: 23335 }); ``` -------------------------------- ### Deploy DATUM Gateway using Docker (Bash) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This section provides bash commands for deploying the DATUM Gateway using Docker. It covers building the Docker image, running the container with mounted configurations and exposed ports, and includes specific instructions for when the Bitcoin node runs on the host system. It also shows how to configure `blocknotify` for Dockerized deployments. ```bash # Build Docker image docker build -t datum_gateway . # Run with mounted configuration directory docker run -v /path/to/config:/app/config \ -p 23334:23334 \ -p 7152:7152 \ --name datum-gateway \ datum_gateway # For Bitcoin node on host system docker run -v /path/to/config:/app/config \ -p 23334:23334 \ -p 7152:7152 \ --add-host=host.docker.internal:host-gateway \ datum_gateway # Configure blocknotify for Docker (in bitcoin.conf) blocknotify=wget -q -O /dev/null http://datum-gateway:7152/NOTIFY ``` -------------------------------- ### Configure DATUM Gateway Basic Settings (JSON) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This JSON configuration file sets up essential parameters for the DATUM Gateway, including Bitcoin node connection details, Stratum server port, mining parameters, API access, and logging preferences. It enables fine-grained control over gateway operations and pooled mining settings. ```json { "bitcoind": { "rpcuser": "datum", "rpcpassword": "your_secure_password", "rpcurl": "http://localhost:8332", "notify_fallback": true }, "stratum": { "listen_port": 23334 }, "mining": { "pool_address": "bc1qexampleaddress...", "coinbase_tag_primary": "DATUM Gateway", "coinbase_tag_secondary": "My Miner ID" }, "api": { "admin_password": "secure_admin_password", "listen_port": 7152, "modify_conf": false }, "logger": { "log_to_console": true, "log_to_file": false, "log_file": "/var/log/datum.log", "log_rotate_daily": true, "log_level_console": 2, "log_level_file": 1 }, "datum": { "pool_pass_workers": true, "pool_pass_full_users": true, "pooled_mining_only": true } } ``` -------------------------------- ### Access Web Dashboard (Bash) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This command demonstrates how to access the Datum Gateway's administrative web interface. The dashboard allows for monitoring hashrate, miner statistics, job information, and share rates. It also enables configuration management if `modify_conf` is enabled. Authentication may be required. ```bash # Access dashboard (requires admin_password for modifications) http://gateway-ip:7152/ ``` -------------------------------- ### Embed Web Resources into Header (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Defines a custom command to generate 'web_resources.h' by embedding the files listed in 'WEB_RESOURCES'. This command runs during the build process and depends on the resource files and the 'EmbedResources.cmake' script. ```cmake add_custom_command( OUTPUT web_resources.h COMMAND ${CMAKE_COMMAND} "-DINPUT_FILES=${WEB_RESOURCES}" -DOUTPUT_FILE=web_resources.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/EmbedResources.cmake DEPENDS ${WEB_RESOURCES} cmake/script/EmbedResources.cmake VERBATIM ) ``` -------------------------------- ### Find and Check Dependencies (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Uses PkgConfig to find and check for required libraries like libcurl, jansson, libmicrohttpd (conditionally), and libsodium. It also finds the Threads library. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(CURL REQUIRED libcurl) pkg_check_modules(JANSSON REQUIRED jansson) if(ENABLE_API) pkg_check_modules(MICROHTTPD REQUIRED libmicrohttpd) endif() pkg_check_modules(SODIUM REQUIRED libsodium) find_package(Threads REQUIRED) ``` -------------------------------- ### Configure Bitcoin Node for Datum Gateway Source: https://github.com/ocean-xyz/datum_gateway/blob/master/README.md These configuration options for your Bitcoin node are recommended to reserve space for the pool's generation transaction and ensure the DATUM Gateway receives new block notifications. ```ini blockmaxsize=3985000 blockmaxweight=3985000 ``` ```ini blocknotify=killall -USR1 datum_gateway ``` ```ini maxmempool=1000 blockreconstructionextratxn=1000000 ``` -------------------------------- ### Define Executable and Source Files (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Defines the main executable target 'datum_gateway' and lists all its source files. It also includes a generated header file for web resources. ```cmake add_executable(datum_gateway src/datum_blocktemplates.c src/datum_coinbaser.c src/datum_conf.c src/datum_conf_tests.c src/datum_gateway.c src/datum_jsonrpc.c src/datum_logger.c src/datum_protocol.c src/datum_queue.c src/datum_sockets.c src/datum_stratum.c src/datum_stratum_dupes.c src/datum_stratum_tests.c src/datum_submitblock.c src/datum_utils.c src/datum_utils_tests.c src/thirdparty_base58.c src/thirdparty_segwit_addr.c ${CMAKE_CURRENT_BINARY_DIR}/web_resources.h ) ``` -------------------------------- ### Generate Build Information Header (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Defines a custom target 'generate_git_version' that creates a 'git_version.h' file containing build information. This target depends on the 'GenerateBuildInfo.cmake' script. ```cmake add_custom_target(generate_git_version BYPRODUCTS ${PROJECT_BINARY_DIR}/git_version.h COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/git_version.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake DEPENDS cmake/script/GenerateBuildInfo.cmake COMMENT "Generating git_version.h" VERBATIM ) add_dependencies(datum_gateway generate_git_version) ``` -------------------------------- ### Configure Bitcoin Node for DATUM Gateway (bitcoin.conf) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This configuration for a Bitcoin node prepares it to work with the DATUM Gateway. It reserves space for pool generation transactions, enables block notifications to the gateway, and sets up necessary RPC access. Proper configuration is crucial for pooled mining and secure communication. ```conf # Reserve space for pool generation transaction (required for DATUM pooled mining) blockmaxsize=3985000 blockmaxweight=3985000 # Send block notifications to DATUM Gateway blocknotify=killall -USR1 datum_gateway # Recommended for optimal mempool management maxmempool=1000 blockreconstructionextratxn=1000000 # RPC access for DATUM Gateway rpcuser=datum rpcpassword=your_secure_password rpcbind=127.0.0.1 rpcallowip=127.0.0.1 ``` -------------------------------- ### List Web Resources for Embedding (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Defines a list of web resource files (HTML, JS, CSS, SVG, ICO) that will be embedded into the 'datum_gateway' executable. This list is used by the 'EmbedResources.cmake' script. ```cmake set(WEB_RESOURCES www/auth_failed.html www/home.html www/clients_top.html www/coinbaser_top.html www/config.html www/config_errors.html www/config_restart.html www/threads_top.html www/foot.html www/assets/post.js www/assets/style.css www/assets/icons/datum_logo.svg www/assets/icons/favicon.ico ) ``` -------------------------------- ### JavaScript: Go Back Button Source: https://github.com/ocean-xyz/datum_gateway/blob/master/www/config_errors.html This JavaScript code snippet dynamically adds a 'Go Back' button to the page. When clicked, it navigates the user to the previous page in their browser history. ```javascript document.write('
') ``` ```javascript document.write('
') ``` -------------------------------- ### POST /api/kick-miner Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Triggers an immediate block template refresh when new blocks arrive on the Bitcoin network. ```APIDOC ## POST /api/kick-miner ### Description Kicks an idle miner from the Stratum pool. This action is typically performed via the web interface. ### Method POST ### Endpoint /api/kick-miner ### Parameters #### Request Body - **miner_id** (integer) - Required - The unique identifier of the miner to be kicked. - **csrf** (string) - Required - The Cross-Site Request Forgery token, automatically populated by the web interface. ### Request Example ```json { "miner_id": 12345, "csrf": "%s" } ``` ### Response #### Success Response (200) - **None** (Indicates successful execution) #### Error Response (401) - **None** (Indicates that admin access is required) #### Error Response (Other Status Codes) - **Error** (string) - Description of the error. ``` -------------------------------- ### Configure Datum Gateway Project with CMake Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt This snippet initializes the CMake build system for the Datum Gateway project. It sets the minimum required CMake version to 3.13, defines the project name as 'DATUM' with version 0.4.0, and specifies C as the programming language for the project. This is a foundational step for building the project with CMake. ```cmake cmake_minimum_required(VERSION 3.13) project(DATUM VERSION 0.4.0 LANGUAGES C) ``` -------------------------------- ### Check for C Library Functions and Libraries (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Checks for the existence of specific C functions like 'pow' and 'argp_parse', and libraries like 'm' and 'argp'. This is used to determine available functionalities and required link libraries, with a workaround for FreeBSD. ```cmake include(CheckFunctionExists) include(CheckLibraryExists) include(CMakePushCheckState) cmake_push_check_state(RESET) string(APPEND CMAKE_REQUIRED_FLAGS -Wno-error) set(POW_LIBS "") check_library_exists(m pow "" LIBM) if(LIBM) list(APPEND POW_LIBS "m") endif() set(ARGP_LIBS "") check_function_exists(argp_parse HAVE_ARGP_PARSE) if(NOT HAVE_ARGP_PARSE) check_library_exists(argp argp_parse "" ARGP) if(NOT ARGP AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # Workaround bug where CMake doesn't check the standard install location on FreeBSD unset(ARGP CACHE) check_library_exists(argp argp_parse "/usr/local/lib" ARGP) endif() if(ARGP) list(APPEND ARGP_LIBS "argp") endif() endif() check_function_exists(epoll_wait HAVE_EPOLL_WAIT) if(HAVE_EPOLL_WAIT) set(EPOLL_SHIM_INCLUDE_DIRS "") set(EPOLL_SHIM_LIBRARIES "") else() pkg_check_modules(EPOLL_SHIM REQUIRED epoll-shim) endif() cmake_pop_check_state() ``` -------------------------------- ### Link Libraries to Target (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Links the necessary libraries to the 'datum_gateway' target. This includes standard libraries like 'm', 'Threads::Threads', 'argp', and 'epoll-shim', as well as dependency-specific libraries and flags for libcurl, jansson, and libsodium. ```cmake target_link_libraries(datum_gateway PUBLIC ${POW_LIBS} Threads::Threads ${ARGP_LIBS} ${EPOLL_SHIM_LIBRARIES} ${CURL_LIBRARIES} ${CURL_LDFLAGS} ${CURL_LDFLAGS_OTHER} ${JANSSON_LIBRARIES} ${JANSSON_LDFLAGS} ${JANSSON_LDFLAGS_OTHER} ${SODIUM_LIBRARIES} ${SODIUM_LDFLAGS} ${SODIUM_LDFLAGS_OTHER} ) ``` -------------------------------- ### Configure C Standard Version (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Sets the C standard for compilation, preferring C23 if supported by CMake version 3.21 or later, otherwise falling back to C11 for compatibility. It ensures the C standard is strictly enforced. ```cmake if(CMAKE_VERSION VERSION_LESS "3.21") # Older CMake: C23 not recognized; use C11 set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) else() # CMake 3.21+: C23 is available set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD_REQUIRED OFF) endif() ``` -------------------------------- ### Configure Target Include and Link Directories (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Sets the include and link directories for the 'datum_gateway' target, including build interface directories and paths for found dependencies like libcurl, jansson, and libsodium. It also handles conditionally added include/link directories for API support. ```cmake target_include_directories(datum_gateway PRIVATE $ ${EPOLL_SHIM_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS} ${SODIUM_INCLUDE_DIRS} ) target_link_directories(datum_gateway PUBLIC ${CURL_LIBRARY_DIRS} ${JANSSON_LIBRARY_DIRS} ${SODIUM_LIBRARY_DIRS} ) ``` -------------------------------- ### Web Dashboard Access Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Access the administrative web interface for monitoring and configuration. ```APIDOC ## Web Dashboard Access ### Description Access the administrative web interface for monitoring and configuration of the Datum Gateway. Requires authentication for modifications. ### Method GET ### Endpoint / ### Parameters None ### Request Example ```bash # Access dashboard (requires admin_password for modifications) http://gateway-ip:7152/ ``` ### Features - Real-time hashrate estimates - Connected miner statistics - Current job information - Share acceptance rates - Configuration management (if `modify_conf` enabled) ``` -------------------------------- ### POST /api/update-config Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Updates a specific configuration setting within the gateway. ```APIDOC ## POST /api/update-config ### Description Updates a specific configuration setting for the Datum Gateway. This can be used to dynamically change parameters like the Stratum listen port. ### Method POST ### Endpoint /api/update-config ### Parameters #### Request Body - **section** (string) - Required - The configuration section to update (e.g., "stratum"). - **key** (string) - Required - The specific configuration key within the section (e.g., "listen_port"). - **value** (any) - Required - The new value for the configuration key. - **csrf** (string) - Required - The Cross-Site Request Forgery token, automatically populated by the web interface. ### Request Example ```json { "section": "stratum", "key": "listen_port", "value": 23335, "csrf": "%s" } ``` ### Response #### Success Response (200) - **None** (Indicates successful execution) #### Error Response (401) - **None** (Indicates that admin access is required) #### Error Response (Other Status Codes) - **Error** (string) - Description of the error. ``` -------------------------------- ### Automatic Form Submission for Continuation (JavaScript) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/www/config_restart.html This JavaScript code snippet automatically submits a form named 'continue_form' after a 10-second delay. It's used on the DATUM Gateway restart confirmation page to allow the user to proceed without manual interaction. ```javascript setTimeout(function() { document.continue_form.submit(); }, 10000); ``` -------------------------------- ### Block Template and Transaction Structures (C) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt These C structures define the data formats for block templates obtained from a Bitcoin node and individual transactions within those templates. `T_DATUM_TEMPLATE_DATA` holds overall block information, while `T_DATUM_TEMPLATE_TXN` details each transaction, including its size, weight, fee, and binary data. The `datum_gbt_parser` function is used to parse JSON GBT responses, and `datum_blocktemplates_notifynew` handles notifications for new blocks. ```c // Block template structure (from datum_blocktemplates.h) typedef struct { uint16_t local_index; uint64_t coinbasevalue; uint64_t curtime; uint32_t height; uint32_t version; char bits[9]; char previousblockhash[72]; uint8_t previousblockhash_bin[32]; char default_witness_commitment[96]; uint32_t txn_count; uint32_t txn_total_weight; T_DATUM_TEMPLATE_TXN *txns; } T_DATUM_TEMPLATE_DATA; // Transaction structure with dependency tracking typedef struct T_DATUM_TEMPLATE_TXN { uint16_t index_raw; char txid_hex[72]; uint8_t txid_bin[32]; uint32_t size; uint32_t weight; uint64_t fee_sats; uint32_t sigops; uint8_t *txn_data_binary; } T_DATUM_TEMPLATE_TXN; // Parse GBT response into template structure T_DATUM_TEMPLATE_DATA *datum_gbt_parser(json_t *gbt); // Trigger template refresh on new block void datum_blocktemplates_notifynew(const char *prevhash, int height); ``` -------------------------------- ### Stratum Job Generation Structures (C) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt These C structures are fundamental to Stratum job generation in the Datum Gateway. `T_DATUM_STRATUM_JOB` encapsulates all necessary data for a mining job, including block template details, previous block hash, version, bits, and multiple coinbase variants tailored for different miner firmwares. Functions like `update_stratum_job`, `send_mining_notify`, and `stratum_job_merkle_root_calc` manage the job lifecycle and communication with miners. ```c // Stratum job structure (from datum_stratum.h) typedef struct { int global_index; char job_id[24]; char prevhash[68]; unsigned char prevhash_bin[32]; char version[10]; char nbits[10]; char ntime[10]; unsigned char block_target[32]; T_DATUM_TEMPLATE_DATA *block_template; unsigned char merklebranch_count; char merklebranches_hex[24][72]; // Multiple coinbase variants for different miner firmware T_DATUM_STRATUM_COINBASE coinbase[MAX_COINBASE_TYPES]; // COINBASE_TYPE_TINY: empty, just pays pool // COINBASE_TYPE_SMALL: Nicehash compatible, max 500 bytes // COINBASE_TYPE_ANTMAIN: Antminer firmware, 750 bytes // COINBASE_TYPE_RESPECTABLE: Whatsminer, 6500 bytes // COINBASE_TYPE_YUGE: ePIC/Bitaxe, 16KB // COINBASE_TYPE_ANTMAIN2: S21, 2250 bytes uint64_t coinbase_value; uint64_t height; bool is_new_block; int job_state; } T_DATUM_STRATUM_JOB; // Update global Stratum job void update_stratum_job(T_DATUM_TEMPLATE_DATA *block_template, bool new_block, int job_state); // Send mining.notify to client int send_mining_notify(T_DATUM_CLIENT_DATA *c, bool clean, bool quickdiff, bool new_block); // Calculate merkle root for share validation void stratum_job_merkle_root_calc(T_DATUM_STRATUM_JOB *s, unsigned char *coinbase_txn_hash, unsigned char *merkle_root_output); ``` -------------------------------- ### Set Compile Options for Target (CMake) Source: https://github.com/ocean-xyz/datum_gateway/blob/master/CMakeLists.txt Applies compile options to the 'datum_gateway' target, including flags from found dependencies like libcurl, jansson, and libsodium. It also includes flags for API support if enabled. ```cmake target_compile_options(datum_gateway PUBLIC ${CURL_CFLAGS} ${CURL_CFLAGS_OTHER} ${JANSSON_CFLAGS} ${JANSSON_CFLAGS_OTHER} ${SODIUM_CFLAGS} ${SODIUM_CFLAGS_OTHER} ) if(ENABLE_API) target_sources(datum_gateway PRIVATE src/datum_api.c) target_include_directories(datum_gateway PRIVATE ${MICROHTTPD_INCLUDE_DIRS}) target_link_directories(datum_gateway PUBLIC ${MICROHTTPD_LIBRARY_DIRS}) target_link_libraries(datum_gateway PUBLIC ${MICROHTTPD_LIBRARIES} ${MICROHTTPD_LDFLAGS} ${MICROHTTPD_LDFLAGS_OTHER}) target_compile_options(datum_gateway PUBLIC -DENABLE_API ${MICROHTTPD_CFLAGS} ${MICROHTTPD_CFLAGS_OTHER} ) endif() ``` -------------------------------- ### Stratum Client Utility Functions (C) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Provides essential utility functions for managing Stratum clients within the Datum Gateway. These functions include sending difficulty updates, retrieving global subscriber counts, estimating network hashrate, and initiating a shutdown of all Stratum connections. They are crucial for operational control and performance monitoring. ```c // Send difficulty update to miner int send_mining_set_difficulty(T_DATUM_CLIENT_DATA *c); // Get total subscriber count across all threads int datum_stratum_v1_global_subscriber_count(void); // Estimate total network hashrate from connected miners double datum_stratum_v1_est_total_th_sec(void); // Shutdown all Stratum connections void datum_stratum_v1_shutdown_all(void); ``` -------------------------------- ### JavaScript: Reward Sharing UI Update Source: https://github.com/ocean-xyz/datum_gateway/blob/master/www/config.html This JavaScript function dynamically updates the enabled/disabled state of pool setting input fields based on the selected 'reward_sharing' value. It iterates through input elements within the 'pool_settings' div. If 'never' is selected, all fields are disabled; otherwise, they are enabled. ```javascript function reward_sharing_changed() { var newvalue = document.getElementById('reward_sharing').value; var fields = document.getElementById('pool_settings').getElementsByTagName('input'); if (newvalue == 'never') { for (var i = 0; i < fields.length; ++i) { fields[i].setAttribute('disabled', true); } } else { for (var i = 0; i < fields.length; ++i) { fields[i].removeAttribute('disabled'); } } } reward_sharing_changed(); ``` -------------------------------- ### Configure Username Modifiers in Stratum Section Source: https://github.com/ocean-xyz/datum_gateway/blob/master/doc/usernames.md This JSON configuration defines multiple username modifiers, each with specific proportions for distributing mining shares to different Bitcoin addresses. The key 'modifier name X' represents the name of the modifier, and the nested object maps Bitcoin addresses to their respective share percentages. An empty string "" refers to the address specified in the Stratum username. ```json { "username_modifiers": { "modifier name 1": { "bitcoin address A": 0.2, "": 0.8 }, "modifier name 2": { "bitcoin address B": 0.5, "": 0.5 }, "modifier name 3": { "bitcoin address C": 0.01, "bitcoin address D": 0.99 } } } ``` -------------------------------- ### Configure Username Modifiers for Revenue Sharing (JSON) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt This JSON configuration defines username modifiers to split mining rewards among multiple addresses. It allows specifying the percentage distribution for different sharing schemes like 'revenue_share_80_20' or 'hosting_split_50_50'. The empty string key represents the default share if no specific address matches. ```json { "stratum": { "listen_port": 23334, "username_modifiers": { "revenue_share_80_20": { "bc1qprimaryaddress...": 0.8, "": 0.2 }, "hosting_split_50_50": { "bc1qhostingprovider...": 0.5, "": 0.5 }, "donation_1pct": { "bc1qdonationaddress...": 0.01, "": 0.99 } } } } ``` -------------------------------- ### Username Modifiers for Revenue Sharing Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Configure username modifiers to split mining rewards across multiple addresses based on proof-of-work hash distribution. ```APIDOC ## Username Modifiers for Revenue Sharing ### Description Configure username modifiers to split mining rewards across multiple addresses based on proof-of-work hash distribution. ### Method Not Applicable (Configuration) ### Endpoint Not Applicable (Configuration) ### Parameters #### Request Body - **stratum** (object) - Required - Stratum configuration settings. - **listen_port** (integer) - Optional - The port for the Stratum server. - **username_modifiers** (object) - Optional - Defines how usernames are modified for revenue sharing. - **modifier_name** (object) - Required - A unique name for the revenue share configuration. - **address1** (string) - Required - The first Bitcoin address. - **share1** (number) - Required - The percentage (0.0 to 1.0) of revenue for address1. - **address2** (string) - Required - The second Bitcoin address. - **share2** (number) - Required - The percentage (0.0 to 1.0) of revenue for address2. (Can include multiple addresses and shares) ### Request Example ```json { "stratum": { "listen_port": 23334, "username_modifiers": { "revenue_share_80_20": { "bc1qprimaryaddress...": 0.8, "": 0.2 }, "hosting_split_50_50": { "bc1qhostingprovider...": 0.5, "": 0.5 }, "donation_1pct": { "bc1qdonationaddress...": 0.01, "": 0.99 } } } } ``` ### Response N/A (Configuration applied on gateway startup or via update-config API) ``` -------------------------------- ### Miner Client Data Structure Definition (C) Source: https://context7.com/ocean-xyz/datum_gateway/llms.txt Defines the T_DATUM_MINER_DATA structure used to hold information about connected Stratum miners. This includes session details, user agent, authorization status, difficulty settings, share statistics, and extended Stratum features. It serves as the central repository for all data related to an individual miner connection. ```c // Miner client data structure (from datum_stratum.h) typedef struct { uint32_t sid, sid_inv; uint64_t unique_id; uint64_t connect_tsms; char useragent[128]; char last_auth_username[192]; // Stratum extensions bool extension_version_rolling; uint32_t extension_version_rolling_mask; bool extension_minimum_difficulty; double extension_minimum_difficulty_value; bool authorized; bool subscribed; uint64_t subscribe_tsms; // Variable difficulty uint64_t last_sent_diff; uint64_t current_diff; uint8_t stratum_job_targets[MAX_STRATUM_JOBS][32]; uint64_t stratum_job_diffs[MAX_STRATUM_JOBS]; // Coinbase size selection unsigned char coinbase_selection; // Share statistics uint64_t share_diff_accepted; uint64_t share_count_accepted; uint64_t share_diff_rejected; uint64_t share_count_rejected; // Vardiff tracking uint64_t share_count_since_snap; uint64_t share_diff_since_snap; uint64_t share_snap_tsms; // Quick difficulty boost bool quickdiff_active; uint64_t quickdiff_value; uint8_t quickdiff_target[32]; int last_sent_stratum_job_index; T_DATUM_STRATUM_USER_STATS stats; } T_DATUM_MINER_DATA; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.