Added some data to confirmation event

This commit is contained in:
kexkey
2019-11-28 20:56:30 -05:00
committed by kexkey
parent 1ae5bf1dc0
commit 8e3ac5ab2c

View File

@@ -149,6 +149,7 @@ confirmation() {
address=$(echo "${row}" | cut -d '|' -f2)
########################################################################################################
# Let's now insert in the join table if not already done
tx_vout_amount=$(echo "${tx_details}" | jq ".result.details | map(select(.address==\"${address}\"))[0] | .amount | fabs" | awk '{ printf "%.8f", $0 }')
if [ -z "${tx}" ]; then
trace "[confirmation] For this tx, there's no watching_tx row, let's create it"
local watching_id
@@ -159,7 +160,6 @@ confirmation() {
# In the case of us spending to a watched address, the address appears twice in the details,
# once on the spend side (negative amount) and once on the receiving side (positive amount)
tx_vout_n=$(echo "${tx_details}" | jq ".result.details | map(select(.address==\"${address}\"))[0] | .vout")
tx_vout_amount=$(echo "${tx_details}" | jq ".result.details | map(select(.address==\"${address}\"))[0] | .amount | fabs" | awk '{ printf "%.8f", $0 }')
sql "INSERT OR IGNORE INTO watching_tx (watching_id, tx_id, vout, amount) VALUES (${watching_id}, ${id_inserted}, ${tx_vout_n}, ${tx_vout_amount})"
trace_rc $?
else
@@ -185,8 +185,8 @@ confirmation() {
# There's an event message, let's publish it!
# We use the pid as the response-topic, so there's no conflict in responses.
trace "[confirmation] mosquitto_pub -h broker -t conf_event -m \"{\"address\":\"${address}\",\"confirmations\":${tx_nb_conf},\"event_message\":\"${event_message}\"}\""
response=$(mosquitto_pub -h broker -t conf_event -m "{\"address\":\"${address}\",\"confirmations\":${tx_nb_conf},\"event_message\":\"${event_message}\"}")
trace "[confirmation] mosquitto_pub -h broker -t conf_event -m \"{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_vout_amount},\"confirmations\":${tx_nb_conf},\"event_message\":\"${event_message}\"}\""
response=$(mosquitto_pub -h broker -t conf_event -m "{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_vout_amount},\"confirmations\":${tx_nb_conf},\"event_message\":\"${event_message}\"}")
returncode=$?
trace_rc ${returncode}
fi