From 2bb30aa880a3b30535e55b9d316aa010972eabb1 Mon Sep 17 00:00:00 2001 From: Eneko Illarramendi Date: Sat, 11 Jan 2020 23:51:35 +0100 Subject: [PATCH] fix: LND invoice payments and status checks --- lnbits/wallets/lnd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lnbits/wallets/lnd.py b/lnbits/wallets/lnd.py index 3e55cd5..52927f8 100644 --- a/lnbits/wallets/lnd.py +++ b/lnbits/wallets/lnd.py @@ -26,7 +26,9 @@ class LndWallet(Wallet): return InvoiceResponse(r, payment_hash, payment_request) def pay_invoice(self, bolt11: str) -> Response: - raise NotImplementedError + return post( + url=f"{self.endpoint}/v1/channels/transactions", headers=self.auth_admin, json={"payment_request": bolt11} + ) def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus: r = get(url=f"{self.endpoint}/v1/invoice/{payment_hash}", headers=self.auth_admin) @@ -46,4 +48,5 @@ class LndWallet(Wallet): payment = payments[0] if payments else None # check payment.status: https://api.lightning.community/rest/index.html?python#peersynctype - return TxStatus(r, {0: None, 1: None, 2: True, 3: False}[payment["status"]] if payment else None) + statuses = {"UNKNOWN": None, "IN_FLIGHT": None, "SUCCEEDED": True, "FAILED": False} + return TxStatus(r, statuses[payment["status"]] if payment else None)