Bug fixes.. unused address test pass

This commit is contained in:
gus-t460
2019-12-05 16:29:39 -05:00
committed by kexkey
parent 24f5b552b4
commit f1f1de3c3a

View File

@@ -6,43 +6,56 @@
get_txns_by_watchlabel(){
trace "Entering get_txns_by_watchlabel()..."
local label_txns
$sql=<<HERE
SELECT w32.label, w.address, tx.txid, tx.confirmations,tx.blockheight, wtxn.v_out, wtxn.amount
FROM watching_by_pub32 as w32
INNER JOIN watching ON w32.id = w.watching_by_pub32_id
INNER JOIN watching_tx as wtxn ON w.id = wtxn.watching_id
INNER JOIN tx as tx ON wtxn.tx_id = tx.id
WHERE w32.label={$1}
$query=<<HERE
SELECT w32.label, w.address, tx.txid, tx.confirmations,tx.blockheight, wtxn.v_out, wtxn.amount
FROM watching_by_pub32 as w32
INNER JOIN watching ON w32.id = w.watching_by_pub32_id
INNER JOIN watching_tx as wtxn ON w.id = wtxn.watching_id
INNER JOIN tx as tx ON wtxn.tx_id = tx.id
WHERE w32.label="$1"
HERE
$label_txns = $(sql "$sql")
$label_txns=$(sql "$query")
returncode=$?
trace_rc ${returncode}
$label_txns_json = jq -Rsn '
$label_txns_json = $(echo "$label_txns" | jq -Rcsn '
{"label_txns":
[inputs
| . / "\n"
| (.[] | select(length > 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_txns)
return $label_txns_json
| {"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()..."
local label_txns
$sql = "SELECT w.watching_by_pub32_id, w.pub32_index, w.address FROM watching as w WHERE w.id NOT IN (SELECT watching_id FROM watching_tx) WHERE w.label=${1}"
$label_txns = $(sql "$sql")
trace "Entering get_unused_addresses_by_watchlabel()... $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 (
SELECT watching_id FROM watching_tx
)
AND w32.label="$1"
HERE
)
label_unused_addrs=$(sql "$query")
returncode=$?
trace_rc ${returncode}
$label_txns_json = jq -Rsn '
label_unused_addrs_json=$(echo "$label_unused_addrs" | jq -Rcsn '
{"label_unused_addresses":
[inputs
| . / "\n"
| (.[] | select(length > 0) | . / "|") as $input
| {"pub32_watch_id": $input[0], "address_pub32_index": $input[1], "address": "$input[2] }]}
' <$($label_txns)
return $label_txns_json
| {"pub32_watch_id": $input[0], "pub32_label": $input[1], "pub32" : $input[2], "address_pub32_index": $input[3], "address": $input[4]
]
}
')
echo "$label_unused_addrs_json"
return ${returncode}
}
getactivewatches() {
trace "Entering getactivewatches()..."