diff --git a/proxy_docker/app/script/getactivewatches.sh b/proxy_docker/app/script/getactivewatches.sh index d9dba1b..7b0a0bb 100644 --- a/proxy_docker/app/script/getactivewatches.sh +++ b/proxy_docker/app/script/getactivewatches.sh @@ -4,41 +4,43 @@ . ./sql.sh get_txns_by_watchlabel(){ - trace "Entering get_txns_by_watchlabel()..." + trace "Entering get_txns_by_watchlabel() for label ${1}..." local label_txns - $query=< 0) | . / "|") as $input - | {"label": $input[0], "address": $input[1], "txid": "$input[2], "confirmations": $input[3], "blockheight" : $input[4], "v_out":$input[5], "amount": $input[6]} + | {"label": $input[0], "address": $input[1], "txid": $input[2], "confirmations": $input[3], "blockheight": $input[4], "v_out": $input[5], "amount": $input[6]} ] - }') + } + ') echo "$label_txns_json" return ${returncode} } get_unused_addresses_by_watchlabel(){ - trace "Entering get_unused_addresses_by_watchlabel()... $1" + trace "Entering get_unused_addresses_by_watchlabel() for label ${1}..." local label_unused_addrs query=$(cat <<-HERE SELECT w32.id, w32.label, w32.pub32, w.pub32_index, w.address FROM watching as w INNER JOIN watching_by_pub32 AS w32 ON w.watching_by_pub32_id = w32.id - WHERE w.id NOT IN ( + WHERE w32.label="$1" + AND w.id NOT IN ( SELECT watching_id FROM watching_tx ) - AND w32.label="$1" HERE ) label_unused_addrs=$(sql "$query") @@ -49,7 +51,7 @@ HERE [inputs | . / "\n" | (.[] | select(length > 0) | . / "|") as $input - | {"pub32_watch_id": $input[0], "pub32_label": $input[1], "pub32" : $input[2], "address_pub32_index": $input[3], "address": $input[4] + | {"pub32_watch_id": $input[0], "pub32_label": $input[1], "pub32" : $input[2], "address_pub32_index": $input[3], "address": $input[4]} ] } ')