forked from LBRYCommunity/lbry-sdk
fixed bug where lbrynet failed to start with single-key accounts in the wallet
This commit is contained in:
parent
d61ddbb950
commit
d7c2e4e9b3
2 changed files with 23 additions and 5 deletions
|
@ -4,7 +4,7 @@ import binascii
|
|||
from hashlib import sha256
|
||||
from string import hexdigits
|
||||
|
||||
from torba.client.baseaccount import BaseAccount
|
||||
from torba.client.baseaccount import BaseAccount, HierarchicalDeterministic
|
||||
from torba.client.basetransaction import TXORef
|
||||
|
||||
|
||||
|
@ -167,6 +167,7 @@ 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)
|
||||
|
|
|
@ -95,3 +95,20 @@ class TestAccount(AsyncioTestCase):
|
|||
account = Account.from_dict(self.ledger, Wallet(), account_data)
|
||||
account_data['ledger'] = 'lbc_mainnet'
|
||||
self.assertDictEqual(account_data, account.to_dict())
|
||||
|
||||
async def test_save_max_gap(self):
|
||||
account = Account.generate(
|
||||
self.ledger, Wallet(), 'lbryum', {
|
||||
'name': 'deterministic-chain',
|
||||
'receiving': {'gap': 3, 'maximum_uses_per_address': 2},
|
||||
'change': {'gap': 4, 'maximum_uses_per_address': 2}
|
||||
}
|
||||
)
|
||||
self.assertEqual(account.receiving.gap, 3)
|
||||
self.assertEqual(account.change.gap, 4)
|
||||
await account.save_max_gap()
|
||||
self.assertEqual(account.receiving.gap, 20)
|
||||
self.assertEqual(account.change.gap, 6)
|
||||
# doesn't fail for single-address account
|
||||
account2 = Account.generate(self.ledger, Wallet(), 'lbryum', {'name': 'single-address'})
|
||||
await account2.save_max_gap()
|
||||
|
|
Loading…
Reference in a new issue