From e8d416c9c037573930ef71a88075364e9e6504f8 Mon Sep 17 00:00:00 2001
From: Gregory Sanders <gsanders87@gmail.com>
Date: Tue, 5 Jun 2018 13:19:58 -0700
Subject: [PATCH] allow all other base58 prefix things to be set by conf file

---
 src/chainparams.cpp     | 29 ++++++++++++++++++++---------
 src/chainparamsbase.cpp |  7 +++++++
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 3b58079e4fd..d1fe0d94bef 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -141,6 +141,26 @@ class CCustomParams : public CChainParams {
         fRequireStandard = GetBoolArg("-frequirestandard", false);
         fMineBlocksOnDemand = GetBoolArg("-fmineblocksondemand", true);
         anyonecanspend_aremine = GetBoolArg("-anyonecanspendaremine", true);
+
+        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, GetArg("-pubkeyprefix", 235));
+        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, GetArg("-scriptprefix", 75));
+        base58Prefixes[BLINDED_ADDRESS]= std::vector<unsigned char>(1, GetArg("-blindedprefix", 4));
+        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1, GetArg("-secretprefix", 239));
+
+        std::string extpubprefix = GetArg("-extpubkeyprefix", "043587CF");
+        if (!IsHex(extpubprefix) || extpubprefix.size() != 8) {
+            assert("-extpubkeyprefix must be hex string of length 8" && false);
+        }
+        base58Prefixes[EXT_PUBLIC_KEY] = ParseHex(extpubprefix);
+
+        std::string extprvprefix = GetArg("-extprvkeyprefix", "04358394");
+        if (!IsHex(extprvprefix) || extprvprefix.size() != 8) {
+            assert("-extprvkeyprefix must be hex string of length 8" && false);
+        }
+        base58Prefixes[EXT_SECRET_KEY] = ParseHex(extprvprefix);
+        base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentpubkeyprefix", 111));
+        base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentscriptprefix", 196));
+
     }
 
 public:
@@ -199,15 +219,6 @@ class CCustomParams : public CChainParams {
             0,
             0
         };
-        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,235);
-        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,75);
-        base58Prefixes[BLINDED_ADDRESS]= std::vector<unsigned char>(1,4);
-        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
-        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
-        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
-
-        base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentpubkeyprefix", 111));
-        base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentscriptprefix", 196));
     }
 };
 
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp
index f47cfe14c09..300a9965f91 100644
--- a/src/chainparamsbase.cpp
+++ b/src/chainparamsbase.cpp
@@ -19,6 +19,13 @@ void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
     strUsage += HelpMessageOpt("-chain=<chain>", strprintf(_("Use the chain <chain> (default: %s). Anything except main is allowed"), CHAINPARAMS_REGTEST));
     if (debugHelp) {
         strUsage += HelpMessageOpt("-regtest", strprintf(_("Equivalent to -chain=%s"), CHAINPARAMS_REGTEST));
+        strUsage += HelpMessageOpt("-pubkeyprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 pubkey address. (default: %d)"), 235));
+        strUsage += HelpMessageOpt("-scriptprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 script address. (default: %d)"), 75));
+        strUsage += HelpMessageOpt("-secretprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 secret key encoding. (default: %d)"), 239));
+        strUsage += HelpMessageOpt("-extpubkeyprefix", strprintf(_("The 4-byte prefix, in hex, of the chain's base58 extended public key encoding. (default: %s)"), "043587CF"));
+        strUsage += HelpMessageOpt("-extprvkeyprefix", strprintf(_("The 4-byte prefix, in hex, of the chain's base58 extended private key encoding. (default: %s)"), "04358394"));
+        strUsage += HelpMessageOpt("-blindedprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 script address. (default: %d)"), 4));
+
     }
 }
 
