Skip to content

Commit

Permalink
revert merge error
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Aug 1, 2022
1 parent 1ce2fad commit b76231f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lnbits/wallets/cln.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,24 @@ async def create_invoice(
label = "lbl{}".format(random.random())
msat = amount * 1000
try:
if description_hash:
if not self.supports_description_hash:
raise Unsupported("description_hash")

params = [msat, label, hashlib.sha256(description_hash).hexdigest()]
r = self.ln.call("invoicewithdescriptionhash", params)
return InvoiceResponse(True, label, r["bolt11"], "")
else:
r = self.ln.invoice(msat, label, memo, exposeprivatechannels=True)
return InvoiceResponse(True, label, r["bolt11"], "")
if description_hash and not self.supports_description_hash:
raise Unsupported("description_hash")
r = self.ln.invoice(
msatoshi=msat,
label=label,
description=description_hash.decode("utf-8")
if description_hash
else memo,
exposeprivatechannels=True,
deschashonly=True
if description_hash
else False, # we can't pass None here
)

if r.get("code") and r.get("code") < 0:
raise Exception(r.get("message"))

return InvoiceResponse(True, r["payment_hash"], r["bolt11"], "")
except RpcError as exc:
error_message = f"lightningd '{exc.method}' failed with '{exc.error}'."
logger.error("RPC error:", error_message)
Expand Down

0 comments on commit b76231f

Please sign in to comment.