namespace PalladiumWallet.Core.Chain; /// /// Supported network type (single selector for the whole wallet, blueprint §3). /// public enum NetKind { Mainnet, Testnet, Regtest, } /// /// Supported script/address type (blueprint §4.3). /// public enum ScriptKind { /// P2PKH legacy. Legacy, /// P2SH-P2WPKH (segwit wrapped). WrappedSegwit, /// P2WPKH (native segwit) — recommended default. NativeSegwit, /// P2SH-P2WSH (multisig wrapped). WrappedSegwitMultisig, /// P2WSH (multisig native). NativeSegwitMultisig, /// P2TR key-path only (Taproot, BIP86) — witness v1, bech32m. Taproot, } /// /// Pair of BIP32 version headers (4-byte big-endian) to serialize /// xprv/xpub and SLIP-132 variants (y/z/Y/Z) — blueprint §3. /// public readonly record struct ExtKeyHeaders(uint Private, uint Public) { /// Private header as 4 big-endian bytes (to prepend to the BIP32 payload). public byte[] PrivateBytes() => ToBytes(Private); /// Public header as 4 big-endian bytes. public byte[] PublicBytes() => ToBytes(Public); internal static byte[] ToBytes(uint header) => [ (byte)(header >> 24), (byte)(header >> 16), (byte)(header >> 8), (byte)header, ]; } /// /// Bootstrap indexing server: host + TCP port + SSL port (blueprint §3/§9). /// public readonly record struct ServerEndpoint(string Host, int TcpPort, int SslPort); /// /// Chain checkpoint: anchors trust when PoW validation is disabled /// (blueprint §7.3). Target serialized as compact "bits". /// public readonly record struct Checkpoint(int Height, string BlockHash, uint Bits); /// /// Network/chain profile (blueprint §3): all chain-specific constants, /// centralized in one place. No magic numbers elsewhere in the code. /// public sealed record ChainProfile { public required NetKind Kind { get; init; } /// Network name, also used as the data subfolder. public required string NetName { get; init; } /// Unit symbol (e.g. PLM). public required string CoinUnit { get; init; } /// WIF prefix for private keys. public required byte WifPrefix { get; init; } /// Version byte for P2PKH addresses. public required byte AddrP2pkh { get; init; } /// Version byte for P2SH addresses. public required byte AddrP2sh { get; init; } /// Human-readable part bech32/bech32m. public required string SegwitHrp { get; init; } /// HRP for BOLT11 invoices (Lightning, later phase — §11). public required string Bolt11Hrp { get; init; } /// Genesis block hash (hex, explorer byte order). public required string GenesisHash { get; init; } /// TCP port of the indexing server (not the node's P2P port). public required int DefaultTcpPort { get; init; } /// SSL port of the indexing server. public required int DefaultSslPort { get; init; } /// Node's P2P port — informational only: the SPV wallet does not use it. public required int NodeP2pPort { get; init; } /// SLIP-0044 coin type in derivation paths (wallet convention). public required int Bip44CoinType { get; init; } /// BIP21 payment URI scheme (without the colon). public required string UriScheme { get; init; } /// Default block explorer. public required string ExplorerUrl { get; init; } /// /// The chain uses LWMA (per-block retargeting, 2 minutes): an SPV client cannot /// recompute it, so bits/target validation must be skipped and trust anchored /// to checkpoints (§3/§7). For the reference chain it is always true. /// public required bool SkipPowValidation { get; init; } /// Target block time in seconds (LWMA v2: 120s). public required int BlockTimeSeconds { get; init; } /// BIP32/SLIP-132 headers for each script type. public required IReadOnlyDictionary ExtKeyHeaders { get; init; } /// Indexing servers for first contact (bootstrap). public required IReadOnlyList BootstrapServers { get; init; } /// Hardcoded checkpoints, updated at every release (§7.3). public required IReadOnlyList Checkpoints { get; init; } }