unwatch wasn't unwatching when webhooks not supplied

This commit is contained in:
kexkey
2020-11-24 01:10:13 -05:00
parent 0b1fd6e0d7
commit fe3471b3c6
2 changed files with 12 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ Proxy response:
### Un-watch a previously watched Bitcoin Address (called by your application)
Updates the watched address row in DB so that webhooks won't be called on tx confirmations for that address. You can POST the URLs to make sure you unwatch the good watcher, since there may be multiple watchers on the same address with different webhook URLs. You can also, more conveniently, supply the watch id to unwatch.
Updates the watched address row in DB so that webhooks won't be called on tx confirmations for that address. You can POST the URLs to make sure you unwatch the good watcher, since there may be multiple watchers on the same address with different webhook URLs. If you don't supply URLs and there are several watchers on the same address for different URLs, all watchers will be turned off for that address. You can also, more conveniently, supply the watch id to unwatch.
```http
GET http://cyphernode:8888/unwatch/2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp

View File

@@ -20,7 +20,17 @@ unwatchrequest() {
data="{\"event\":\"unwatch\",\"id\":${watchid}}"
else
sql "UPDATE watching SET watching=0 WHERE address='${address}' AND callback0conf=${unconfirmedCallbackURL} AND callback1conf=${confirmedCallbackURL}"
local cb0_where=
local cb1_where=
if [ "${unconfirmedCallbackURL}" != "null" ]; then
cb0_where=" AND callback0conf='${unconfirmedCallbackURL}'"
fi
if [ "${confirmedCallbackURL}" != "null" ]; then
cb1_where=" AND callback1conf='${confirmedCallbackURL}'"
fi
sql "UPDATE watching SET watching=0 WHERE address='${address}'${cb0_where}${cb1_where}"
returncode=$?
trace_rc ${returncode}