Do extra work to find sapling params in various locations
This commit is contained in:
53
src/init.cpp
53
src/init.cpp
@@ -743,6 +743,19 @@ bool InitSanityCheck(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NoParamsShutdown(void)
|
||||||
|
{
|
||||||
|
//TODO: error message incorrect about location
|
||||||
|
LogPrintf("Could not find Sapling params anywhere! Exiting...");
|
||||||
|
uiInterface.ThreadSafeMessageBox(strprintf(
|
||||||
|
_("Cannot find the Sapling network parameters in the following directory:\n"
|
||||||
|
"%s\n"
|
||||||
|
"Please run 'zcash-fetch-params' or './zcutil/fetch-params.sh' and then restart."),
|
||||||
|
ZC_GetParamsDir()),
|
||||||
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
|
StartShutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static void ZC_LoadParams(
|
static void ZC_LoadParams(
|
||||||
const CChainParams& chainparams
|
const CChainParams& chainparams
|
||||||
@@ -751,21 +764,37 @@ static void ZC_LoadParams(
|
|||||||
struct timeval tv_start, tv_end;
|
struct timeval tv_start, tv_end;
|
||||||
float elapsed;
|
float elapsed;
|
||||||
|
|
||||||
|
// First check the global installation location
|
||||||
boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params";
|
boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params";
|
||||||
boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params";
|
boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params";
|
||||||
|
|
||||||
if (!(
|
// NOTE: This means that sapling params do not need to be installed, just findable
|
||||||
boost::filesystem::exists(sapling_spend) &&
|
if (!( boost::filesystem::exists(sapling_spend) && boost::filesystem::exists(sapling_output))) {
|
||||||
boost::filesystem::exists(sapling_output)
|
// Not globally installed, use local copies if they exist
|
||||||
)) {
|
// First check ., then .., then ../hush3
|
||||||
uiInterface.ThreadSafeMessageBox(strprintf(
|
sapling_spend = "sapling-spend.params";
|
||||||
_("Cannot find the Zcash network parameters in the following directory:\n"
|
sapling_output = "sapling-output.params";
|
||||||
"%s\n"
|
|
||||||
"Please run 'zcash-fetch-params' or './zcutil/fetch-params.sh' and then restart."),
|
// This is the most common case, for binaries distributed with params
|
||||||
ZC_GetParamsDir()),
|
if (!( boost::filesystem::exists(sapling_spend) && boost::filesystem::exists(sapling_output))) {
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
// Not in PWD, try ..
|
||||||
StartShutdown();
|
sapling_spend = boost::filesystem::path("..") / "sapling-spend.params";
|
||||||
return;
|
sapling_output = boost::filesystem::path("..") / "sapling-output.params";
|
||||||
|
|
||||||
|
// Try .. in case this binary has no params
|
||||||
|
if (!( boost::filesystem::exists(sapling_spend) && boost::filesystem::exists(sapling_output))) {
|
||||||
|
// Not in .., try ../hush3 (the case of SilentDragon installed in same directory as hush3)
|
||||||
|
sapling_spend = boost::filesystem::path("..") / "hush3" / "sapling-spend.params";
|
||||||
|
sapling_output = boost::filesystem::path("..") / "hush3" / "sapling-output.params";
|
||||||
|
|
||||||
|
// This will catch the case of any external software (i.e. GUI wallets) needing params and installed in same dir as hush3.git
|
||||||
|
if (!( boost::filesystem::exists(sapling_spend) && boost::filesystem::exists(sapling_output))) {
|
||||||
|
// No Sapling params, at least we tried
|
||||||
|
NoParamsShutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str());
|
//LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user