mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 13:14:56 +01:00
Add bonus gettxnslist/count/skip endpoint for spender wallet :)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user