fix startup error when single key account present in wallet
This commit is contained in:
parent
d8d136f1d8
commit
1c2029cddf
1 changed files with 21 additions and 10 deletions
|
@ -4,6 +4,7 @@ from binascii import unhexlify
|
||||||
from typing import Tuple, List, Dict
|
from typing import Tuple, List, Dict
|
||||||
|
|
||||||
from torba.client.baseledger import BaseLedger
|
from torba.client.baseledger import BaseLedger
|
||||||
|
from torba.client.baseaccount import SingleKey
|
||||||
from lbrynet.schema.result import Outputs
|
from lbrynet.schema.result import Outputs
|
||||||
from lbrynet.schema.url import URL
|
from lbrynet.schema.url import URL
|
||||||
from lbrynet.wallet.dewies import dewies_to_lbc
|
from lbrynet.wallet.dewies import dewies_to_lbc
|
||||||
|
@ -87,16 +88,26 @@ class MainNetLedger(BaseLedger):
|
||||||
await self._report_state()
|
await self._report_state()
|
||||||
|
|
||||||
async def _report_state(self):
|
async def _report_state(self):
|
||||||
|
try:
|
||||||
for account in self.accounts:
|
for account in self.accounts:
|
||||||
total_receiving = len((await account.receiving.get_addresses()))
|
balance = dewies_to_lbc(await account.get_balance())
|
||||||
total_change = len((await account.change.get_addresses()))
|
|
||||||
channel_count = await account.get_channel_count()
|
channel_count = await account.get_channel_count()
|
||||||
claim_count = await account.get_claim_count()
|
claim_count = await account.get_claim_count()
|
||||||
balance = dewies_to_lbc(await account.get_balance())
|
if isinstance(account.receiving, SingleKey):
|
||||||
|
log.info("Loaded single key account %s with %s LBC. "
|
||||||
|
"%d channels, %d certificates and %d claims",
|
||||||
|
account.id, balance, channel_count, len(account.channel_keys), claim_count)
|
||||||
|
else:
|
||||||
|
total_receiving = len((await account.receiving.get_addresses()))
|
||||||
|
total_change = len((await account.change.get_addresses()))
|
||||||
log.info("Loaded account %s with %s LBC, %d receiving addresses (gap: %d), "
|
log.info("Loaded account %s with %s LBC, %d receiving addresses (gap: %d), "
|
||||||
"%d change addresses (gap: %d), %d channels, %d certificates and %d claims. ",
|
"%d change addresses (gap: %d), %d channels, %d certificates and %d claims. ",
|
||||||
account.id, balance, total_receiving, account.receiving.gap, total_change, account.change.gap,
|
account.id, balance, total_receiving, account.receiving.gap, total_change,
|
||||||
channel_count, len(account.channel_keys), claim_count)
|
account.change.gap, channel_count, len(account.channel_keys), claim_count)
|
||||||
|
except:
|
||||||
|
log.exception(
|
||||||
|
'Failed to display wallet state, please file issue '
|
||||||
|
'for this bug along with the traceback you see below:')
|
||||||
|
|
||||||
|
|
||||||
class TestNetLedger(MainNetLedger):
|
class TestNetLedger(MainNetLedger):
|
||||||
|
|
Loading…
Reference in a new issue