Now expecting event_message in base64 and some fixes

This commit is contained in:
kexkey
2019-11-28 15:56:12 -05:00
committed by kexkey
parent ed40433b28
commit 1ae5bf1dc0
4 changed files with 26 additions and 9 deletions

View File

@@ -62,6 +62,8 @@ ln_manage_callback() {
local row=$@ local row=$@
trace "[ln_manage_callback] row=${row}" trace "[ln_manage_callback] row=${row}"
local id=$(echo "${row}" | cut -d '|' -f1)
trace "[ln_manage_callback] id=${id}"
local callback_url=$(echo "${row}" | cut -d '|' -f4) local callback_url=$(echo "${row}" | cut -d '|' -f4)
trace "[ln_manage_callback] callback_url=${callback_url}" trace "[ln_manage_callback] callback_url=${callback_url}"
@@ -73,8 +75,6 @@ ln_manage_callback() {
return return
fi fi
local id=$(echo "${row}" | cut -d '|' -f1)
trace "[ln_manage_callback] id=${id}"
local label=$(echo "${row}" | cut -d '|' -f2) local label=$(echo "${row}" | cut -d '|' -f2)
trace "[ln_manage_callback] label=${label}" trace "[ln_manage_callback] label=${label}"
local bolt11=$(echo "${row}" | cut -d '|' -f3) local bolt11=$(echo "${row}" | cut -d '|' -f3)

View File

@@ -189,7 +189,6 @@ confirmation() {
response=$(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}\"}")
returncode=$? returncode=$?
trace_rc ${returncode} trace_rc ${returncode}
fi fi
######################################################################################################## ########################################################################################################

View File

@@ -89,7 +89,7 @@ main() {
watch) watch)
# POST http://192.168.111.152:8080/watch # POST http://192.168.111.152:8080/watch
# BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","unconfirmedCallbackURL":"192.168.111.233:1111/callback0conf","confirmedCallbackURL":"192.168.111.233:1111/callback1conf"} # BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","unconfirmedCallbackURL":"192.168.111.233:1111/callback0conf","confirmedCallbackURL":"192.168.111.233:1111/callback1conf"}
# BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","confirmedCallbackURL":"192.168.111.233:1111/callback1conf","eventMessage":"{\"bounce_address}\":\"tb1q6s0ppwk2msdewal3mu90ahfhpyepawnw6wdk8t\",\"nb_conf\":6}"} # BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","confirmedCallbackURL":"192.168.111.233:1111/callback1conf","eventMessage":"eyJib3VuY2VfYWRkcmVzcyI6InRiMXE2czBwcHdrMm1zZGV3YWwzbXU5MGFoZmhweWVwYXdudzZ3ZGs4dCIsIm5iX2NvbmYiOjZ9Cg=="}
response=$(watchrequest "${line}") response=$(watchrequest "${line}")
response_to_client "${response}" ${?} response_to_client "${response}" ${?}

View File

@@ -11,10 +11,28 @@ watchrequest() {
local returncode local returncode
local request=${1} local request=${1}
local address=$(echo "${request}" | jq -r ".address") local address=$(echo "${request}" | jq -er ".address")
local cb0conf_url=$(echo "${request}" | jq -r ".unconfirmedCallbackURL") local cb0conf_url
local cb1conf_url=$(echo "${request}" | jq -r ".confirmedCallbackURL") cb0conf_url=$(echo "${request}" | jq -er ".unconfirmedCallbackURL")
local event_message=$(echo "${request}" | jq -r ".event_message") if [ "$?" -ne "0" ]; then
# unconfirmedCallbackURL tag null, so there's no unconfirmedCallbackURL
trace "[watchrequest] unconfirmedCallbackURL="
unconfirmedCallbackURL=
fi
local cb1conf_url
cb1conf_url=$(echo "${request}" | jq -er ".confirmedCallbackURL")
if [ "$?" -ne "0" ]; then
# confirmedCallbackURL tag null, so there's no confirmedCallbackURL
trace "[watchrequest] confirmedCallbackURL="
confirmedCallbackURL=
fi
local event_message
event_message=$(echo "${request}" | jq -er ".eventMessage")
if [ "$?" -ne "0" ]; then
# event_message tag null, so there's no event_message
trace "[watchrequest] event_message="
event_message=
fi
local imported local imported
local inserted local inserted
local id_inserted local id_inserted