Add bonus gettxnslist/count/skip endpoint for spender wallet :)

This commit is contained in:
g-homebase
2019-12-13 12:13:18 -05:00
committed by kexkey
parent e8306f8a8a
commit 29704c20e5
5 changed files with 36 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ action_ln_getconnectionstring=watcher
action_ln_decodebolt11=watcher
# Spender can do what the watcher can do, plus:
action_getxnslist=spender
action_getbalance=spender
action_getbalancebyxpub=spender
action_getbalancebyxpublabel=spender

View File

@@ -35,6 +35,7 @@ action_ln_getconnectionstring=watcher
action_ln_decodebolt11=watcher
# Spender can do what the watcher can do, plus:
action_gettxnslist=spender
action_getbalance=spender
action_getbalancebyxpub=spender
action_getbalancebyxpublabel=spender

View File

@@ -31,7 +31,7 @@ confirmation() {
local txid=${1}
local tx_details
# We need make sure to discard error results generated by get_transction tryin to find a watching wallet's `txn in
# spender wallet first,return code will tell if there's an actaul error. FIXME Add issue here
# spender wallet first,return code will tell if there's an actaul error. See #153
tx_details=$(get_transaction ${txid} | jq '. | select(.result != null)')
returncode=$?
trace_rc ${returncode}

View File

@@ -238,6 +238,13 @@ main() {
response_to_client "${response}" ${?}
break
;;
gettxnslist)
# curl (GET) http://192.168.111.152:8080/gettxnslist/20/10
response=$(gettxnslist $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3) $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f4))
response_to_client "${response}" ${?}
break
;;
getbalance)
# curl (GET) http://192.168.111.152:8080/getbalance

View File

@@ -123,6 +123,32 @@ bumpfee() {
return ${returncode}
}
gettxnslist() {
trace "Entering gettxnslist()... with count: $1 , skip: $2"
local count="$1"
local skip="$2"
local response
local data="{\"method\":\"listtransactions\",\"params\":[\"*\",${count:-10},${skip:-0}]}"
response=$(send_to_spender_node "${data}")
local returncode=$?
trace_rc ${returncode}
trace "[gettxnlist] response=${response}"
if [ "${returncode}" -eq 0 ]; then
local txns=$(echo ${response} | jq -rc ".result")
trace "[gettxnlist] txns=${txns}"
data="{\"txns\":${txns}}"
else
trace "[gettxnlist] Coudn't get txns!"
data=""
fi
trace "[gettransactions] responding=${data}"
echo "${data}"
return ${returncode}
}
getbalance() {
trace "Entering getbalance()..."