Skip to content

Commit

Permalink
Merge pull request #3549 from lbryio/wallet_lock_w_deterministic_chan…
Browse files Browse the repository at this point in the history
…nels

wallet locking/unlocking no longer breaks deterministic channel keys
  • Loading branch information
eukreign authored Jan 26, 2022
2 parents b5ead91 + 3a49690 commit 9adfec6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lbry/wallet/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ def __init__(self, account: 'Account'):
self.account = account
self.last_known = 0
self.cache = {}
self.private_key: Optional[PrivateKey] = None
if account.private_key is not None:
self.private_key = account.private_key.child(KeyPath.CHANNEL)
self._private_key: Optional[PrivateKey] = None

@property
def private_key(self):
if self._private_key is None:
if self.account.private_key is not None:
self._private_key = self.account.private_key.child(KeyPath.CHANNEL)
return self._private_key

def maybe_generate_deterministic_key_for_channel(self, txo):
if self.private_key is None:
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/blockchain/test_wallet_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ async def test_encryption_with_imported_channel(self):
self.assertEqual(daemon2.jsonrpc_wallet_status(),
{'is_locked': False, 'is_encrypted': True, 'is_syncing': False})

async def test_locking_unlocking_does_not_break_deterministic_channels(self):
self.assertTrue(self.daemon.jsonrpc_wallet_encrypt("password"))
self.assertTrue(self.daemon.jsonrpc_wallet_lock())
self.account.deterministic_channel_keys._private_key = None
self.assertTrue(self.daemon.jsonrpc_wallet_unlock("password"))
await self.channel_create()

async def test_sync_with_encryption_and_password_change(self):
daemon, daemon2 = self.daemon, self.daemon2
wallet, wallet2 = daemon.wallet_manager.default_wallet, daemon2.wallet_manager.default_wallet
Expand Down

0 comments on commit 9adfec6

Please sign in to comment.