migrate per-account on disk encryption to encrypt-on-disk preference

This commit is contained in:
Lex Berezhny 2019-10-16 09:36:11 -04:00
parent bcd69f812e
commit 722419dffc

View file

@ -5,6 +5,7 @@ from binascii import unhexlify
from torba.client.basemanager import BaseWalletManager from torba.client.basemanager import BaseWalletManager
from torba.client.wallet import ENCRYPT_ON_DISK
from torba.rpc.jsonrpc import CodeMessageError from torba.rpc.jsonrpc import CodeMessageError
from lbry.wallet.ledger import MainNetLedger from lbry.wallet.ledger import MainNetLedger
@ -121,6 +122,9 @@ class LbryWalletManager(BaseWalletManager):
log.info('Wallet at %s is empty, generating a default account.', default_wallet.id) log.info('Wallet at %s is empty, generating a default account.', default_wallet.id)
default_wallet.generate_account(ledger) default_wallet.generate_account(ledger)
default_wallet.save() default_wallet.save()
if default_wallet.is_locked and default_wallet.preferences.get(ENCRYPT_ON_DISK) is None:
default_wallet.preferences[ENCRYPT_ON_DISK] = True
default_wallet.save()
if receiving_addresses or change_addresses: if receiving_addresses or change_addresses:
if not os.path.exists(ledger.path): if not os.path.exists(ledger.path):
os.mkdir(ledger.path) os.mkdir(ledger.path)