tx_confirmation and newblock events published

This commit is contained in:
kexkey
2019-12-02 11:19:28 -05:00
committed by kexkey
parent 8e3ac5ab2c
commit ebd797871d
2 changed files with 14 additions and 3 deletions

View File

@@ -184,9 +184,8 @@ confirmation() {
if [ -n "${event_message}" ]; then
# 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 \"{\"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}\"}")
trace "[confirmation] mosquitto_pub -h broker -t tx_confirmation -m \"{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_vout_amount},\"confirmations\":${tx_nb_conf},\"event_message\":\"${event_message}\"}\""
response=$(mosquitto_pub -h broker -t tx_confirmation -m "{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_vout_amount},\"confirmations\":${tx_nb_conf},\"event_message\":\"${event_message}\"}")
returncode=$?
trace_rc ${returncode}
fi

View File

@@ -2,6 +2,7 @@
. ./trace.sh
. ./callbacks_txid.sh
. ./blockchainrpc.sh
newblock() {
trace "Entering newblock()..."
@@ -9,5 +10,16 @@ newblock() {
local request=${1}
local blockhash=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
local blockinfo
blockinfo=$(get_block_info ${blockhash})
local blockheight
blockheight=$(echo ${blockinfo} | jq -r ".result.height")
trace "[newblock] mosquitto_pub -h broker -t newblock -m \"{\"blockhash\":\"${blockhash}\",\"blockheight\":\"${blockheight}\"}\""
response=$(mosquitto_pub -h broker -t newblock -m "{\"blockhash\":\"${blockhash}\",\"blockheight\":\"${blockheight}\"}")
returncode=$?
trace_rc ${returncode}
do_callbacks_txid
}