From 4c38132c38b7c2ed65751c3bbda5b339558dd24f Mon Sep 17 00:00:00 2001 From: kexkey Date: Fri, 10 Sep 2021 02:08:23 -0400 Subject: [PATCH] Added ln_paystatus --- .../templates/gatekeeper/api.properties | 1 + proxy_docker/app/script/call_lightningd.sh | 17 +++++++++++++++++ proxy_docker/app/script/requesthandler.sh | 17 +++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/cyphernodeconf_docker/templates/gatekeeper/api.properties b/cyphernodeconf_docker/templates/gatekeeper/api.properties index ad1f652..35b0ac4 100644 --- a/cyphernodeconf_docker/templates/gatekeeper/api.properties +++ b/cyphernodeconf_docker/templates/gatekeeper/api.properties @@ -37,6 +37,7 @@ action_ln_decodebolt11=watcher action_ln_listpeers=watcher action_ln_getroute=watcher action_ln_listpays=watcher +action_ln_paystatus=watcher action_bitcoin_estimatesmartfee=watcher # Spender can do what the watcher can do, plus: diff --git a/proxy_docker/app/script/call_lightningd.sh b/proxy_docker/app/script/call_lightningd.sh index 624f287..45adc06 100644 --- a/proxy_docker/app/script/call_lightningd.sh +++ b/proxy_docker/app/script/call_lightningd.sh @@ -472,6 +472,23 @@ ln_listpays() { return ${returncode} } +ln_paystatus() { + trace "Entering ln_paystatus()..." + + local result + local bolt11=${1} + trace "[ln_paystatus] bolt11=${bolt11}" + + result=$(./lightning-cli paystatus ${bolt11}) + returncode=$? + trace_rc ${returncode} + trace "[ln_paystatus] result=${result}" + + echo "${result}" + + return ${returncode} +} + ln_newaddr() { trace "Entering ln_newaddr()..." diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index eea3ffc..4119580 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -661,6 +661,23 @@ main() { response_to_client "${response}" ${?} break ;; + ln_paystatus) + # GET http://192.168.111.152:8080/ln_paystatus + # POST http://192.168.111.152:8080/ln_paystatus + # BODY {"bolt11":"lntb1pdca82tpp5gv8mn5jqlj6xztpnt4r472zcyrwf3y2c3cvm4uzg2gqcnj90f83qdp2gf5hgcm0d9hzqnm4w3kx2apqdaexgetjyq3nwvpcxgcqp2g3d86wwdfvyxcz7kce7d3n26d2rw3wf5tzpm2m5fl2z3mm8msa3xk8nv2y32gmzlhwjved980mcmkgq83u9wafq9n4w28amnmwzujgqpmapcr3"} + # BODY {} + + # Let's make it work even for a GET request (equivalent to a POST with empty json object body) + if [ "$http_method" = "POST" ]; then + bolt11=$(echo "${line}" | jq -r ".bolt11 // empty") + else + bolt11= + fi + + response=$(ln_paystatus "${bolt11}") + response_to_client "${response}" ${?} + break + ;; ln_newaddr) # GET http://192.168.111.152:8080/ln_newaddr