Support wallet.dat outside of datadir

Ported from 6a7cfdea54
which did not apply cleanly.
This commit is contained in:
Jonathan "Duke" Leto
2020-09-04 19:31:05 -07:00
parent 6745ea5a48
commit 5315ded786
2 changed files with 68 additions and 0 deletions

View File

@@ -668,6 +668,23 @@ void CWallet::Flush(bool shutdown)
bool CWallet::Verify(const string& walletFile, string& warningString, string& errorString)
{
LogPrintf("Using wallet %s\n", walletFile);
uiInterface.InitMessage(_("Verifying wallet..."));
if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile)) {
boost::filesystem::path path(walletFile);
if (path.is_absolute()) {
if (!boost::filesystem::exists(path.parent_path())) {
return UIError(strprintf(_("Absolute path %s does not exist!"), walletFile));
}
} else {
boost::filesystem::path full_path = GetDataDir() / path;
if (!boost::filesystem::exists(full_path.parent_path())) {
return UIError(strprintf(_("Relative path %s does not exist!"), walletFile));
}
}
}
if (!bitdb.Open(GetDataDir()))
{
// try moving the database env out of the way