create backwards compatibility for <=v1.0 (#3041)
in v0.12.12, the key is "payment_request" instead of the new "bolt11"
This commit is contained in:
parent
f7b3444be4
commit
d7f0f4da0c
1 changed files with 4 additions and 2 deletions
|
|
@ -87,13 +87,15 @@ class LNbitsWallet(Wallet):
|
|||
r.raise_for_status()
|
||||
data = r.json()
|
||||
|
||||
if r.is_error or "bolt11" not in data:
|
||||
# Backwards compatibility for pre-v1 which used the key "payment_request"
|
||||
payment_str = data.get("bolt11") or data.get("payment_request")
|
||||
if r.is_error or not payment_str:
|
||||
error_message = data["detail"] if "detail" in data else r.text
|
||||
return InvoiceResponse(
|
||||
False, None, None, f"Server error: '{error_message}'"
|
||||
)
|
||||
|
||||
return InvoiceResponse(True, data["checking_id"], data["bolt11"], None)
|
||||
return InvoiceResponse(True, data["checking_id"], payment_str, None)
|
||||
except json.JSONDecodeError:
|
||||
return InvoiceResponse(
|
||||
False, None, None, "Server error: 'invalid json response'"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue