Skip to content

Commit

Permalink
[Refactor] First load all wallets, then back em
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra authored and furszy committed Jul 21, 2021
1 parent 91b112b commit e7aa6bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/wallet/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,22 @@ bool InitLoadWallet()
return false;
}

// automatic backup
// add to wallets in use
vpwallets.emplace_back(pwallet);
}

// automatic backup
// do this after loading all wallets, so unique fileids are checked properly
for (CWallet* pwallet: vpwallets) {
std::string strWarning, strError;
if (!AutoBackupWallet(*pwallet, strWarning, strError)) {
if (!strWarning.empty()) {
UIWarning(strprintf("%s: %s", walletFile, strWarning));
UIWarning(strprintf("%s: %s", pwallet->GetName(), strWarning));
}
if (!strError.empty()) {
return UIError(strprintf("%s: %s", walletFile, strError));
return UIError(strprintf("%s: %s", pwallet->GetName(), strError));
}
}

// add to wallets in use
vpwallets.emplace_back(pwallet);
}

return true;
Expand Down
5 changes: 2 additions & 3 deletions test/functional/wallet_multiwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ def wallet_file(name):
# should not initialize if there are duplicate wallets
self.assert_start_raises_init_error(0, ['-wallet=w1', '-wallet=w1'], 'Error loading wallet w1. Duplicate -wallet filename specified.')

# !TODO: automatic backup changes the environment, fix in the next commit
# should not initialize if one wallet is a copy of another
# shutil.copyfile(wallet_dir('w8'), wallet_dir('w8_copy'))
# self.assert_start_raises_init_error(0, ['-wallet=w8', '-wallet=w8_copy'], 'duplicates fileid')
shutil.copyfile(wallet_dir('w8'), wallet_dir('w8_copy'))
self.assert_start_raises_init_error(0, ['-wallet=w8', '-wallet=w8_copy'], 'duplicates fileid')

# should not initialize if wallet file is a symlink
os.symlink('w8', wallet_dir('w8_symlink'))
Expand Down

0 comments on commit e7aa6bd

Please sign in to comment.