From 45eef03576fd0ed40a4b793a8c49cf23d86b3e35 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 14 Oct 2019 00:03:01 -0400 Subject: [PATCH] fixes --- lbry/lbry/extras/daemon/Daemon.py | 1 + lbry/tests/integration/test_sync.py | 6 ++++++ torba/torba/client/wallet.py | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lbry/lbry/extras/daemon/Daemon.py b/lbry/lbry/extras/daemon/Daemon.py index a0602aa50..40eb38555 100644 --- a/lbry/lbry/extras/daemon/Daemon.py +++ b/lbry/lbry/extras/daemon/Daemon.py @@ -1656,6 +1656,7 @@ class Daemon(metaclass=JSONRPCServerType): for new_account in added_accounts: asyncio.create_task(self.ledger.subscribe_account(new_account)) wallet.save() + wallet.unlock(password) encrypted = wallet.pack(encrypt_password or password) return { 'hash': self.jsonrpc_sync_hash(wallet_id), diff --git a/lbry/tests/integration/test_sync.py b/lbry/tests/integration/test_sync.py index 63bef8340..161eef8bc 100644 --- a/lbry/tests/integration/test_sync.py +++ b/lbry/tests/integration/test_sync.py @@ -34,6 +34,12 @@ class WalletSynchronization(CommandTestCase): self.assertEqual(len((await daemon.jsonrpc_account_list())['lbc_regtest']), 1) + daemon2.jsonrpc_wallet_encrypt('password') + daemon2.jsonrpc_wallet_lock() + with self.assertRaises(AssertionError): + await daemon2.jsonrpc_sync_apply('password') + + daemon2.jsonrpc_wallet_unlock('password') data = await daemon2.jsonrpc_sync_apply('password') await daemon.jsonrpc_sync_apply('password', data=data['data'], blocking=True) diff --git a/torba/torba/client/wallet.py b/torba/torba/client/wallet.py index 12fac2efc..5e57b6011 100644 --- a/torba/torba/client/wallet.py +++ b/torba/torba/client/wallet.py @@ -185,6 +185,7 @@ class Wallet: def lock(self): for account in self.accounts: if not account.encrypted: + assert account.password is not None, "account was never encrypted" account.encrypt(account.password) @property @@ -201,7 +202,7 @@ class Wallet: def encrypt(self, password): for account in self.accounts: - if not self.encrypted: + if not account.encrypted: account.encrypt(password) account.serialize_encrypted = True self.save()