1
0

invoices/lnaddr: LNInvoice.from_bech32 now raises InvoiceError

rm LnAddressError

fixes https://github.com/spesmilo/electrum/issues/7321
related https://github.com/spesmilo/electrum/pull/7234
This commit is contained in:
SomberNight
2021-06-07 14:46:30 +02:00
parent eb6b4580e8
commit a425ab0301
3 changed files with 13 additions and 10 deletions

View File

@@ -212,7 +212,14 @@ class LNInvoice(Invoice):
@classmethod
def from_bech32(cls, invoice: str) -> 'LNInvoice':
amount_msat = lndecode(invoice).get_amount_msat()
"""Constructs LNInvoice object from BOLT-11 string.
Might raise InvoiceError.
"""
try:
lnaddr = lndecode(invoice)
except Exception as e:
raise InvoiceError(e) from e
amount_msat = lnaddr.get_amount_msat()
return LNInvoice(
type=PR_TYPE_LN,
invoice=invoice,