Skip to content
Merged
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
18 changes: 8 additions & 10 deletions pylnbits/user_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ async def get_decoded(self, bolt11: str):
try:
decode_url = self._lnbits_url + self.paypath + "/decode"
payload = {"data": bolt11}
# res = requests.post(decode_url, json=payload, headers=self._invoice_headers)
res = await post_url(self._session, path=decode_url, body=payload, headers=self._invoice_headers)
j = json.dumps(payload)
#res = requests.post(decode_url, json=payload, headers=self._invoice_headers)
res = await post_url(self._session, path=decode_url, body=j, headers=self._invoice_headers)
return res
except Exception as e:
print("Exception in get_decoded() ", e)
Expand All @@ -181,8 +182,7 @@ async def get_payhash(self, bolt11: str):
"""
Only returns the payment hash not entire decoded invoice
"""
res = await self.get_decoded(bolt11)
decoded = res.json()
decoded = await self.get_decoded(bolt11)
# print(decoded)
if "payment_hash" in decoded:
payhash = decoded["payment_hash"]
Expand Down Expand Up @@ -255,18 +255,16 @@ async def get_bolt11(self, email: str, amount: int):
"""
try:
purl = self.get_payurl(email)
res = await get_url(self._session, path=purl, headers=self._invoice_headers)
json_content = await get_url(self._session, path=purl, headers=self._invoice_headers)
# res = requests.get(purl)
json_content = res.json()
lnurlpay = json_content["callback"]

millisats = amount * 1000
payquery = lnurlpay + "?amount=" + str(millisats)

# get bech32-serialized lightning invoice
# ln_res = requests.get(payquery)
ln_res = await get_url(self._session, path=payquery, headers=self._invoice_headers)
pr_dict = ln_res.json()
# pr_dict = requests.get(payquery)
pr_dict = await get_url(self._session, path=payquery, headers=self._invoice_headers)
# check keys returned for status
if "status" in pr_dict:
reason = pr_dict["reason"]
Expand All @@ -278,4 +276,4 @@ async def get_bolt11(self, email: str, amount: int):
print("Exception as: ", str(e))
return e

# get lnbits pay_id from lightning address if its a lnpayurl
# get lnbits pay_id from lightning address if its a lnpayurl