diff --git a/api_auth_docker/api-sample.properties b/api_auth_docker/api-sample.properties index c99cccd..7e31558 100644 --- a/api_auth_docker/api-sample.properties +++ b/api_auth_docker/api-sample.properties @@ -16,6 +16,8 @@ action_getblockinfo=watcher action_gettransaction=watcher action_ln_getinfo=watcher action_ln_create_invoice=watcher +action_ln_getconnectionstring=watcher +action_ln_decodebolt11=watcher # Spender can do what the watcher can do, plus: action_getbalance=spender @@ -32,7 +34,6 @@ action_ln_newaddr=spender action_ots_stamp=spender action_ots_getfile=spender action_ln_getinvoice=spender -action_ln_decodebolt11=spender # Admin can do what the spender can do, plus: diff --git a/install/generator-cyphernode/generators/app/index.js b/install/generator-cyphernode/generators/app/index.js index 18f472a..7e31027 100644 --- a/install/generator-cyphernode/generators/app/index.js +++ b/install/generator-cyphernode/generators/app/index.js @@ -39,6 +39,8 @@ action_getblockinfo=watcher action_gettransaction=watcher action_ln_getinfo=watcher action_ln_create_invoice=watcher +action_ln_getconnectionstring=watcher +action_ln_decodebolt11=watcher # Spender can do what the watcher can do, plus: action_getbalance=spender diff --git a/proxy_docker/app/script/call_lightningd.sh b/proxy_docker/app/script/call_lightningd.sh index a3ed549..8546b6c 100644 --- a/proxy_docker/app/script/call_lightningd.sh +++ b/proxy_docker/app/script/call_lightningd.sh @@ -46,15 +46,7 @@ ln_create_invoice() trace "[ln_create_invoice] expires_at=${expires_at}" # Let's get the connect string if provided in configuration - local connectstring - local getinfo=$(ln_getinfo) - trace "[ln_create_invoice] getinfo=${getinfo}" - echo ${getinfo} | jq -e '.address[0]' > /dev/null - if [ "$?" -eq 0 ]; then - # If there's an address - connectstring="$(echo ${getinfo} | jq '((.id + "@") + (.address[0] | ((.address + ":") + (.port | tostring))))' | tr -d '"')" - trace "[ln_create_invoice] connectstring=${connectstring}" - fi + local connectstring=$(ln_get_connection_string) 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 $? @@ -81,6 +73,22 @@ ln_create_invoice() return ${returncode} } +ln_get_connection_string() { + trace "Entering ln_get_connection_string()..." + + # Let's get the connect string if provided in configuration + local connectstring + local getinfo=$(ln_getinfo) + echo ${getinfo} | jq -e '.address[0]' > /dev/null + if [ "$?" -eq 0 ]; then + # If there's an address + connectstring="$(echo ${getinfo} | jq '((.id + "@") + (.address[0] | ((.address + ":") + (.port | tostring))))' | tr -d '"')" + trace "[ln_get_connection_string] connectstring=${connectstring}" + fi + + echo "${connectstring}" +} + ln_getinfo() { trace "Entering ln_get_info()..." diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index 74d30b7..ebe3058 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -258,6 +258,13 @@ main() response_to_client "${response}" ${?} break ;; + ln_getconnectionstring) + # GET http://192.168.111.152:8080/ln_getconnectionstring + + response=$(ln_get_connection_string) + response_to_client "${response}" ${?} + break + ;; ln_create_invoice) # POST http://192.168.111.152:8080/ln_create_invoice # BODY {"msatoshi":"10000","label":"koNCcrSvhX3dmyFhW","description":"Bylls order #10649","expiry":"900","callback_url":"http://192.168.122.159"}