More LN, more robust, more info

This commit is contained in:
kexkey
2019-01-11 18:46:40 -05:00
committed by kexkey
parent 986dfba936
commit f3a3b1e0ff
8 changed files with 139 additions and 60 deletions

View File

@@ -11,13 +11,13 @@ ln_create_invoice()
local request=${1}
local msatoshi=$(echo "${request}" | jq ".msatoshi" | tr -d '"')
trace "[ln_create_invoice] msatoshi=${msatoshi}"
local label=$(echo "${request}" | jq ".label")
local label=$(echo "${request}" | jq ".label" | tr -d '"')
trace "[ln_create_invoice] label=${label}"
local description=$(echo "${request}" | jq ".description")
local description=$(echo "${request}" | jq ".description" | tr -d '"')
trace "[ln_create_invoice] description=${description}"
local expiry=$(echo "${request}" | jq ".expiry" | tr -d '"')
trace "[ln_create_invoice] expiry=${expiry}"
local callback_url=$(echo "${request}" | jq ".callback_url" | tr -d '"')
local callback_url=$(echo "${request}" | jq ".callbackUrl" | tr -d '"')
trace "[ln_create_invoice] callback_url=${callback_url}"
#/proxy $ ./lightning-cli invoice 10000 "t1" "t1d" 60
@@ -27,15 +27,20 @@ ln_create_invoice()
# "bolt11": "lnbc100n1pwzllqgpp55a8xen9sdcntehwr93pkwnuu8nmtqx9yew0flalcxhx9nvy34crqdq9wsckgxqzpucqp2rzjqt04ll5ft3mcuy8hws4xcku2pnhma9r9mavtjtadawyrw5kgzp7g7zr745qq3mcqqyqqqqlgqqqqqzsqpcr85k33shzaxscpj29fadmjmfej6y2p380x9w4kxydqpxq87l6lshy69fry9q2yrtu037nt44x77uhzkdyn8043n5yj8tqgluvmcl69cquaxr68"
#}
trace "[ln_create_invoice] ./lightning-cli invoice ${msatoshi} \"${label}\" \${description}\" ${expiry}"
result=$(./lightning-cli invoice ${msatoshi} "${label}" "${description}" ${expiry})
returncode=$?
trace_rc ${returncode}
trace "[ln_create_invoice] result=${result}"
local bolt11
bolt11=$(echo ${result} | jq ".bolt11" | tr -d '"')
local bolt11=$(echo ${result} | jq ".bolt11" | tr -d '"')
trace "[ln_create_invoice] bolt11=${bolt11}"
sql "INSERT OR IGNORE INTO ln_invoice (bolt11, callback_url) VALUES (\"${bolt11}\", \"${callback_url}\")"
local payment_hash=$(echo ${result} | jq ".payment_hash" | tr -d '"')
trace "[ln_create_invoice] payment_hash=${payment_hash}"
local expires_at=$(echo ${result} | jq ".expires_at" | tr -d '"')
trace "[ln_create_invoice] expires_at=${expires_at}"
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\")"
trace_rc $?
echo "${result}"
@@ -75,6 +80,22 @@ ln_getinvoice() {
return ${returncode}
}
ln_delinvoice() {
trace "Entering ln_delinvoice()..."
local label=${1}
local result
result=$(./lightning-cli delinvoice ${label} "unpaid")
returncode=$?
trace_rc ${returncode}
trace "[ln_delinvoice] result=${result}"
echo "${result}"
return ${returncode}
}
ln_decodebolt11() {
trace "Entering ln_decodebolt11()..."