mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-01-31 10:14:35 +01:00
callbackUrl now optional on ln_create_invoice
This commit is contained in:
@@ -786,12 +786,12 @@ Proxy response:
|
||||
|
||||
### Create a Lightning Network invoice (called by application)
|
||||
|
||||
Returns a LN invoice. Label must be unique. Description will be used by your user for payment. Expiry is in seconds. If msatoshi is not supplied, will use "any" (ie donation invoice).
|
||||
Returns a LN invoice. Label must be unique. Description will be used by your user for payment. Expiry is in seconds. If msatoshi is not supplied, will use "any" (ie donation invoice). callbackUrl is optional.
|
||||
|
||||
```http
|
||||
POST http://cyphernode:8888/ln_create_invoice
|
||||
with body...
|
||||
{"msatoshi":10000,"label":"koNCcrSvhX3dmyFhW","description":"Bylls order #10649","expiry":900}
|
||||
{"msatoshi":10000,"label":"koNCcrSvhX3dmyFhW","description":"Bylls order #10649","expiry":900,"callbackUrl":"https://thesite/lnwebhook/9d8sa98yd"}
|
||||
or
|
||||
{"label":"koNCcrSvhX3dmyFhW","description":"Bylls order #10649","expiry":900}
|
||||
```
|
||||
|
||||
@@ -1399,6 +1399,9 @@ paths:
|
||||
type: "string"
|
||||
expiry:
|
||||
type: "integer"
|
||||
callbackUrl:
|
||||
type: "string"
|
||||
format: "url"
|
||||
responses:
|
||||
'200':
|
||||
description: "successful operation"
|
||||
|
||||
@@ -20,6 +20,11 @@ ln_create_invoice() {
|
||||
trace "[ln_create_invoice] expiry=${expiry}"
|
||||
local callback_url=$(echo "${request}" | jq -r ".callbackUrl")
|
||||
trace "[ln_create_invoice] callback_url=${callback_url}"
|
||||
if [ "${callback_url}" != "null" ]; then
|
||||
# If not null, let's add double-quotes so we don't need to add the double-quotes in the sql insert,
|
||||
# so if it's null, it will insert the actual sql NULL value.
|
||||
callback_url="\"${callback_url}\""
|
||||
fi
|
||||
|
||||
#/proxy $ ./lightning-cli invoice 10000 "t1" "t1d" 60
|
||||
#{
|
||||
@@ -53,9 +58,9 @@ ln_create_invoice() {
|
||||
local connectstring=$(get_connection_string)
|
||||
|
||||
if [ "${msatoshi}" = "null" ]; then
|
||||
sql "INSERT OR IGNORE INTO ln_invoice (label, bolt11, callback_url, payment_hash, expires_at, description, status) VALUES (\"${label}\", \"${bolt11}\", \"${callback_url}\", \"${payment_hash}\", ${expires_at}, \"${description}\", \"unpaid\")"
|
||||
sql "INSERT OR IGNORE INTO ln_invoice (label, bolt11, callback_url, payment_hash, expires_at, description, status) VALUES (\"${label}\", \"${bolt11}\", ${callback_url}, \"${payment_hash}\", ${expires_at}, \"${description}\", \"unpaid\")"
|
||||
else
|
||||
sql "INSERT OR IGNORE INTO ln_invoice (label, bolt11, callback_url, payment_hash, expires_at, msatoshi, description, status) VALUES (\"${label}\", \"${bolt11}\", \"${callback_url}\", \"${payment_hash}\", ${expires_at}, ${msatoshi}, \"${description}\", \"unpaid\")"
|
||||
sql "INSERT OR IGNORE INTO ln_invoice (label, bolt11, callback_url, payment_hash, expires_at, msatoshi, description, status) VALUES (\"${label}\", \"${bolt11}\", ${callback_url}, \"${payment_hash}\", ${expires_at}, ${msatoshi}, \"${description}\", \"unpaid\")"
|
||||
fi
|
||||
trace_rc $?
|
||||
id=$(sql "SELECT id FROM ln_invoice WHERE bolt11=\"${bolt11}\"")
|
||||
@@ -67,7 +72,9 @@ ln_create_invoice() {
|
||||
if [ -n "${connectstring}" ]; then
|
||||
data="${data}\"connectstring\":\"${connectstring}\","
|
||||
fi
|
||||
data="${data}\"callback_url\":\"${callback_url}\","
|
||||
if [ "${callback_url}" != "null" ]; then
|
||||
data="${data}\"callback_url\":${callback_url},"
|
||||
fi
|
||||
data="${data}\"payment_hash\":\"${payment_hash}\","
|
||||
if [ "${msatoshi}" != "null" ]; then
|
||||
data="${data}\"msatoshi\":${msatoshi},"
|
||||
|
||||
@@ -43,7 +43,7 @@ ln_waitanyinvoice() {
|
||||
paid_at=$(echo "${result}" | jq -r ".paid_at")
|
||||
|
||||
sql "UPDATE ln_invoice SET status=\"${status}\", pay_index=${pay_index}, msatoshi_received=${msatoshi_received}, paid_at=${paid_at} WHERE bolt11=\"${bolt11}\""
|
||||
row=$(sql "SELECT id, label, bolt11, callback_url, payment_hash, msatoshi, status, pay_index, msatoshi_received, paid_at, description, expires_at FROM ln_invoice WHERE NOT calledback AND bolt11=\"${bolt11}\"")
|
||||
row=$(sql "SELECT id, label, bolt11, callback_url, payment_hash, msatoshi, status, pay_index, msatoshi_received, paid_at, description, expires_at FROM ln_invoice WHERE callback_url<>\"\" AND NOT calledback AND bolt11=\"${bolt11}\"")
|
||||
|
||||
if [ -n "${row}" ]; then
|
||||
ln_manage_callback ${row}
|
||||
|
||||
Reference in New Issue
Block a user