xpubwatch docs and more endpoints

This commit is contained in:
kexkey
2019-03-05 13:59:51 -05:00
committed by kexkey
parent 6787f9cee2
commit d3eba5e881
6 changed files with 186 additions and 2 deletions

View File

@@ -97,3 +97,35 @@ getactivewatchesxpub() {
return ${returncode}
}
getactivexpubwatches() {
trace "Entering getactivexpubwatches()..."
local watches
# Let's build the string directly with sqlite instead of manipulating multiple strings afterwards, it's faster.
# {"id":"${id}","pub32":"${pub32}","label":"${label}","derivation_path":"${derivation_path}","last_imported_n":${last_imported_n},"unconfirmedCallbackURL":"${cb0conf_url}","confirmedCallbackURL":"${cb1conf_url}","watching_since":"${timestamp}"}
watches=$(sql "SELECT '{\"id\":\"' || id || '\",\"pub32\":\"' || pub32 || '\",\"label\":\"' || label || '\",\"derivation_path\":\"' || derivation_path || '\",\"last_imported_n\":' || last_imported_n || ',\"unconfirmedCallbackURL\":\"' || callback0conf || '\",\"confirmedCallbackURL\":\"' || callback1conf || '\",\"watching_since\":\"' || inserted_ts || '\"}' FROM watching_by_pub32 WHERE watching AND NOT calledback1conf")
returncode=$?
trace_rc ${returncode}
local notfirst=false
echo -n "{\"watches\":["
local IFS=$'\n'
for row in ${watches}
do
if ${notfirst}; then
echo ","
else
notfirst=true
fi
trace "[getactivexpubwatches] row=${row}"
echo -n "${row}"
done
echo "]}"
return ${returncode}
}

View File

@@ -124,6 +124,13 @@ main()
response_to_client "${response}" ${?}
break
;;
getactivexpubwatches)
# GET http://192.168.111.152:8080/getactivexpubwatches
response=$(getactivexpubwatches)
response_to_client "${response}" ${?}
break
;;
getactivewatches)
# curl (GET) 192.168.111.152:8080/getactivewatches

View File

@@ -60,7 +60,7 @@ unwatchpub32labelrequest() {
local returncode
trace "[unwatchpub32labelrequest] Unwatch xpub label ${label}"
id=$(sql "SELECT id FROM watching WHERE label='${label}'")
id=$(sql "SELECT id FROM watching_by_pub32 WHERE label='${label}'")
returncode=$?
trace_rc ${returncode}
trace "[unwatchpub32labelrequest] id: ${id}"
@@ -73,7 +73,7 @@ unwatchpub32labelrequest() {
returncode=$?
trace_rc ${returncode}
data="{\"event\":\"unwatchxpubbylabel\",\"pub32\":\"${pub32}\"}"
data="{\"event\":\"unwatchxpubbylabel\",\"label\":\"${label}\"}"
trace "[unwatchpub32labelrequest] responding=${data}"
echo "${data}"