Skip to content

Commit e8d416c

Browse files
committed
allow all other base58 prefix things to be set by conf file
1 parent 0c7ab1f commit e8d416c

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/chainparams.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ class CCustomParams : public CChainParams {
141141
fRequireStandard = GetBoolArg("-frequirestandard", false);
142142
fMineBlocksOnDemand = GetBoolArg("-fmineblocksondemand", true);
143143
anyonecanspend_aremine = GetBoolArg("-anyonecanspendaremine", true);
144+
145+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, GetArg("-pubkeyprefix", 235));
146+
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, GetArg("-scriptprefix", 75));
147+
base58Prefixes[BLINDED_ADDRESS]= std::vector<unsigned char>(1, GetArg("-blindedprefix", 4));
148+
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, GetArg("-secretprefix", 239));
149+
150+
std::string extpubprefix = GetArg("-extpubkeyprefix", "043587CF");
151+
if (!IsHex(extpubprefix) || extpubprefix.size() != 8) {
152+
assert("-extpubkeyprefix must be hex string of length 8" && false);
153+
}
154+
base58Prefixes[EXT_PUBLIC_KEY] = ParseHex(extpubprefix);
155+
156+
std::string extprvprefix = GetArg("-extprvkeyprefix", "04358394");
157+
if (!IsHex(extprvprefix) || extprvprefix.size() != 8) {
158+
assert("-extprvkeyprefix must be hex string of length 8" && false);
159+
}
160+
base58Prefixes[EXT_SECRET_KEY] = ParseHex(extprvprefix);
161+
base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentpubkeyprefix", 111));
162+
base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentscriptprefix", 196));
163+
144164
}
145165

146166
public:
@@ -199,15 +219,6 @@ class CCustomParams : public CChainParams {
199219
0,
200220
0
201221
};
202-
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,235);
203-
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,75);
204-
base58Prefixes[BLINDED_ADDRESS]= std::vector<unsigned char>(1,4);
205-
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
206-
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
207-
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
208-
209-
base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentpubkeyprefix", 111));
210-
base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, GetArg("-parentscriptprefix", 196));
211222
}
212223
};
213224

src/chainparamsbase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
1919
strUsage += HelpMessageOpt("-chain=<chain>", strprintf(_("Use the chain <chain> (default: %s). Anything except main is allowed"), CHAINPARAMS_REGTEST));
2020
if (debugHelp) {
2121
strUsage += HelpMessageOpt("-regtest", strprintf(_("Equivalent to -chain=%s"), CHAINPARAMS_REGTEST));
22+
strUsage += HelpMessageOpt("-pubkeyprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 pubkey address. (default: %d)"), 235));
23+
strUsage += HelpMessageOpt("-scriptprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 script address. (default: %d)"), 75));
24+
strUsage += HelpMessageOpt("-secretprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 secret key encoding. (default: %d)"), 239));
25+
strUsage += HelpMessageOpt("-extpubkeyprefix", strprintf(_("The 4-byte prefix, in hex, of the chain's base58 extended public key encoding. (default: %s)"), "043587CF"));
26+
strUsage += HelpMessageOpt("-extprvkeyprefix", strprintf(_("The 4-byte prefix, in hex, of the chain's base58 extended private key encoding. (default: %s)"), "04358394"));
27+
strUsage += HelpMessageOpt("-blindedprefix", strprintf(_("The byte prefix, in decimal, of the chain's base58 script address. (default: %d)"), 4));
28+
2229
}
2330
}
2431

0 commit comments

Comments
 (0)