Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions lnbits/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from urllib.parse import parse_qs, urlparse

import httpx
from bolt11 import Bolt11
from bolt11 import decode as bolt11_decode
from cryptography.hazmat.primitives import serialization
from fastapi import Depends, WebSocket
Expand Down Expand Up @@ -177,7 +176,7 @@ async def create_invoice(
payment_request=payment_request,
payment_hash=invoice.payment_hash,
amount=amount_msat,
expiry=get_bolt11_expiry(invoice),
expiry=invoice.expiry_date,
memo=memo,
extra=extra,
webhook=webhook,
Expand Down Expand Up @@ -241,7 +240,7 @@ class PaymentKwargs(TypedDict):
payment_request=payment_request,
payment_hash=invoice.payment_hash,
amount=-invoice.amount_msat,
expiry=get_bolt11_expiry(invoice),
expiry=invoice.expiry_date,
memo=description or invoice.description or "",
extra=extra,
)
Expand Down Expand Up @@ -798,11 +797,3 @@ async def get_balance_delta() -> BalanceDelta:
lnbits_balance_msats=lnbits_balance,
node_balance_msats=status.balance_msat,
)


def get_bolt11_expiry(invoice: Bolt11) -> datetime.datetime:
if invoice.expiry:
return datetime.datetime.fromtimestamp(invoice.date + invoice.expiry)
else:
# assume maximum bolt11 expiry of 31 days to be on the safe side
return datetime.datetime.now() + datetime.timedelta(days=31)
28 changes: 24 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ slowapi = "0.1.9"
websocket-client = "1.6.3"
pycryptodomex = "3.19.1"
packaging = "23.1"
bolt11 = "2.0.5"
bolt11 = "2.0.6"
# needed for new login methods: username-password, google-auth, github-auth
bcrypt = "^4.1.1"
python-jose = "^3.3.0"
Expand Down