From c40869df4734f2cc84428324a72ada401945aab4 Mon Sep 17 00:00:00 2001 From: frstrtr Date: Wed, 17 Jun 2026 11:35:27 +0000 Subject: [PATCH] btc(v36): consume PoolConfig SSOT for segwit activation gate (FLAG 2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit share_check.hpp gated segwit serialization/merkle paths on the namespace-local btc::SEGWIT_ACTIVATION_VERSION (share_types.hpp = 17) instead of PoolConfig::SEGWIT_ACTIVATION_VERSION (= 33, jtoomim bitcoin.py:35) — the declared single source of truth. Retire the share_types-local constant, route is_segwit_activated() and all six share_check.hpp gate sites at PoolConfig, and add the config_pool.hpp include to share_types.hpp (no cycle: config_pool has no share_types dep). Low live risk (only legacy v17/v32 fall in the 17..32 gap; the live sharechain is v35/v36) but a genuine structural divergence — the gate now agrees with config across all paths. Also refresh the stale COMBINED_DONATION_SCRIPT comment (FLAG 4): BTC now runs v36-active shares; its donation leg intentionally stays the V35 P2PK (forrestv canonical BTC-mainnet donation) while the COMBINED P2SH remains LTC-only. Comment-only; no byte change. No build (capacity-return hold); staged read-only for operator-gated review. --- src/impl/btc/config_pool.hpp | 8 +++++--- src/impl/btc/share_check.hpp | 12 ++++++------ src/impl/btc/share_types.hpp | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/impl/btc/config_pool.hpp b/src/impl/btc/config_pool.hpp index 8d5a40e1b..6d72150e4 100644 --- a/src/impl/btc/config_pool.hpp +++ b/src/impl/btc/config_pool.hpp @@ -119,9 +119,11 @@ class PoolConfig : protected core::Fileconfig // V36+ COMBINED_DONATION_SCRIPT (P2SH: OP_HASH160 OP_EQUAL) // 1-of-2 multisig: forrestv + frstrtr/c2pool dev key. - // LTC-specific (BTC stays at v35 per jtoomim — see plan v2 §3); kept - // here as inert byte data so get_donation_script() compiles for both - // BTC v35 (returns the P2PK above) and LTC v36 paths. + // LTC P2SH donation target. BTC now runs v36-active shares, but its + // donation leg intentionally stays the V35 P2PK above (forrestv + // canonical BTC-mainnet donation); this COMBINED P2SH is LTC-only, + // kept here as inert byte data so get_donation_script() compiles for + // both the BTC (P2PK) and LTC v36 (P2SH) paths. // Address: MLhSmVQxMusLE3pjGFvp4unFckgjeD8LUA (LTC mainnet P2SH). static constexpr std::array COMBINED_DONATION_SCRIPT = { 0xa9, // OP_HASH160 diff --git a/src/impl/btc/share_check.hpp b/src/impl/btc/share_check.hpp index 51d837b3b..a48a0771a 100644 --- a/src/impl/btc/share_check.hpp +++ b/src/impl/btc/share_check.hpp @@ -485,7 +485,7 @@ uint256 share_init_verify(const ShareT& share, bool check_pow = true) constexpr int64_t ver = ShareT::version; - if constexpr (ver >= btc::SEGWIT_ACTIVATION_VERSION) + if constexpr (ver >= btc::PoolConfig::SEGWIT_ACTIVATION_VERSION) { if constexpr (requires { share.m_segwit_data; }) { @@ -563,7 +563,7 @@ uint256 share_init_verify(const ShareT& share, bool check_pow = true) // segwit_data (optional) if constexpr (requires { share.m_segwit_data; }) { - if constexpr (ver >= btc::SEGWIT_ACTIVATION_VERSION) + if constexpr (ver >= btc::PoolConfig::SEGWIT_ACTIVATION_VERSION) { // PossiblyNoneType: ALWAYS serialize (p2pool writes default when None) if (share.m_segwit_data.has_value()) { @@ -671,7 +671,7 @@ uint256 share_init_verify(const ShareT& share, bool check_pow = true) // --- Merkle root --- // For segwit-activated shares, use segwit_data.txid_merkle_link; otherwise merkle_link uint256 merkle_root; - if constexpr (ver >= btc::SEGWIT_ACTIVATION_VERSION) + if constexpr (ver >= btc::PoolConfig::SEGWIT_ACTIVATION_VERSION) { if constexpr (requires { share.m_segwit_data; }) { @@ -1163,7 +1163,7 @@ uint256 generate_share_transaction(const ShareT& share, TrackerT& tracker, bool size_t n_outs = payout_outputs.size() + 1 /* donation */ + 1 /* OP_RETURN commitment */; // Segwit commitment output (if applicable) bool has_segwit = false; - if constexpr (ver >= btc::SEGWIT_ACTIVATION_VERSION) + if constexpr (ver >= btc::PoolConfig::SEGWIT_ACTIVATION_VERSION) { if constexpr (requires { share.m_segwit_data; }) { @@ -1282,7 +1282,7 @@ uint256 generate_share_transaction(const ShareT& share, TrackerT& tracker, bool if constexpr (requires { share.m_segwit_data; }) { - if constexpr (ver >= btc::SEGWIT_ACTIVATION_VERSION) + if constexpr (ver >= btc::PoolConfig::SEGWIT_ACTIVATION_VERSION) { // PossiblyNoneType: ALWAYS serialize (p2pool writes default when None). // Must match share_init_verify — both paths must produce identical ref_hash. @@ -1973,7 +1973,7 @@ uint256 verify_share(const ShareT& share, TrackerT& tracker) if constexpr (requires { share.m_segwit_data; }) { - if constexpr (ver >= btc::SEGWIT_ACTIVATION_VERSION) + if constexpr (ver >= btc::PoolConfig::SEGWIT_ACTIVATION_VERSION) { // PossiblyNoneType: ALWAYS serialize (p2pool writes default when None) if (share.m_segwit_data.has_value()) { diff --git a/src/impl/btc/share_types.hpp b/src/impl/btc/share_types.hpp index 5d5b914b2..0c32b7489 100644 --- a/src/impl/btc/share_types.hpp +++ b/src/impl/btc/share_types.hpp @@ -3,15 +3,15 @@ #include #include #include +#include "config_pool.hpp" // SSOT: PoolConfig::SEGWIT_ACTIVATION_VERSION namespace btc { -const uint64_t SEGWIT_ACTIVATION_VERSION = 17; constexpr bool is_segwit_activated(uint64_t version) { - return version >= SEGWIT_ACTIVATION_VERSION; + return version >= PoolConfig::SEGWIT_ACTIVATION_VERSION; } enum StaleInfo