lndrest: check last 20 payments instead of first 20.
fixes https://github.com/lnbits/lnbits/issues/110
This commit is contained in:
parent
9185342c72
commit
76633fb71f
1 changed files with 6 additions and 5 deletions
|
|
@ -101,20 +101,21 @@ class LndRestWallet(Wallet):
|
||||||
url=f"{self.endpoint}/v1/payments",
|
url=f"{self.endpoint}/v1/payments",
|
||||||
headers=self.auth,
|
headers=self.auth,
|
||||||
verify=self.cert,
|
verify=self.cert,
|
||||||
params={"include_incomplete": "True", "max_payments": "20"},
|
params={"max_payments": "20", "reversed": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
if r.is_error:
|
if r.is_error:
|
||||||
return PaymentStatus(None)
|
return PaymentStatus(None)
|
||||||
|
|
||||||
payments = [p for p in r.json()["payments"] if p["payment_hash"] == checking_id]
|
|
||||||
payment = payments[0] if payments else None
|
|
||||||
|
|
||||||
# check payment.status:
|
# check payment.status:
|
||||||
# https://api.lightning.community/rest/index.html?python#peersynctype
|
# https://api.lightning.community/rest/index.html?python#peersynctype
|
||||||
statuses = {"UNKNOWN": None, "IN_FLIGHT": None, "SUCCEEDED": True, "FAILED": False}
|
statuses = {"UNKNOWN": None, "IN_FLIGHT": None, "SUCCEEDED": True, "FAILED": False}
|
||||||
|
|
||||||
return PaymentStatus(statuses[payment["status"]])
|
for p in r.json()["payments"]:
|
||||||
|
if p["payment_hash"] == checking_id:
|
||||||
|
return PaymentStatus(statuses[p["status"]])
|
||||||
|
|
||||||
|
return PaymentStatus(None)
|
||||||
|
|
||||||
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
||||||
url = self.endpoint + "/v1/invoices/subscribe"
|
url = self.endpoint + "/v1/invoices/subscribe"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue