diff --git a/doc/API.v0.md b/doc/API.v0.md index ef937b0..c9e10c5 100644 --- a/doc/API.v0.md +++ b/doc/API.v0.md @@ -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 diff --git a/proxy_docker/app/script/unwatchrequest.sh b/proxy_docker/app/script/unwatchrequest.sh index ad9784d..ac14493 100644 --- a/proxy_docker/app/script/unwatchrequest.sh +++ b/proxy_docker/app/script/unwatchrequest.sh @@ -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}