Skip to content

Commit

Permalink
Include Base58 encoded prefixes in chainparams
Browse files Browse the repository at this point in the history
  • Loading branch information
russeree committed Oct 4, 2024
1 parent 366678f commit 749977c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ class CMainParams : public CChainParams {
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<uint8_t>(std::begin(chainparams_seed_main), std::end(chainparams_seed_main));
Expand Down Expand Up @@ -273,6 +279,12 @@ class CTestNetParams : public CChainParams {
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<uint8_t>(std::begin(chainparams_seed_test), std::end(chainparams_seed_test));
Expand Down Expand Up @@ -377,6 +389,12 @@ class CTestNet4Params : public CChainParams {
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<uint8_t>(std::begin(chainparams_seed_testnet4), std::end(chainparams_seed_testnet4));
Expand Down Expand Up @@ -511,6 +529,12 @@ class SigNetParams : public CChainParams {
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;
Expand Down Expand Up @@ -648,6 +672,12 @@ class CRegTestParams : public CChainParams
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";
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/kernel/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class CChainParams
/** Return the list of hostnames to look up for DNS seeds */
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const std::vector<std::string_view>& Base58EncodedPrefix(Base58Type type) const { return base58EncodedPrefixes[type]; }
const std::string& Bech32HRP() const { return bech32_hrp; }
const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; }
const CCheckpointData& Checkpoints() const { return checkpointData; }
Expand Down Expand Up @@ -176,6 +177,7 @@ class CChainParams
uint64_t m_assumed_chain_state_size;
std::vector<std::string> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
std::vector<std::string_view> base58EncodedPrefixes[MAX_BASE58_TYPES];
std::string bech32_hrp;
ChainType m_chain_type;
CBlock genesis;
Expand Down

0 comments on commit 749977c

Please sign in to comment.