diff --git a/api_auth_docker/api-sample.properties b/api_auth_docker/api-sample.properties index 95e3596..ca878a8 100644 --- a/api_auth_docker/api-sample.properties +++ b/api_auth_docker/api-sample.properties @@ -32,6 +32,7 @@ action_ln_decodebolt11=watcher # Spender can do what the watcher can do, plus: action_getxnslist=spender action_getbalance=spender +action_getbalances=spender action_getbalancebyxpub=spender action_getbalancebyxpublabel=spender action_getnewaddress=spender diff --git a/cyphernodeconf_docker/templates/gatekeeper/api.properties b/cyphernodeconf_docker/templates/gatekeeper/api.properties index 0a85497..e4e9871 100644 --- a/cyphernodeconf_docker/templates/gatekeeper/api.properties +++ b/cyphernodeconf_docker/templates/gatekeeper/api.properties @@ -37,6 +37,7 @@ action_ln_decodebolt11=watcher # Spender can do what the watcher can do, plus: action_get_txns_spending=spender action_getbalance=spender +action_getbalances=spender action_getbalancebyxpub=spender action_getbalancebyxpublabel=spender action_getnewaddress=spender diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index 4478a87..e60a505 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -252,6 +252,13 @@ main() { response_to_client "${response}" ${?} break ;; + getbalances) + # curl (GET) http://192.168.111.152:8080/getbalances + + response=$(getbalances) + response_to_client "${response}" ${?} + break + ;; getbalancebyxpub) # curl (GET) http://192.168.111.152:8080/getbalancebyxpub/upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb diff --git a/proxy_docker/app/script/walletoperations.sh b/proxy_docker/app/script/walletoperations.sh index be5a594..b067bf4 100644 --- a/proxy_docker/app/script/walletoperations.sh +++ b/proxy_docker/app/script/walletoperations.sh @@ -175,6 +175,32 @@ getbalance() { return ${returncode} } +getbalances() { + trace "Entering getbalances()..." + + local response + local data='{"method":"getbalances"}' + response=$(send_to_spender_node "${data}") + local returncode=$? + trace_rc ${returncode} + trace "[getbalances] response=${response}" + + if [ "${returncode}" -eq 0 ]; then + local balances=$(echo ${response} | jq ".result") + trace "[getbalances] balances=${balances}" + + data="{\"balances\":${balances}}" + else + trace "[getbalances] Couldn't get balances!" + data="" + fi + + trace "[getbalances] responding=${data}" + echo "${data}" + + return ${returncode} +} + getbalancebyxpublabel() { trace "Entering getbalancebyxpublabel()..."