Skip to content

Commit 9accd5b

Browse files
committed
dgb: add make_coin_params factory (params.hpp) — Scrypt-only
Builds a fully populated core::CoinParams for the DigiByte-Scrypt p2pool parent chain. Holds zero hardcoded consensus bytes: every consensus-critical value is sourced from the single-source-of-truth static members of dgb::CoinParams (config_coin.hpp) and dgb::PoolConfig (config_pool.hpp). Sourced from the DGB oracle frstrtr/p2pool-dgb-scrypt (switch-oracle / Option B): IDENTIFIER 4b62545b1a631afe, PREFIX 1c0553f23ebfcffe, P2P 5024, minproto floor 1700, softforks csv+segwit, version-gated donation (v35 forrestv P2PK / v36 P2SH). Single-coin scope: touches only src/impl/dgb/.
1 parent 8671b0b commit 9accd5b

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

src/impl/dgb/params.hpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#pragma once
2+
3+
// DGB CoinParams factory: builds a fully populated core::CoinParams for the
4+
// DigiByte-Scrypt p2pool parent chain.
5+
//
6+
// SOURCE OF TRUTH: the DGB oracle frstrtr/p2pool-dgb-scrypt (operator ruling
7+
// 2026-06-17, "switch-oracle" / Option B). The V36-master byte-compat
8+
// constraint with p2pool-merged-v36 is FORMALLY WAIVED for DGB by that ruling.
9+
//
10+
// CONSENSUS-NEUTRALITY: this factory holds NO hardcoded consensus bytes of its
11+
// own. Every consensus-critical value is sourced from the single-source-of-truth
12+
// static members of dgb::CoinParams (config_coin.hpp) and dgb::PoolConfig
13+
// (config_pool.hpp), so there is exactly one place a DGB constant can drift.
14+
//
15+
// Scrypt-only (V36): pow_func = scrypt; other DGB algos are accept-by-continuity
16+
// per project_v36_dgb_scrypt_only and never reach Scrypt share validation.
17+
18+
#include "config_coin.hpp"
19+
#include "config_pool.hpp"
20+
21+
#include <core/coin_params.hpp>
22+
#include <core/pow.hpp>
23+
24+
namespace dgb
25+
{
26+
27+
inline core::CoinParams make_coin_params(bool testnet)
28+
{
29+
core::CoinParams p;
30+
31+
// ===== Coin-level (net.PARENT) — from dgb::CoinParams (config_coin.hpp) =====
32+
p.symbol = "DGB";
33+
p.block_period = CoinParams::BLOCK_PERIOD; // 15s (Scrypt algo rotation slot)
34+
35+
// Address encoding
36+
if (testnet) {
37+
p.address_version = CoinParams::TESTNET_ADDRESS_VERSION; // 126
38+
p.address_p2sh_version = CoinParams::TESTNET_P2SH_VERSION; // 140
39+
p.bech32_hrp = CoinParams::TESTNET_BECH32_HRP; // "dgbt"
40+
} else {
41+
p.address_version = CoinParams::ADDRESS_VERSION; // 30 (D...)
42+
p.address_p2sh_version = CoinParams::ADDRESS_P2SH_VERSION; // 63 (S...)
43+
p.bech32_hrp = CoinParams::BECH32_HRP; // "dgb"
44+
}
45+
// address_p2sh_version2: DGB legacy P2SH prefix (5). Affects address-parse
46+
// leniency only, NOT block/share validation. [confirm-vs-oracle]
47+
p.address_p2sh_version2 = testnet ? 0 : 5;
48+
49+
// PoW: Scrypt work, SHA256d block identity (same shape as LTC)
50+
p.pow_func = core::pow::scrypt;
51+
p.block_hash_func = core::pow::sha256d;
52+
53+
// Subsidy: DGB 3-phase decay schedule (config_coin.hpp SSOT)
54+
p.subsidy_func = [](uint32_t height) -> uint64_t {
55+
return CoinParams::subsidy(height);
56+
};
57+
58+
// Dust threshold: 0.001 DGB. Local relay policy, not consensus. [confirm-vs-oracle]
59+
p.dust_threshold = 100000;
60+
61+
// Softforks — from PoolConfig SSOT (DGB oracle: csv + segwit)
62+
p.softforks_required = PoolConfig::SOFTFORKS_REQUIRED;
63+
p.segwit_activation_version = PoolConfig::SEGWIT_ACTIVATION_VERSION; // 17
64+
65+
// ===== Pool-level (net) — from dgb::PoolConfig (config_pool.hpp) =====
66+
p.p2p_port = PoolConfig::P2P_PORT; // 5024 (DGB sharechain P2P)
67+
// worker_port: DGB Stratum port. Operator-overridable via pool.yaml; the
68+
// default below is provisional pending oracle confirmation. [confirm-vs-oracle]
69+
p.worker_port = 5025;
70+
71+
if (testnet) {
72+
p.share_period = PoolConfig::TESTNET_SHARE_PERIOD; // 4
73+
p.chain_length = PoolConfig::TESTNET_CHAIN_LENGTH; // 400
74+
p.real_chain_length = PoolConfig::TESTNET_REAL_CHAIN_LENGTH; // 400
75+
} else {
76+
p.share_period = PoolConfig::SHARE_PERIOD; // 25
77+
p.chain_length = PoolConfig::CHAIN_LENGTH; // 8640
78+
p.real_chain_length = PoolConfig::REAL_CHAIN_LENGTH; // 8640
79+
}
80+
81+
p.target_lookbehind = PoolConfig::TARGET_LOOKBEHIND; // 200
82+
p.spread = PoolConfig::SPREAD; // 30
83+
p.minimum_protocol_version = PoolConfig::MINIMUM_PROTOCOL_VERSION; // 1700 floor
84+
p.block_max_size = PoolConfig::BLOCK_MAX_SIZE;
85+
p.block_max_weight = PoolConfig::BLOCK_MAX_WEIGHT;
86+
87+
// Max target (share difficulty floor) — PoolConfig SSOT, testnet-aware
88+
PoolConfig::is_testnet = testnet;
89+
p.max_target = PoolConfig::max_target();
90+
91+
// Network identification — DGB oracle (switch-oracle Option B)
92+
p.identifier_hex = PoolConfig::IDENTIFIER_HEX; // 4b62545b1a631afe
93+
p.prefix_hex = PoolConfig::DEFAULT_PREFIX_HEX; // 1c0553f23ebfcffe
94+
p.testnet_identifier_hex = PoolConfig::TESTNET_IDENTIFIER_HEX;
95+
p.testnet_prefix_hex = PoolConfig::TESTNET_PREFIX_HEX;
96+
97+
// Bootstrap peers (populated as DGB p2pool nodes come online)
98+
p.bootstrap_addrs = PoolConfig::DEFAULT_BOOTSTRAP_HOSTS;
99+
100+
// Donation scripts (consensus-critical) — version-gated selection lives in
101+
// PoolConfig::get_donation_script (SSOT). v35 = forrestv P2PK (4104ffd0...),
102+
// v36+ = combined P2SH 1-of-2.
103+
p.donation_script_func = [](int64_t share_version) -> std::vector<unsigned char> {
104+
return PoolConfig::get_donation_script(share_version);
105+
};
106+
107+
p.current_share_version = 36;
108+
p.is_testnet = testnet;
109+
110+
return p;
111+
}
112+
113+
} // namespace dgb

0 commit comments

Comments
 (0)