@@ -442,6 +442,10 @@ void print_help() {
442442 std::cout << " Nonzero: creates a private sharechain. P2P prefix\n " ;
443443 std::cout << " and THE metadata will carry this ID on the blockchain.\n " ;
444444 std::cout << " Genesis shares are created automatically when chain is empty.\n " ;
445+ std::cout << " Full 8 bytes (up to 16 hex chars) are used, not truncated.\n " ;
446+ std::cout << " --prefix HEX Explicit P2P transport-framing prefix (hex, up to 8 bytes).\n " ;
447+ std::cout << " Independent of --network-id; defaults to the compiled\n " ;
448+ std::cout << " per-network constant. Must match across all peers.\n " ;
445449 std::cout << " --startup-mode MODE Sharechain startup behavior:\n " ;
446450 std::cout << " auto — wait for peers (60s), then genesis if none (default)\n " ;
447451 std::cout << " genesis — create new chain immediately, don't wait for peers\n " ;
@@ -642,7 +646,8 @@ int main(int argc, char* argv[]) {
642646 std::string coinbase_text; // --coinbase-text (replaces /c2pool/ tag)
643647
644648 // Private sharechain
645- uint32_t network_id = 0 ; // 0 = public p2pool network, nonzero = private
649+ uint64_t network_id = 0 ; // 0 = public p2pool network, nonzero = private (full 8 bytes)
650+ std::string prefix_override_hex; // explicit --prefix; empty = compiled per-network default
646651
647652 // Startup mode: wait (default, p2pool persist=true), genesis, auto
648653 enum class StartupMode { AUTO , GENESIS , WAIT };
@@ -960,9 +965,14 @@ int main(int argc, char* argv[]) {
960965 cli_explicit.insert (" coinbase_text" );
961966 }
962967 else if ((arg == " --network-id" || arg == " --chain-id" ) && i + 1 < argc) {
963- network_id = static_cast <uint32_t >(std::stoul (argv[++i], nullptr , 16 ));
968+ // Full 8-byte identifier: parse as 64-bit, never truncate to 32 bits
969+ network_id = std::stoull (argv[++i], nullptr , 16 );
964970 cli_explicit.insert (" network_id" );
965971 }
972+ else if (arg == " --prefix" && i + 1 < argc) {
973+ prefix_override_hex = argv[++i];
974+ cli_explicit.insert (" prefix" );
975+ }
966976 else if (arg == " --startup-mode" && i + 1 < argc) {
967977 std::string mode = argv[++i];
968978 if (mode == " genesis" ) startup_mode = StartupMode::GENESIS ;
@@ -2530,11 +2540,14 @@ int main(int argc, char* argv[]) {
25302540 // Private chain: override IDENTIFIER and PREFIX before any P2P or share ops
25312541 if (network_id != 0 ) {
25322542 std::ostringstream hex;
2533- hex << std::hex << std::setfill (' 0' ) << std::setw (8 ) << network_id;
2534- // Pad to 16 hex chars (8 bytes) for full IDENTIFIER
2543+ hex << std::hex << std::setfill (' 0' ) << std::setw (16 ) << network_id; // full 8-byte IDENTIFIER, no truncation
2544+ // setw(16) already produced the full 8-byte IDENTIFIER
25352545 std::string id_hex = hex.str ();
2536- while (id_hex.size () < 16 ) id_hex += " 00" ;
25372546 ltc::PoolConfig::set_network_id (id_hex);
2547+ // PREFIX is independent: compiled per-network default unless
2548+ // explicitly overridden via --prefix (never derived from the ID)
2549+ if (!prefix_override_hex.empty ())
2550+ ltc::PoolConfig::set_prefix (prefix_override_hex);
25382551 LOG_INFO << " [Private] Network ID: " << ltc::PoolConfig::identifier_hex ()
25392552 << " (PREFIX: " << ltc::PoolConfig::prefix_hex () << " )" ;
25402553 }
0 commit comments