From 749977cbb5ae89a00553f81b25c55b42d5c45843 Mon Sep 17 00:00:00 2001 From: Reese Russell Date: Sun, 29 Sep 2024 05:32:37 +0000 Subject: [PATCH] Include Base58 encoded prefixes in chainparams --- src/kernel/chainparams.cpp | 30 ++++++++++++++++++++++++++++++ src/kernel/chainparams.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index 0f128d4c56..5e2a24124e 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -160,6 +160,12 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4}; + base58EncodedPrefixes[PUBKEY_ADDRESS] = {"1"}; + base58EncodedPrefixes[SCRIPT_ADDRESS] = {"3"}; + base58EncodedPrefixes[SECRET_KEY] = {"5","K","L"}; + base58EncodedPrefixes[EXT_PUBLIC_KEY] = {"xpub"}; + base58EncodedPrefixes[EXT_SECRET_KEY] = {"xpriv"}; + bech32_hrp = "bc"; vFixedSeeds = std::vector(std::begin(chainparams_seed_main), std::end(chainparams_seed_main)); @@ -273,6 +279,12 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; + base58EncodedPrefixes[PUBKEY_ADDRESS] = {"m","n"}; + base58EncodedPrefixes[SCRIPT_ADDRESS] = {"2"}; + base58EncodedPrefixes[SECRET_KEY] = {"9","c"}; + base58EncodedPrefixes[EXT_PUBLIC_KEY] = {"tpub"}; + base58EncodedPrefixes[EXT_SECRET_KEY] = {"tpriv"}; + bech32_hrp = "tb"; vFixedSeeds = std::vector(std::begin(chainparams_seed_test), std::end(chainparams_seed_test)); @@ -377,6 +389,12 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; + base58EncodedPrefixes[PUBKEY_ADDRESS] = {"m","n"}; + base58EncodedPrefixes[SCRIPT_ADDRESS] = {"2"}; + base58EncodedPrefixes[SECRET_KEY] = {"9","c"}; + base58EncodedPrefixes[EXT_PUBLIC_KEY] = {"tpub"}; + base58EncodedPrefixes[EXT_SECRET_KEY] = {"tpriv"}; + bech32_hrp = "tb"; vFixedSeeds = std::vector(std::begin(chainparams_seed_testnet4), std::end(chainparams_seed_testnet4)); @@ -511,6 +529,12 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; + base58EncodedPrefixes[PUBKEY_ADDRESS] = {"m","n"}; + base58EncodedPrefixes[SCRIPT_ADDRESS] = {"2"}; + base58EncodedPrefixes[SECRET_KEY] = {"9","c"}; + base58EncodedPrefixes[EXT_PUBLIC_KEY] = {"tpub"}; + base58EncodedPrefixes[EXT_SECRET_KEY] = {"tpriv"}; + bech32_hrp = "tb"; fDefaultConsistencyChecks = false; @@ -648,6 +672,12 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; + base58EncodedPrefixes[PUBKEY_ADDRESS] = {"m","n"}; + base58EncodedPrefixes[SCRIPT_ADDRESS] = {"2"}; + base58EncodedPrefixes[SECRET_KEY] = {"9","c"}; + base58EncodedPrefixes[EXT_PUBLIC_KEY] = {"tpub"}; + base58EncodedPrefixes[EXT_SECRET_KEY] = {"tpriv"}; + bech32_hrp = "bcrt"; } }; diff --git a/src/kernel/chainparams.h b/src/kernel/chainparams.h index 8b180f3981..929293f129 100644 --- a/src/kernel/chainparams.h +++ b/src/kernel/chainparams.h @@ -118,6 +118,7 @@ public: /** Return the list of hostnames to look up for DNS seeds */ const std::vector& DNSSeeds() const { return vSeeds; } const std::vector& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } + const std::vector& Base58EncodedPrefix(Base58Type type) const { return base58EncodedPrefixes[type]; } const std::string& Bech32HRP() const { return bech32_hrp; } const std::vector& FixedSeeds() const { return vFixedSeeds; } const CCheckpointData& Checkpoints() const { return checkpointData; } @@ -176,6 +177,7 @@ protected: uint64_t m_assumed_chain_state_size; std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; + std::vector base58EncodedPrefixes[MAX_BASE58_TYPES]; std::string bech32_hrp; ChainType m_chain_type; CBlock genesis;