Skip to content

Commit a2afc14

Browse files
authored
Merge pull request #17 from FelixFrei/bugfix/16-div-compatibility-fix
Div compatibility fix #16
2 parents e0ffcc0 + b0b7f30 commit a2afc14

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

pylnbits/user_wallet.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ async def get_decoded(self, bolt11: str):
169169
try:
170170
decode_url = self._lnbits_url + self.paypath + "/decode"
171171
payload = {"data": bolt11}
172-
# res = requests.post(decode_url, json=payload, headers=self._invoice_headers)
173-
res = await post_url(self._session, path=decode_url, body=payload, headers=self._invoice_headers)
172+
j = json.dumps(payload)
173+
#res = requests.post(decode_url, json=payload, headers=self._invoice_headers)
174+
res = await post_url(self._session, path=decode_url, body=j, headers=self._invoice_headers)
174175
return res
175176
except Exception as e:
176177
print("Exception in get_decoded() ", e)
@@ -181,8 +182,7 @@ async def get_payhash(self, bolt11: str):
181182
"""
182183
Only returns the payment hash not entire decoded invoice
183184
"""
184-
res = await self.get_decoded(bolt11)
185-
decoded = res.json()
185+
decoded = await self.get_decoded(bolt11)
186186
# print(decoded)
187187
if "payment_hash" in decoded:
188188
payhash = decoded["payment_hash"]
@@ -255,18 +255,16 @@ async def get_bolt11(self, email: str, amount: int):
255255
"""
256256
try:
257257
purl = self.get_payurl(email)
258-
res = await get_url(self._session, path=purl, headers=self._invoice_headers)
258+
json_content = await get_url(self._session, path=purl, headers=self._invoice_headers)
259259
# res = requests.get(purl)
260-
json_content = res.json()
261260
lnurlpay = json_content["callback"]
262261

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

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

281-
# get lnbits pay_id from lightning address if its a lnpayurl
279+
# get lnbits pay_id from lightning address if its a lnpayurl

0 commit comments

Comments
 (0)