From b6ba329e7566a9b941b66adf9bac4c81070c6939 Mon Sep 17 00:00:00 2001 From: kexkey Date: Tue, 3 Dec 2019 12:19:59 -0500 Subject: [PATCH] Doc eventMessage on spend, eventMessage name in JSON instead of event_message --- doc/API.v0.md | 10 ++++++---- doc/openapi/v0/cyphernode-api.yaml | 3 +++ proxy_docker/app/script/callbacks_job.sh | 2 +- proxy_docker/app/script/confirmation.sh | 4 ++-- proxy_docker/app/script/walletoperations.sh | 4 ++-- proxy_docker/app/script/watchrequest.sh | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/API.v0.md b/doc/API.v0.md index ff8633a..95ea650 100644 --- a/doc/API.v0.md +++ b/doc/API.v0.md @@ -9,7 +9,7 @@ Inserts the address and callbacks in the DB and imports the address to the Watch ```http POST http://cyphernode:8888/watch with body... -{"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","unconfirmedCallbackURL":"192.168.111.233:1111/callback0conf","confirmedCallbackURL":"192.168.111.233:1111/callback1conf","eventMessage":"eyJib3VuY2VfYWRkcmVzcyI6InRiMXE2czBwcHdrMm1zZGV3YWwzbXU5MGFoZmhweWVwYXdudzZ3ZGs4dCIsIm5iX2NvbmYiOjZ9Cg=="} +{"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","unconfirmedCallbackURL":"192.168.111.233:1111/callback0conf","confirmedCallbackURL":"192.168.111.233:1111/callback1conf","eventMessage":"eyJib3VuY2VfYWRkcmVzcyI6IjJNdkEzeHIzOHIxNXRRZWhGblBKMVhBdXJDUFR2ZTZOamNGIiwibmJfY29uZiI6MH0K"} ``` Proxy response: @@ -27,7 +27,7 @@ Proxy response: "estimatesmartfee6blocks": "0.000010", "estimatesmartfee36blocks": "0.000010", "estimatesmartfee144blocks": "0.000010", - "eventMessage": "eyJib3VuY2VfYWRkcmVzcyI6InRiMXE2czBwcHdrMm1zZGV3YWwzbXU5MGFoZmhweWVwYXdudzZ3ZGs4dCIsIm5iX2NvbmYiOjZ9Cg==" + "eventMessage": "eyJib3VuY2VfYWRkcmVzcyI6IjJNdkEzeHIzOHIxNXRRZWhGblBKMVhBdXJDUFR2ZTZOamNGIiwibmJfY29uZiI6MH0K" } ``` @@ -68,7 +68,7 @@ Proxy response: "unconfirmedCallbackURL":"192.168.133.233:1111/callback0conf", "confirmedCallbackURL":"192.168.133.233:1111/callback1conf", "watching_since":"2018-09-06 21:14:03", - "eventMessage":"eyJib3VuY2VfYWRkcmVzcyI6InRiMXE2czBwcHdrMm1zZGV3YWwzbXU5MGFoZmhweWVwYXdudzZ3ZGs4dCIsIm5iX2NvbmYiOjZ9Cg=="} + "eventMessage":"eyJib3VuY2VfYWRkcmVzcyI6IjJNdkEzeHIzOHIxNXRRZWhGblBKMVhBdXJDUFR2ZTZOamNGIiwibmJfY29uZiI6MH0K"} ] } ``` @@ -621,12 +621,14 @@ Proxy response: ### Spend coins from spending wallet (called by application) -Calls sendtoaddress RPC on the spending wallet with supplied info. +Calls sendtoaddress RPC on the spending wallet with supplied info. Can supply an eventMessage to be published on successful spending. eventMessage should be base64 encoded to avoid dealing with escaping special characters. ```http POST http://cyphernode:8888/spend with body... {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","amount":0.00233} +or +{"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","amount":0.00233,"eventMessage":"eyJib3VuY2VfYWRkcmVzcyI6IjJNdkEzeHIzOHIxNXRRZWhGblBKMVhBdXJDUFR2ZTZOamNGIiwibmJfY29uZiI6MH0K"} ``` Proxy response: diff --git a/doc/openapi/v0/cyphernode-api.yaml b/doc/openapi/v0/cyphernode-api.yaml index 91b9c52..b7d7997 100644 --- a/doc/openapi/v0/cyphernode-api.yaml +++ b/doc/openapi/v0/cyphernode-api.yaml @@ -797,6 +797,9 @@ paths: $ref: '#/components/schemas/TypeAddressString' amount: type: "number" + eventMessage: + description: "Will be part of the published message on spend" + type: "string" responses: '200': description: "operation successful" diff --git a/proxy_docker/app/script/callbacks_job.sh b/proxy_docker/app/script/callbacks_job.sh index 27a2b30..62ff7a4 100644 --- a/proxy_docker/app/script/callbacks_job.sh +++ b/proxy_docker/app/script/callbacks_job.sh @@ -237,7 +237,7 @@ build_callback() { derivation_path=$(echo -e $derivation_path | sed -En "s/n/${pub32_index}/p") data="${data}\"pub32_derivation_path\":\"${derivation_path}\"," fi - data="${data}\"event_message\":\"${event_message}\"}" + data="${data}\"eventMessage\":\"${event_message}\"}" trace "[build_callback] data=${data}" curl_callback "${url}" "${data}" diff --git a/proxy_docker/app/script/confirmation.sh b/proxy_docker/app/script/confirmation.sh index 17b54b4..3fbfd8a 100644 --- a/proxy_docker/app/script/confirmation.sh +++ b/proxy_docker/app/script/confirmation.sh @@ -185,8 +185,8 @@ confirmation() { if [ -n "${event_message}" ]; then # There's an event message, let's publish it! - trace "[confirmation] mosquitto_pub -h broker -t tx_confirmation -m \"{\"txid\":\"${txid}\",\"address\":\"${address}\",\"vout_n\":${tx_vout_n},\"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}\",\"vout_n\":${tx_vout_n},\"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}\",\"vout_n\":${tx_vout_n},\"amount\":${tx_vout_amount},\"confirmations\":${tx_nb_conf},\"eventMessage\":\"${event_message}\"}\"" + response=$(mosquitto_pub -h broker -t tx_confirmation -m "{\"txid\":\"${txid}\",\"address\":\"${address}\",\"vout_n\":${tx_vout_n},\"amount\":${tx_vout_amount},\"confirmations\":${tx_nb_conf},\"eventMessage\":\"${event_message}\"}") returncode=$? trace_rc ${returncode} fi diff --git a/proxy_docker/app/script/walletoperations.sh b/proxy_docker/app/script/walletoperations.sh index f1ed68f..404a7b8 100644 --- a/proxy_docker/app/script/walletoperations.sh +++ b/proxy_docker/app/script/walletoperations.sh @@ -54,8 +54,8 @@ spend() { else # There's an event message, let's publish it! - trace "[spend] mosquitto_pub -h broker -t spend -m \"{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_amount},\"event_message\":\"${event_message}\"}\"" - response=$(mosquitto_pub -h broker -t spend -m "{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_amount},\"event_message\":\"${event_message}\"}") + trace "[spend] mosquitto_pub -h broker -t spend -m \"{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_amount},\"eventMessage\":\"${event_message}\"}\"" + response=$(mosquitto_pub -h broker -t spend -m "{\"txid\":\"${txid}\",\"address\":\"${address}\",\"amount\":${tx_amount},\"eventMessage\":\"${event_message}\"}") returncode=$? trace_rc ${returncode} fi diff --git a/proxy_docker/app/script/watchrequest.sh b/proxy_docker/app/script/watchrequest.sh index a28809b..0a49b23 100644 --- a/proxy_docker/app/script/watchrequest.sh +++ b/proxy_docker/app/script/watchrequest.sh @@ -83,7 +83,7 @@ watchrequest() { \"estimatesmartfee6blocks\":\"${fees6blocks}\", \"estimatesmartfee36blocks\":\"${fees36blocks}\", \"estimatesmartfee144blocks\":\"${fees144blocks}\", - \"event_message\":\"${event_message}\"}" + \"eventMessage\":\"${event_message}\"}" trace "[watchrequest] responding=${data}" echo "${data}"