mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-26 17:51:53 +01:00
fix: get correct LND payment_hash
This commit is contained in:
parent
47b93a97d6
commit
6d019bcb2b
@ -15,12 +15,13 @@ class LndWallet(Wallet):
|
||||
r = post(
|
||||
url=f"{self.endpoint}/v1/invoices",
|
||||
headers=self.auth_admin,
|
||||
json={"value": f"{amount}", "description_hash": memo}, # , "private": True},
|
||||
json={"value": f"{amount}", "description_hash": memo, "private": True},
|
||||
)
|
||||
|
||||
if r.ok:
|
||||
data = r.json()
|
||||
payment_hash, payment_request = data["r_hash"], data["payment_request"]
|
||||
payment_request = r.json()["payment_request"]
|
||||
decoded = get(url=f"{self.endpoint}/v1/payreq/{payment_request}", headers=self.auth_admin)
|
||||
payment_hash, payment_request = decoded.json()["payment_hash"], payment_request
|
||||
|
||||
return InvoiceResponse(r, payment_hash, payment_request)
|
||||
|
||||
@ -28,9 +29,9 @@ class LndWallet(Wallet):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus:
|
||||
r = get(url=f"{self.endpoint}/v1/invoice", headers=self.auth_admin, params={"r_hash": payment_hash})
|
||||
r = get(url=f"{self.endpoint}/v1/invoice/{payment_hash}", headers=self.auth_admin)
|
||||
|
||||
if not r.ok:
|
||||
if not r.ok or "settled" not in r.json():
|
||||
return TxStatus(r, None)
|
||||
|
||||
return TxStatus(r, r.json()["settled"])
|
||||
|
@ -27,11 +27,12 @@ class LntxbotWallet(Wallet):
|
||||
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus:
|
||||
wait = "true" if wait else "false"
|
||||
r = post(url=f"{self.endpoint}/invoicestatus/{payment_hash}?wait={wait}", headers=self.auth_invoice)
|
||||
data = r.json()
|
||||
|
||||
if not r.ok or "error" in data:
|
||||
if not r.ok or "error" in r.json():
|
||||
return TxStatus(r, None)
|
||||
|
||||
data = r.json()
|
||||
|
||||
if "preimage" not in data or not data["preimage"]:
|
||||
return TxStatus(r, False)
|
||||
|
||||
@ -39,9 +40,8 @@ class LntxbotWallet(Wallet):
|
||||
|
||||
def get_payment_status(self, payment_hash: str) -> TxStatus:
|
||||
r = post(url=f"{self.endpoint}/paymentstatus/{payment_hash}", headers=self.auth_invoice)
|
||||
data = r.json()
|
||||
|
||||
if not r.ok or "error" in data:
|
||||
if not r.ok or "error" in r.json():
|
||||
return TxStatus(r, None)
|
||||
|
||||
return TxStatus(r, {"complete": True, "failed": False, "unknown": None}[data.get("status", "unknown")])
|
||||
return TxStatus(r, {"complete": True, "failed": False, "unknown": None}[r.json().get("status", "unknown")])
|
||||
|
Loading…
x
Reference in New Issue
Block a user