UltrafastSecp256k1 3.50.0
Ultra high-performance secp256k1 elliptic curve cryptography library
Loading...
Searching...
No Matches
coin_params.hpp
Go to the documentation of this file.
1#ifndef SECP256K1_COINS_COIN_PARAMS_HPP
2#define SECP256K1_COINS_COIN_PARAMS_HPP
3#pragma once
4
5// ============================================================================
6// Coin Parameters -- constexpr definitions for all secp256k1-based coins
7// ============================================================================
8// Each CoinParams holds:
9// - Network prefixes (P2PKH version byte, WIF prefix)
10// - Bech32 HRP (human-readable part)
11// - BIP-44 coin_type
12// - Address hash algorithm (HASH160 vs Keccak-256)
13// - Feature flags (supports_segwit, supports_taproot, etc.)
14// - Display name + ticker
15//
16// All data is constexpr -- zero runtime cost, no heap allocation.
17// ============================================================================
18
19#include <cstdint>
20#include <array>
21#include <iterator>
22
23namespace secp256k1::coins {
24
25// -- Address Hash Algorithm ---------------------------------------------------
26
27enum class AddressHash : std::uint8_t {
28 HASH160, // RIPEMD160(SHA256(pubkey)) -- Bitcoin, Litecoin, etc.
29 KECCAK256, // Keccak-256(pubkey[1:]) -- Ethereum, BNB, etc.
30 BLAKE2B_160, // BLAKE2b-160 -- reserved for future use
31};
32
33// -- Address Encoding ---------------------------------------------------------
34
35enum class AddressEncoding : std::uint8_t {
36 BASE58CHECK, // Base58Check (P2PKH, P2SH)
37 BECH32, // Bech32 / Bech32m (SegWit)
38 EIP55, // Ethereum EIP-55 mixed-case checksum
39 CASHADDR, // CashAddr (Bitcoin Cash)
40 TRON_BASE58, // Tron: Keccak-256(pubkey) + 0x41 prefix + Base58Check
41};
42
43// -- Feature Flags ------------------------------------------------------------
44
46 bool supports_segwit : 1; // SegWit (P2WPKH, Bech32)
47 bool supports_taproot : 1; // Taproot (P2TR, Bech32m)
48 bool supports_p2sh : 1; // P2SH (pay-to-script-hash)
49 bool compressed_only : 1; // Only compressed pubkeys allowed
50 bool uses_evm : 1; // EVM-compatible (Ethereum-like)
51 bool uses_schnorr : 1; // Native Schnorr support (BIP-340)
52};
53
54// -- Coin Parameters ----------------------------------------------------------
55
56struct CoinParams {
57 // Display
58 const char* name; // "Bitcoin", "Litecoin", etc.
59 const char* ticker; // "BTC", "LTC", etc.
60
61 // Network prefixes
62 std::uint8_t p2pkh_version; // P2PKH address version byte
63 std::uint8_t p2pkh_version_test; // P2PKH testnet version byte
64 std::uint8_t p2sh_version; // P2SH version byte
65 std::uint8_t wif_prefix; // WIF private key prefix
66 std::uint8_t wif_prefix_test; // WIF testnet prefix
67
68 // Bech32
69 const char* bech32_hrp; // "bc", "ltc", "tb" or nullptr
70 const char* bech32_hrp_test; // Testnet HRP or nullptr
71
72 // BIP-44
73 std::uint32_t coin_type; // BIP-44 coin_type index
74
75 // Addressing
76 AddressHash hash_algo; // Which hash for address derivation
77 AddressEncoding default_encoding; // Primary address format
78
79 // Extended key versions (BIP-32)
80 std::uint32_t xprv_version; // xprv serialization magic (4 bytes)
81 std::uint32_t xpub_version; // xpub serialization magic (4 bytes)
82
83 // EVM chain ID (for EIP-155 signing; 0 = not applicable)
84 std::uint64_t chain_id;
85
86 // Features
88};
89
90// ============================================================================
91// Predefined Coin Configurations (25+ coins)
92// ============================================================================
93// All secp256k1-based cryptocurrencies
94
95// -- Bitcoin (BTC) ------------------------------------------------------------
96inline constexpr CoinParams Bitcoin = {
97 .name = "Bitcoin",
98 .ticker = "BTC",
99 .p2pkh_version = 0x00,
100 .p2pkh_version_test = 0x6F,
101 .p2sh_version = 0x05,
102 .wif_prefix = 0x80,
103 .wif_prefix_test = 0xEF,
104 .bech32_hrp = "bc",
105 .bech32_hrp_test = "tb",
106 .coin_type = 0,
107 .hash_algo = AddressHash::HASH160,
108 .default_encoding = AddressEncoding::BECH32,
109 .xprv_version = 0x0488ADE4,
110 .xpub_version = 0x0488B21E,
111 .chain_id = 0,
112 .features = {true, true, true, true, false, true},
113};
114
115// -- Litecoin (LTC) ----------------------------------------------------------
116inline constexpr CoinParams Litecoin = {
117 .name = "Litecoin",
118 .ticker = "LTC",
119 .p2pkh_version = 0x30,
120 .p2pkh_version_test = 0x6F,
121 .p2sh_version = 0x32,
122 .wif_prefix = 0xB0,
123 .wif_prefix_test = 0xEF,
124 .bech32_hrp = "ltc",
125 .bech32_hrp_test = "tltc",
126 .coin_type = 2,
127 .hash_algo = AddressHash::HASH160,
128 .default_encoding = AddressEncoding::BECH32,
129 .xprv_version = 0x0488ADE4,
130 .xpub_version = 0x0488B21E,
131 .chain_id = 0,
132 .features = {true, false, true, true, false, false},
133};
134
135// -- Dogecoin (DOGE) ----------------------------------------------------------
136inline constexpr CoinParams Dogecoin = {
137 .name = "Dogecoin",
138 .ticker = "DOGE",
139 .p2pkh_version = 0x1E,
140 .p2pkh_version_test = 0x71,
141 .p2sh_version = 0x16,
142 .wif_prefix = 0x9E,
143 .wif_prefix_test = 0xF1,
144 .bech32_hrp = nullptr,
145 .bech32_hrp_test = nullptr,
146 .coin_type = 3,
147 .hash_algo = AddressHash::HASH160,
148 .default_encoding = AddressEncoding::BASE58CHECK,
149 .xprv_version = 0x02FAC398,
150 .xpub_version = 0x02FACAFD,
151 .chain_id = 0,
152 .features = {false, false, true, false, false, false},
153};
154
155// -- Dash (DASH) --------------------------------------------------------------
156inline constexpr CoinParams Dash = {
157 .name = "Dash",
158 .ticker = "DASH",
159 .p2pkh_version = 0x4C,
160 .p2pkh_version_test = 0x8C,
161 .p2sh_version = 0x10,
162 .wif_prefix = 0xCC,
163 .wif_prefix_test = 0xEF,
164 .bech32_hrp = nullptr,
165 .bech32_hrp_test = nullptr,
166 .coin_type = 5,
167 .hash_algo = AddressHash::HASH160,
168 .default_encoding = AddressEncoding::BASE58CHECK,
169 .xprv_version = 0x0488ADE4,
170 .xpub_version = 0x0488B21E,
171 .chain_id = 0,
172 .features = {false, false, true, true, false, false},
173};
174
175// -- Ethereum (ETH) -----------------------------------------------------------
176inline constexpr CoinParams Ethereum = {
177 .name = "Ethereum",
178 .ticker = "ETH",
179 .p2pkh_version = 0x00, // Not used (EVM addresses)
180 .p2pkh_version_test = 0x00,
181 .p2sh_version = 0x00,
182 .wif_prefix = 0x00, // Not used (raw hex private keys)
183 .wif_prefix_test = 0x00,
184 .bech32_hrp = nullptr,
185 .bech32_hrp_test = nullptr,
186 .coin_type = 60,
187 .hash_algo = AddressHash::KECCAK256,
188 .default_encoding = AddressEncoding::EIP55,
189 .xprv_version = 0x0488ADE4,
190 .xpub_version = 0x0488B21E,
191 .chain_id = 1,
192 .features = {false, false, false, true, true, false},
193};
194
195// -- Bitcoin Cash (BCH) -------------------------------------------------------
196inline constexpr CoinParams BitcoinCash = {
197 .name = "Bitcoin Cash",
198 .ticker = "BCH",
199 .p2pkh_version = 0x00,
200 .p2pkh_version_test = 0x6F,
201 .p2sh_version = 0x05,
202 .wif_prefix = 0x80,
203 .wif_prefix_test = 0xEF,
204 .bech32_hrp = nullptr,
205 .bech32_hrp_test = nullptr,
206 .coin_type = 145,
207 .hash_algo = AddressHash::HASH160,
208 .default_encoding = AddressEncoding::CASHADDR,
209 .xprv_version = 0x0488ADE4,
210 .xpub_version = 0x0488B21E,
211 .chain_id = 0,
212 .features = {false, false, true, true, false, true},
213};
214
215// -- Bitcoin SV (BSV) ---------------------------------------------------------
216inline constexpr CoinParams BitcoinSV = {
217 .name = "Bitcoin SV",
218 .ticker = "BSV",
219 .p2pkh_version = 0x00,
220 .p2pkh_version_test = 0x6F,
221 .p2sh_version = 0x05,
222 .wif_prefix = 0x80,
223 .wif_prefix_test = 0xEF,
224 .bech32_hrp = nullptr,
225 .bech32_hrp_test = nullptr,
226 .coin_type = 236,
227 .hash_algo = AddressHash::HASH160,
228 .default_encoding = AddressEncoding::BASE58CHECK,
229 .xprv_version = 0x0488ADE4,
230 .xpub_version = 0x0488B21E,
231 .chain_id = 0,
232 .features = {false, false, true, false, false, false},
233};
234
235// -- Zcash (ZEC) --------------------------------------------------------------
236inline constexpr CoinParams Zcash = {
237 .name = "Zcash",
238 .ticker = "ZEC",
239 .p2pkh_version = 0x1C, // t-addr prefix first byte (0x1CB8 two-byte)
240 .p2pkh_version_test = 0x1D,
241 .p2sh_version = 0x1C, // 0x1CBD
242 .wif_prefix = 0x80,
243 .wif_prefix_test = 0xEF,
244 .bech32_hrp = nullptr,
245 .bech32_hrp_test = nullptr,
246 .coin_type = 133,
247 .hash_algo = AddressHash::HASH160,
248 .default_encoding = AddressEncoding::BASE58CHECK,
249 .xprv_version = 0x0488ADE4,
250 .xpub_version = 0x0488B21E,
251 .chain_id = 0,
252 .features = {false, false, true, true, false, false},
253};
254
255// -- DigiByte (DGB) -----------------------------------------------------------
256inline constexpr CoinParams DigiByte = {
257 .name = "DigiByte",
258 .ticker = "DGB",
259 .p2pkh_version = 0x1E,
260 .p2pkh_version_test = 0x7E,
261 .p2sh_version = 0x3F,
262 .wif_prefix = 0x80,
263 .wif_prefix_test = 0xFE,
264 .bech32_hrp = "dgb",
265 .bech32_hrp_test = "dgbt",
266 .coin_type = 20,
267 .hash_algo = AddressHash::HASH160,
268 .default_encoding = AddressEncoding::BECH32,
269 .xprv_version = 0x0488ADE4,
270 .xpub_version = 0x0488B21E,
271 .chain_id = 0,
272 .features = {true, false, true, true, false, false},
273};
274
275// -- Namecoin (NMC) -----------------------------------------------------------
276inline constexpr CoinParams Namecoin = {
277 .name = "Namecoin",
278 .ticker = "NMC",
279 .p2pkh_version = 0x34,
280 .p2pkh_version_test = 0x6F,
281 .p2sh_version = 0x0D,
282 .wif_prefix = 0xB4,
283 .wif_prefix_test = 0xEF,
284 .bech32_hrp = nullptr,
285 .bech32_hrp_test = nullptr,
286 .coin_type = 7,
287 .hash_algo = AddressHash::HASH160,
288 .default_encoding = AddressEncoding::BASE58CHECK,
289 .xprv_version = 0x0488ADE4,
290 .xpub_version = 0x0488B21E,
291 .chain_id = 0,
292 .features = {false, false, true, true, false, false},
293};
294
295// -- Peercoin (PPC) -----------------------------------------------------------
296inline constexpr CoinParams Peercoin = {
297 .name = "Peercoin",
298 .ticker = "PPC",
299 .p2pkh_version = 0x37,
300 .p2pkh_version_test = 0x6F,
301 .p2sh_version = 0x75,
302 .wif_prefix = 0xB7,
303 .wif_prefix_test = 0xEF,
304 .bech32_hrp = nullptr,
305 .bech32_hrp_test = nullptr,
306 .coin_type = 6,
307 .hash_algo = AddressHash::HASH160,
308 .default_encoding = AddressEncoding::BASE58CHECK,
309 .xprv_version = 0x0488ADE4,
310 .xpub_version = 0x0488B21E,
311 .chain_id = 0,
312 .features = {false, false, true, false, false, false},
313};
314
315// -- Vertcoin (VTC) -----------------------------------------------------------
316inline constexpr CoinParams Vertcoin = {
317 .name = "Vertcoin",
318 .ticker = "VTC",
319 .p2pkh_version = 0x47,
320 .p2pkh_version_test = 0x4A,
321 .p2sh_version = 0x05,
322 .wif_prefix = 0x80,
323 .wif_prefix_test = 0xEF,
324 .bech32_hrp = "vtc",
325 .bech32_hrp_test = "tvtc",
326 .coin_type = 28,
327 .hash_algo = AddressHash::HASH160,
328 .default_encoding = AddressEncoding::BECH32,
329 .xprv_version = 0x0488ADE4,
330 .xpub_version = 0x0488B21E,
331 .chain_id = 0,
332 .features = {true, false, true, true, false, false},
333};
334
335// -- Viacoin (VIA) ------------------------------------------------------------
336inline constexpr CoinParams Viacoin = {
337 .name = "Viacoin",
338 .ticker = "VIA",
339 .p2pkh_version = 0x47,
340 .p2pkh_version_test = 0x7F,
341 .p2sh_version = 0x21,
342 .wif_prefix = 0xC7,
343 .wif_prefix_test = 0xFF,
344 .bech32_hrp = "via",
345 .bech32_hrp_test = "tvia",
346 .coin_type = 14,
347 .hash_algo = AddressHash::HASH160,
348 .default_encoding = AddressEncoding::BECH32,
349 .xprv_version = 0x0488ADE4,
350 .xpub_version = 0x0488B21E,
351 .chain_id = 0,
352 .features = {true, false, true, true, false, false},
353};
354
355// -- Groestlcoin (GRS) --------------------------------------------------------
356inline constexpr CoinParams Groestlcoin = {
357 .name = "Groestlcoin",
358 .ticker = "GRS",
359 .p2pkh_version = 0x24,
360 .p2pkh_version_test = 0x6F,
361 .p2sh_version = 0x05,
362 .wif_prefix = 0x80,
363 .wif_prefix_test = 0xEF,
364 .bech32_hrp = "grs",
365 .bech32_hrp_test = "tgrs",
366 .coin_type = 17,
367 .hash_algo = AddressHash::HASH160,
368 .default_encoding = AddressEncoding::BECH32,
369 .xprv_version = 0x0488ADE4,
370 .xpub_version = 0x0488B21E,
371 .chain_id = 0,
372 .features = {true, true, true, true, false, false},
373};
374
375// -- Syscoin (SYS) ------------------------------------------------------------
376inline constexpr CoinParams Syscoin = {
377 .name = "Syscoin",
378 .ticker = "SYS",
379 .p2pkh_version = 0x3F,
380 .p2pkh_version_test = 0x41,
381 .p2sh_version = 0x05,
382 .wif_prefix = 0x80,
383 .wif_prefix_test = 0xEF,
384 .bech32_hrp = "sys",
385 .bech32_hrp_test = "tsys",
386 .coin_type = 57,
387 .hash_algo = AddressHash::HASH160,
388 .default_encoding = AddressEncoding::BECH32,
389 .xprv_version = 0x0488ADE4,
390 .xpub_version = 0x0488B21E,
391 .chain_id = 0,
392 .features = {true, false, true, true, false, false},
393};
394
395// -- BNB Smart Chain (BNB) ----------------------------------------------------
396inline constexpr CoinParams BNBSmartChain = {
397 .name = "BNB Smart Chain",
398 .ticker = "BNB",
399 .p2pkh_version = 0x00,
400 .p2pkh_version_test = 0x00,
401 .p2sh_version = 0x00,
402 .wif_prefix = 0x00,
403 .wif_prefix_test = 0x00,
404 .bech32_hrp = nullptr,
405 .bech32_hrp_test = nullptr,
406 .coin_type = 60, // Same as Ethereum for BSC
407 .hash_algo = AddressHash::KECCAK256,
408 .default_encoding = AddressEncoding::EIP55,
409 .xprv_version = 0x0488ADE4,
410 .xpub_version = 0x0488B21E,
411 .chain_id = 56,
412 .features = {false, false, false, true, true, false},
413};
414
415// -- Polygon (MATIC / POL) ----------------------------------------------------
416inline constexpr CoinParams Polygon = {
417 .name = "Polygon",
418 .ticker = "POL",
419 .p2pkh_version = 0x00,
420 .p2pkh_version_test = 0x00,
421 .p2sh_version = 0x00,
422 .wif_prefix = 0x00,
423 .wif_prefix_test = 0x00,
424 .bech32_hrp = nullptr,
425 .bech32_hrp_test = nullptr,
426 .coin_type = 60,
427 .hash_algo = AddressHash::KECCAK256,
428 .default_encoding = AddressEncoding::EIP55,
429 .xprv_version = 0x0488ADE4,
430 .xpub_version = 0x0488B21E,
431 .chain_id = 137,
432 .features = {false, false, false, true, true, false},
433};
434
435// -- Avalanche C-Chain (AVAX) -------------------------------------------------
436inline constexpr CoinParams Avalanche = {
437 .name = "Avalanche",
438 .ticker = "AVAX",
439 .p2pkh_version = 0x00,
440 .p2pkh_version_test = 0x00,
441 .p2sh_version = 0x00,
442 .wif_prefix = 0x00,
443 .wif_prefix_test = 0x00,
444 .bech32_hrp = nullptr,
445 .bech32_hrp_test = nullptr,
446 .coin_type = 60,
447 .hash_algo = AddressHash::KECCAK256,
448 .default_encoding = AddressEncoding::EIP55,
449 .xprv_version = 0x0488ADE4,
450 .xpub_version = 0x0488B21E,
451 .chain_id = 43114,
452 .features = {false, false, false, true, true, false},
453};
454
455// -- Fantom (FTM) -------------------------------------------------------------
456inline constexpr CoinParams Fantom = {
457 .name = "Fantom",
458 .ticker = "FTM",
459 .p2pkh_version = 0x00,
460 .p2pkh_version_test = 0x00,
461 .p2sh_version = 0x00,
462 .wif_prefix = 0x00,
463 .wif_prefix_test = 0x00,
464 .bech32_hrp = nullptr,
465 .bech32_hrp_test = nullptr,
466 .coin_type = 60,
467 .hash_algo = AddressHash::KECCAK256,
468 .default_encoding = AddressEncoding::EIP55,
469 .xprv_version = 0x0488ADE4,
470 .xpub_version = 0x0488B21E,
471 .chain_id = 250,
472 .features = {false, false, false, true, true, false},
473};
474
475// -- Arbitrum (ARB) -----------------------------------------------------------
476inline constexpr CoinParams Arbitrum = {
477 .name = "Arbitrum",
478 .ticker = "ARB",
479 .p2pkh_version = 0x00,
480 .p2pkh_version_test = 0x00,
481 .p2sh_version = 0x00,
482 .wif_prefix = 0x00,
483 .wif_prefix_test = 0x00,
484 .bech32_hrp = nullptr,
485 .bech32_hrp_test = nullptr,
486 .coin_type = 60,
487 .hash_algo = AddressHash::KECCAK256,
488 .default_encoding = AddressEncoding::EIP55,
489 .xprv_version = 0x0488ADE4,
490 .xpub_version = 0x0488B21E,
491 .chain_id = 42161,
492 .features = {false, false, false, true, true, false},
493};
494
495// -- Optimism (OP) ------------------------------------------------------------
496inline constexpr CoinParams Optimism = {
497 .name = "Optimism",
498 .ticker = "OP",
499 .p2pkh_version = 0x00,
500 .p2pkh_version_test = 0x00,
501 .p2sh_version = 0x00,
502 .wif_prefix = 0x00,
503 .wif_prefix_test = 0x00,
504 .bech32_hrp = nullptr,
505 .bech32_hrp_test = nullptr,
506 .coin_type = 60,
507 .hash_algo = AddressHash::KECCAK256,
508 .default_encoding = AddressEncoding::EIP55,
509 .xprv_version = 0x0488ADE4,
510 .xpub_version = 0x0488B21E,
511 .chain_id = 10,
512 .features = {false, false, false, true, true, false},
513};
514
515// -- Ravencoin (RVN) ----------------------------------------------------------
516inline constexpr CoinParams Ravencoin = {
517 .name = "Ravencoin",
518 .ticker = "RVN",
519 .p2pkh_version = 0x3C,
520 .p2pkh_version_test = 0x6F,
521 .p2sh_version = 0x7A,
522 .wif_prefix = 0x80,
523 .wif_prefix_test = 0xEF,
524 .bech32_hrp = nullptr,
525 .bech32_hrp_test = nullptr,
526 .coin_type = 175,
527 .hash_algo = AddressHash::HASH160,
528 .default_encoding = AddressEncoding::BASE58CHECK,
529 .xprv_version = 0x0488ADE4,
530 .xpub_version = 0x0488B21E,
531 .chain_id = 0,
532 .features = {false, false, true, true, false, false},
533};
534
535// -- Flux (FLUX) --------------------------------------------------------------
536inline constexpr CoinParams Flux = {
537 .name = "Flux",
538 .ticker = "FLUX",
539 .p2pkh_version = 0x1C, // t1...
540 .p2pkh_version_test = 0x1D,
541 .p2sh_version = 0x1C,
542 .wif_prefix = 0x80,
543 .wif_prefix_test = 0xEF,
544 .bech32_hrp = nullptr,
545 .bech32_hrp_test = nullptr,
546 .coin_type = 19167,
547 .hash_algo = AddressHash::HASH160,
548 .default_encoding = AddressEncoding::BASE58CHECK,
549 .xprv_version = 0x0488ADE4,
550 .xpub_version = 0x0488B21E,
551 .chain_id = 0,
552 .features = {false, false, true, true, false, false},
553};
554
555// -- Qtum (QTUM) --------------------------------------------------------------
556inline constexpr CoinParams Qtum = {
557 .name = "Qtum",
558 .ticker = "QTUM",
559 .p2pkh_version = 0x3A,
560 .p2pkh_version_test = 0x78,
561 .p2sh_version = 0x32,
562 .wif_prefix = 0x80,
563 .wif_prefix_test = 0xEF,
564 .bech32_hrp = "qc",
565 .bech32_hrp_test = "tq",
566 .coin_type = 2301,
567 .hash_algo = AddressHash::HASH160,
568 .default_encoding = AddressEncoding::BASE58CHECK,
569 .xprv_version = 0x0488ADE4,
570 .xpub_version = 0x0488B21E,
571 .chain_id = 0,
572 .features = {true, false, true, true, false, false},
573};
574
575// -- Horizen (ZEN) ------------------------------------------------------------
576inline constexpr CoinParams Horizen = {
577 .name = "Horizen",
578 .ticker = "ZEN",
579 .p2pkh_version = 0x20, // zn...
580 .p2pkh_version_test = 0x20,
581 .p2sh_version = 0x20,
582 .wif_prefix = 0x80,
583 .wif_prefix_test = 0xEF,
584 .bech32_hrp = nullptr,
585 .bech32_hrp_test = nullptr,
586 .coin_type = 121,
587 .hash_algo = AddressHash::HASH160,
588 .default_encoding = AddressEncoding::BASE58CHECK,
589 .xprv_version = 0x0488ADE4,
590 .xpub_version = 0x0488B21E,
591 .chain_id = 0,
592 .features = {false, false, true, true, false, false},
593};
594
595// -- Bitcoin Gold (BTG) -------------------------------------------------------
596inline constexpr CoinParams BitcoinGold = {
597 .name = "Bitcoin Gold",
598 .ticker = "BTG",
599 .p2pkh_version = 0x26,
600 .p2pkh_version_test = 0x6F,
601 .p2sh_version = 0x17,
602 .wif_prefix = 0x80,
603 .wif_prefix_test = 0xEF,
604 .bech32_hrp = "btg",
605 .bech32_hrp_test = "tbtg",
606 .coin_type = 156,
607 .hash_algo = AddressHash::HASH160,
608 .default_encoding = AddressEncoding::BASE58CHECK,
609 .xprv_version = 0x0488ADE4,
610 .xpub_version = 0x0488B21E,
611 .chain_id = 0,
612 .features = {true, false, true, true, false, false},
613};
614
615// -- Komodo (KMD) -------------------------------------------------------------
616inline constexpr CoinParams Komodo = {
617 .name = "Komodo",
618 .ticker = "KMD",
619 .p2pkh_version = 0x3C,
620 .p2pkh_version_test = 0x00,
621 .p2sh_version = 0x55,
622 .wif_prefix = 0xBC,
623 .wif_prefix_test = 0x00,
624 .bech32_hrp = nullptr,
625 .bech32_hrp_test = nullptr,
626 .coin_type = 141,
627 .hash_algo = AddressHash::HASH160,
628 .default_encoding = AddressEncoding::BASE58CHECK,
629 .xprv_version = 0x0488ADE4,
630 .xpub_version = 0x0488B21E,
631 .chain_id = 0,
632 .features = {false, false, true, true, false, false},
633};
634
635// -- Tron (TRX) ---------------------------------------------------------------
636inline constexpr CoinParams Tron = {
637 .name = "Tron",
638 .ticker = "TRX",
639 .p2pkh_version = 0x41, // Tron address prefix byte
640 .p2pkh_version_test = 0xA0,
641 .p2sh_version = 0x00,
642 .wif_prefix = 0x00, // Not used (raw hex private keys)
643 .wif_prefix_test = 0x00,
644 .bech32_hrp = nullptr,
645 .bech32_hrp_test = nullptr,
646 .coin_type = 195,
647 .hash_algo = AddressHash::KECCAK256,
648 .default_encoding = AddressEncoding::TRON_BASE58,
649 .xprv_version = 0x0488ADE4,
650 .xpub_version = 0x0488B21E,
651 .chain_id = 0,
652 .features = {false, false, false, true, false, false},
653};
654
655// ============================================================================
656// Coin Registry -- Lookup by coin_type or ticker
657// ============================================================================
658
659// All predefined coins for iteration
668
669inline constexpr std::size_t ALL_COINS_COUNT = std::size(ALL_COINS);
670
671// Find coin by BIP-44 coin_type (returns nullptr if not found)
672inline const CoinParams* find_by_coin_type(std::uint32_t coin_type) {
673 for (const auto* coin : ALL_COINS) {
674 if (coin->coin_type == coin_type) return coin;
675 }
676 return nullptr;
677}
678
679// Find coin by ticker string (case-sensitive, returns nullptr if not found)
680inline const CoinParams* find_by_ticker(const char* ticker) {
681 for (const auto* coin : ALL_COINS) {
682 const char* a = coin->ticker;
683 const char* b = ticker;
684 bool match = true;
685 while (*a && *b) {
686 if (*a != *b) { match = false; break; }
687 ++a; ++b;
688 }
689 if (match && *a == *b) return coin;
690 }
691 return nullptr;
692}
693
694} // namespace secp256k1::coins
695
696#endif // SECP256K1_COINS_COIN_PARAMS_HPP
constexpr CoinParams Syscoin
constexpr CoinParams Horizen
const CoinParams * find_by_coin_type(std::uint32_t coin_type)
constexpr CoinParams Viacoin
constexpr CoinParams Namecoin
constexpr CoinParams Optimism
constexpr CoinParams BitcoinGold
constexpr CoinParams Dogecoin
constexpr CoinParams Avalanche
constexpr CoinParams Vertcoin
constexpr CoinParams BNBSmartChain
constexpr CoinParams Qtum
constexpr CoinParams Ethereum
constexpr CoinParams Flux
constexpr CoinParams Komodo
constexpr CoinParams Fantom
constexpr CoinParams Arbitrum
constexpr CoinParams BitcoinCash
constexpr const CoinParams * ALL_COINS[]
constexpr CoinParams Litecoin
constexpr CoinParams Ravencoin
constexpr CoinParams Tron
constexpr CoinParams BitcoinSV
constexpr CoinParams Bitcoin
constexpr CoinParams Peercoin
constexpr CoinParams Groestlcoin
constexpr CoinParams Zcash
const CoinParams * find_by_ticker(const char *ticker)
constexpr std::size_t ALL_COINS_COUNT
constexpr CoinParams Dash
constexpr CoinParams Polygon
constexpr CoinParams DigiByte
AddressEncoding default_encoding