adding bolt11 lib and removing bolt11.py from the codebase (#1817)

* add latest bolt11 lib

decode exception handling for create_payment
fix json response for decode
bugfix hexing description hash
improvement on bolt11 lib
update to bolt11 2.0.1
fix clnrest
* bolt 2.0.4
* refactor core/crud.py

* catch bolt11 erxception clnrest
This commit is contained in:
dni ⚡
2023-09-25 12:06:54 +02:00
committed by GitHub
parent bd1db0c919
commit 1646b087cf
11 changed files with 125 additions and 429 deletions
+5 -4
View File
@@ -5,8 +5,8 @@ from urllib.parse import urlparse
from uuid import UUID, uuid4
import shortuuid
from bolt11.decode import decode
from lnbits import bolt11
from lnbits.core.db import db
from lnbits.core.models import WalletType
from lnbits.db import DB_TYPE, SQLITE, Connection, Database, Filters, Page
@@ -545,10 +545,11 @@ async def create_payment(
previous_payment = await get_standalone_payment(checking_id, conn=conn)
assert previous_payment is None, "Payment already exists"
try:
invoice = bolt11.decode(payment_request)
invoice = decode(payment_request)
if invoice.expiry:
expiration_date = datetime.datetime.fromtimestamp(invoice.date + invoice.expiry)
except Exception:
else:
# assume maximum bolt11 expiry of 31 days to be on the safe side
expiration_date = datetime.datetime.now() + datetime.timedelta(days=31)