From 98bf974319c76433ba9452f269e9ba2fb0dbfb28 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 12 Jan 2023 13:50:55 +0000 Subject: [PATCH] invoices: fix to_debug_json: LN r_tags might be missing > 'r_tags': [ str((a.hex(),b.hex(),c,d,e)) for a,b,c,d,e in self._lnaddr.get_routing_info('r')[-1]] }) E IndexError: list index out of range --- electrum/invoices.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/electrum/invoices.py b/electrum/invoices.py index be5d26644..bfc10a7d9 100644 --- a/electrum/invoices.py +++ b/electrum/invoices.py @@ -266,9 +266,10 @@ class Invoice(StoredObject): 'description': self._lnaddr.get_description(), 'exp': self._lnaddr.get_expiry(), 'time': self._lnaddr.date, - # show the last hop of routing hints. (our invoices only have one hop) - 'r_tags': [ str((a.hex(),b.hex(),c,d,e)) for a,b,c,d,e in self._lnaddr.get_routing_info('r')[-1]] }) + if ln_routing_info := self._lnaddr.get_routing_info('r'): + # show the last hop of routing hints. (our invoices only have one hop) + d['r_tags'] = [str((a.hex(),b.hex(),c,d,e)) for a,b,c,d,e in ln_routing_info[-1]] return d def get_id(self) -> str: