diff --git a/lbry/lbry/wallet/account.py b/lbry/lbry/wallet/account.py index 7040b44a9..1e333b552 100644 --- a/lbry/lbry/wallet/account.py +++ b/lbry/lbry/wallet/account.py @@ -69,9 +69,17 @@ class Account(BaseAccount): async def save_max_gap(self): if issubclass(self.address_generator, HierarchicalDeterministic): gap = await self.get_max_gap() - self.receiving.gap = max(20, gap['max_receiving_gap'] + 1) - self.change.gap = max(6, gap['max_change_gap'] + 1) - self.wallet.save() + gap_changed = False + new_receiving_gap = max(20, gap['max_receiving_gap'] + 1) + if self.receiving.gap != new_receiving_gap: + self.receiving.gap = new_receiving_gap + gap_changed = True + new_change_gap = max(6, gap['max_change_gap'] + 1) + if self.change.gap != new_change_gap: + self.change.gap = new_change_gap + gap_changed = True + if gap_changed: + self.wallet.save() def get_balance(self, confirmations=0, include_claims=False, **constraints): if not include_claims: diff --git a/torba/torba/client/wallet.py b/torba/torba/client/wallet.py index acc1d01b4..97b12ef68 100644 --- a/torba/torba/client/wallet.py +++ b/torba/torba/client/wallet.py @@ -141,7 +141,7 @@ class Wallet: } def save(self): - if self.preferences.get(ENCRYPT_ON_DISK, False): + if not self.is_locked and self.preferences.get(ENCRYPT_ON_DISK, False): if self.encryption_password: self.storage.write(self.to_dict(encrypt_password=self.encryption_password)) return