From 9b8750b9cc8a0526184c0c144de26549725abbbd Mon Sep 17 00:00:00 2001 From: SomberNight Date: Sun, 10 Jul 2022 16:26:20 +0200 Subject: [PATCH] wallet.export_invoice: should support onchain invoice with "!" (max) amount As the GUI allows saving such invoices, CLI should not break for these wallets. Also note the pre-existing assert on the next line. follow-up https://github.com/spesmilo/electrum/commit/bf4455ef302f228828085148a267cba240d40840 ``` >>> list_invoices() Traceback (most recent call last): File "...\electrum\gui\qt\main_window.py", line 1506, in return lambda *args, **kwargs: f(method, File "...\electrum\commands.py", line 191, in _run result = fut.result() File "...\Python310\lib\concurrent\futures\_base.py", line 446, in result return self.__get_result() File "...\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result raise self._exception File "...\electrum\commands.py", line 154, in func_wrapper return await func(*args, **kwargs) File "...\electrum\commands.py", line 1188, in list_invoices return [wallet.export_invoice(x) for x in l] File "...\electrum\commands.py", line 1188, in return [wallet.export_invoice(x) for x in l] File "...\electrum\wallet.py", line 2405, in export_invoice amount_sat = int(x.get_amount_sat()) ValueError: invalid literal for int() with base 10: '!' ``` --- electrum/wallet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrum/wallet.py b/electrum/wallet.py index 9f877ead2..59078d8fa 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -2402,7 +2402,7 @@ class Abstract_Wallet(ABC, Logger, EventListener): if self.lnworker and status == PR_UNPAID: d['can_pay'] = self.lnworker.can_pay_invoice(x) else: - amount_sat = int(x.get_amount_sat()) + amount_sat = x.get_amount_sat() assert isinstance(amount_sat, (int, str, type(None))) d['amount_sat'] = amount_sat d['outputs'] = [y.to_legacy_tuple() for y in x.get_outputs()]