fix(wallet): autobackup fixes (#5269)

## Issue being fixed or feature implemented
pls see individual commits

fixes an issue (reported by @strophy recently) where mixing wouldn't
start in a fresh new wallet

not 100% sure but
[99867eb](99867eb769)
might also fix #5350 reported by @splawik21 so this could also be a v19
backport candidate

## What was done?


## How Has This Been Tested?
mixing on testnet

## Breaking Changes


## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation

**For repository code-owners and collaborators only**
- [x] I have assigned this pull request to a milestone
This commit is contained in:
UdjinM6 2023-05-10 15:46:36 +03:00 committed by pasta
parent b66dc270bc
commit 99e5b08189
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -324,6 +324,12 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::strin
wallet->m_spk_man->NewKeyPool();
// end TODO
// backup the wallet we just encrypted
if (!wallet->AutoBackupWallet("", error, warnings) && !error.original.empty()) {
status = DatabaseStatus::FAILED_ENCRYPT;
return nullptr;
}
// Relock the wallet
wallet->Lock();
}
@ -4637,11 +4643,16 @@ bool CWallet::AutoBackupWallet(const fs::path& wallet_path, bilingual_str& error
strWalletName = "wallet.dat";
}
if (!IsBDBFile(BDBDataFile(wallet_path))) {
if (!wallet_path.empty() && !IsBDBFile(BDBDataFile(wallet_path))) {
WalletLogPrintf("Automatic wallet backups are currently only supported with Berkeley DB!\n");
return false;
}
if (IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
WalletLogPrintf("Wallet is blank, won't create new backup for it!\n");
return false;
}
if (nWalletBackups <= 0) {
WalletLogPrintf("Automatic wallet backups are disabled!\n");
return false;