This commit is contained in:
Lex Berezhny 2019-10-14 00:03:01 -04:00
parent 270f77df24
commit 45eef03576
3 changed files with 9 additions and 1 deletions

View file

@ -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),

View file

@ -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)

View file

@ -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()