Skip to content

ltc: fix private-net IDENTIFIER truncation + independent PREFIX (V36 ship-blocker) - #95

Merged
frstrtr merged 1 commit into
masterfrom
ltc-doge/private-net-id-prefix-fix
Jun 15, 2026
Merged

ltc: fix private-net IDENTIFIER truncation + independent PREFIX (V36 ship-blocker)#95
frstrtr merged 1 commit into
masterfrom
ltc-doge/private-net-id-prefix-fix

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes two independent defects in c2pool private-sharechain identity that prevented joining any p2pool net (the V36 crossing-soak blocker, #93-class parity fix). LTC shape; btc/dgb/dash/bch get the identical fix via their stewards.

Bug (i) — --network-id truncated to 32 bits

main() parsed the id via static_cast<uint32_t>(std::stoul(...)) and formatted it with setw(8), so an 8-byte identifier (e.g. 9765c71ad4c00467) collapsed to its low 4 bytes (d4c00467). Two operators passing the same 8-byte id would silently run on different chains.

  • network_id is now uint64_t, parsed with std::stoull, formatted with setw(16); the redundant right-pad is removed.

Bug (ii) — PREFIX XOR-derived from IDENTIFIER

set_network_id() derived the transport PREFIX from the IDENTIFIER via an XOR-rotate. A peer that supplies its PREFIX independently (as p2pool does — a fixed per-network constant) computes a different value → prefix doesn't matchPeers:0.

  • PREFIX is now an independent per-network constant, falling back to the compiled testnet/mainnet value, overridable via a new --prefix flag. set_network_id() no longer touches PREFIX. chain_fingerprint_u64() now hashes the effective prefix_hex().

Changes

  • impl/ltc/config_pool.hpp: drop XOR derivation from set_network_id(); add set_prefix(); fingerprint over effective prefix.
  • c2pool/c2pool_refactored.cpp: uint64_t id + std::stoull + setw(16); add --prefix flag, override wiring, help text.

Test plan

  • CI: Linux x86_64 ctest (authoritative).
  • Manual: --network-id 9765c71ad4c00467 now logs IDENTIFIER 9765c71ad4c00467 (not 00000000d4c00467); with no --prefix, PREFIX = compiled testnet constant ad9614f6466a39cf.

Merge is operator-gated. Reviewer: dash-consensus-pay-replay.

…ship-blocker)

Two defects prevented c2pool from joining any p2pool private net:

(i) --network-id truncated to 32 bits: parsed via
    static_cast<uint32_t>(std::stoul(...)) and formatted with setw(8),
    so an 8-byte id (e.g. 9765c71ad4c00467) collapsed to its low 4 bytes
    (d4c00467). Parse as uint64_t (std::stoull) and format with setw(16);
    drop the now-redundant right-pad.

(ii) PREFIX was XOR-derived from IDENTIFIER in set_network_id(), so two
    nodes with the same id but a different prefix source got
    "prefix doesn't match" -> Peers:0. PREFIX is now an independent
    per-network constant, overridable via a new --prefix flag;
    set_network_id() no longer derives it. chain_fingerprint_u64() now
    hashes the effective prefix_hex().

Adds set_prefix() + --prefix CLI flag and help text. ltc shape only;
btc/dgb/dash/bch receive the identical fix via their stewards.
else if ((arg == "--network-id" || arg == "--chain-id") && i + 1 < argc) {
network_id = static_cast<uint32_t>(std::stoul(argv[++i], nullptr, 16));
// Full 8-byte identifier: parse as 64-bit, never truncate to 32 bits
network_id = std::stoull(argv[++i], nullptr, 16);
cli_explicit.insert("network_id");
}
else if (arg == "--prefix" && i + 1 < argc) {
prefix_override_hex = argv[++i];
@frstrtr
frstrtr merged commit 96b22ad into master Jun 15, 2026
16 checks passed
frstrtr added a commit that referenced this pull request Jun 16, 2026
…ependence

btc/v36: network-id/prefix independence (#95 BTC mirror)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants