Merge pull request #155 from FrancisPouliot/getbalances

Getbalances
This commit is contained in:
SKP
2020-01-17 21:02:35 +01:00
committed by GitHub
4 changed files with 35 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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()..."