diff --git a/cyphernodeconf_docker/templates/bitcoin/walletnotify.sh b/cyphernodeconf_docker/templates/bitcoin/walletnotify.sh index 3eb67da2..68e21c18 100644 --- a/cyphernodeconf_docker/templates/bitcoin/walletnotify.sh +++ b/cyphernodeconf_docker/templates/bitcoin/walletnotify.sh @@ -29,11 +29,13 @@ walletnotify(){ tmpfile=$(mktemp) echo "${txb64}" > ${tmpfile} - if [ "${walletname}" = "watching01.dat" ] || [ "${walletname}" = "xpubwatching01.dat" ]; then - echo "[walletnotify-$$] It's a watching wallet ["${walletname}"] - Adding topic cyphernode/bitcoin/walletnotify" - echo "[walletnotify-$$] mosquitto_pub -h broker -t cyphernode/bitcoin/walletnotify -f \"${tmpfile}\"" - mosquitto_pub -h broker -t cyphernode/bitcoin/walletnotify -f "${tmpfile}" - fi + case "${walletname}" in + spending*.dat|watching*.dat|xpubwatching*.dat) + echo "[walletnotify-$$] It's a watching wallet ["${walletname}"] - Adding topic cyphernode/bitcoin/walletnotify" + echo "[walletnotify-$$] mosquitto_pub -h broker -t cyphernode/bitcoin/walletnotify -f \"${tmpfile}\"" + mosquitto_pub -h broker -t cyphernode/bitcoin/walletnotify -f "${tmpfile}" + ;; + esac echo "[walletnotify-$$] mosquitto_pub -h broker -t bitcoinnode/walletnotify -f \"${tmpfile}\"" mosquitto_pub -h broker -t bitcoinnode/walletnotify -f "${tmpfile}" diff --git a/proxy_docker/app/script/manage_missed_conf.sh b/proxy_docker/app/script/manage_missed_conf.sh index 9fd54872..967d2c68 100644 --- a/proxy_docker/app/script/manage_missed_conf.sh +++ b/proxy_docker/app/script/manage_missed_conf.sh @@ -59,15 +59,16 @@ manage_missed_conf() { fi data=${data}'{"id":"'${address}'","method":"listreceivedbyaddress","params":[0,false,true,"'${address}'"]}' done + body_file=$(mktemp) echo "[${data}]" > ${body_file} - received_watches=$(send_batch_to_bitcoin_node "${WATCHER_BTC_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET}" "${WATCHER_BTC_NODE_RPC_CFG}" "${body_file}") - rm ${body_file} - trace "[manage_missed_conf] received_watches=${received_watches}" - # received_watches=[{"result":[],"error":null,"id":"bcrt1q05laru93h7qkf8v0ujaezzsgvakh0t6ytdz8xk"},{"result":[],"error":null,"id":"bcrt1q597re8ayjlls2saz0ypxfks4f22r38zmynwqsx"},{"result":[],"error":null,"id":"bcrt1q65pc8vqznl2l5wk4fd800l5lv0w9dml2c6rws6"},{"result":[{"involvesWatchonly":true,"address":"bcrt1q7xun0gcgt4hu8xtc8e7ttzkw64sp6yun4pzumk","amount":0.00010000,"confirmations":1,"label":"missed1conftest","txids":["05f1912ebdf1538964c7f0d4fb0643e7e35c21cba82e080518c11bebec1aeec4"]}],"error":null,"id":"bcrt1q7xun0gcgt4hu8xtc8e7ttzkw64sp6yun4pzumk"},{"result":[],"error":null,"id":"bcrt1qe3x9zv59xeepgqzgsyhn6s7n3ewkck7wlnmv4f"},{"result":[],"error":null,"id":"bcrt1qegp66u24qjt5m8e7r8z7c243csv7x9e2w55j00"},{"result":[],"error":null,"id":"bcrt1qfhkpv4mghzps09g6t2f693yhh6qqvhw0hyq0yz"},{"result":[],"error":null,"id":"bcrt1qg7hruwvec90fe3ku7unqgccgu6r6mkwrcm7lzj"},{"result":[{"involvesWatchonly":true,"address":"bcrt1qpzwcuhl0tmen8wu26rfyw4eaeq9ku3xqva85ft","amount":0.00010000,"confirmations":3,"label":"missed1conftest","txids":["fb045d4bae557fbae17d4338b15bdab90deff46c1b22c8dd0d34e2100f081d8e"]}],"error":null,"id":"bcrt1qpzwcuhl0tmen8wu26rfyw4eaeq9ku3xqva85ft"},{"result":[],"error":null,"id":"bcrt1qq38fekxvxgn3cw859ps3alf4acugm3h8svzshy"},{"result":[],"error":null,"id":"bcrt1qr8ur0fdc3h9yeqjverc8x2lxjkyp6mlfg0ht03"},{"result":[{"involvesWatchonly":true,"address":"bcrt1qt09cttrcpdfcfr6wltkzdv48ep7h3acux6v8tl","amount":0.00010000,"confirmations":5,"label":"missed1conftest","txids":["4e859d9ce6c173d8373b2222127687bb697311161ec36deff2f1a12282c88b27"]}],"error":null,"id":"bcrt1qt09cttrcpdfcfr6wltkzdv48ep7h3acux6v8tl"},{"result":[{"involvesWatchonly":true,"address":"bcrt1qwdpehjzu6sszp7zgdsud7se6trv2rt35szrcqz","amount":0.00010000,"confirmations":8,"label":"missed1conftest","txids":["bab2adb187ed0d04c8ca0d93f6c94eb2a5c7cccef39d9fb00bd9dab92210f68a"]}],"error":null,"id":"bcrt1qwdpehjzu6sszp7zgdsud7se6trv2rt35szrcqz"},{"result":null,"error":{"code":-4,"message":"address_filter parameter was invalid"},"id":"tb1q7g0zneqlww82vafshwgf5rz6mhgj2lkpkkt08x"},{"result":null,"error":{"code":-4,"message":"address_filter parameter was invalid"},"id":"tb1qpf55tg76lurah3z67d3tk93tc2yzmntspsjqnc"},{"result":null,"error":{"code":-4,"message":"address_filter parameter was invalid"},"id":"tb1qx5jwlzjscz2k6cfse8tn4pdrlye8es7epz5msc"}] - received_watches=$(echo "${received_watches}" | jq -Mc '.[] | select(.result != [] and .result != null) | .result[0]') + for wallet in "01" "02" "03" "04" + do + received_watches=${received_watches}$(send_batch_to_spender_node "${body_file}" "${wallet}" | jq -Mc '.[] | select(.result != [] and .result != null) | .result[0]') + done trace "[manage_missed_conf] received_watches=${received_watches}" + rm ${body_file} local received_watch local confirmations @@ -113,7 +114,15 @@ manage_missed_conf() { data="{\"method\":\"gettransaction\",\"params\":[\"${txid}\",true,true]}" trace "[manage_missed_conf] calling method=${data}" - tx=$(send_to_watcher_node "${data}") + for wallet in "01" "02" "03" "04" + do + tx=$(send_to_spender_node "${data}" ${wallet}) + returncode=$? + trace_rc ${returncode} + if [ "${returncode}" -eq 0 ]; then + break + fi + done txtime=$(echo "${tx}" | jq '.result.time') diff --git a/proxy_docker/app/script/sendtobitcoinnode.sh b/proxy_docker/app/script/sendtobitcoinnode.sh index 5a582f00..f63d1515 100644 --- a/proxy_docker/app/script/sendtobitcoinnode.sh +++ b/proxy_docker/app/script/sendtobitcoinnode.sh @@ -89,6 +89,21 @@ send_to_bitcoin_node() { return ${returncode} } +send_batch_to_spender_node() { + trace "Entering send_batch_to_spender_node()..." + + local walletname=${SPENDER_BTC_NODE_DEFAULT_WALLET} + if [ -n "$2" ]; then + walletname="spending${2}.dat" + fi + trace "[send_batch_to_spender_node]wallet: ${walletname}" + + send_batch_to_bitcoin_node "${SPENDER_BTC_NODE_RPC_URL}/${walletname}" "${SPENDER_BTC_NODE_RPC_CFG}" "$1" + local returncode=$? + trace_rc ${returncode} + return ${returncode} +} + send_batch_to_bitcoin_node() { trace "Entering send_batch_to_bitcoin_node()..." local returncode diff --git a/proxy_docker/app/script/watchrequest.sh b/proxy_docker/app/script/watchrequest.sh index 965d2692..0953bf10 100644 --- a/proxy_docker/app/script/watchrequest.sh +++ b/proxy_docker/app/script/watchrequest.sh @@ -110,14 +110,14 @@ watchrequest() { return 1 fi - result=$(importaddress_rpc "${address}" "${label}") - returncode=$? - trace_rc ${returncode} - if [ "${returncode}" -eq 0 ]; then + # result=$(importaddress_rpc "${address}" "${label}") + # returncode=$? + # trace_rc ${returncode} + # if [ "${returncode}" -eq 0 ]; then imported=true - else - imported=false - fi + # else + # imported=false + # fi id_inserted=$(sql "INSERT INTO watching (address, watching, callback0conf, callback1conf, imported, event_message, label)"\ " VALUES (${address_pg}, true, ${cb0conf_url_pg}, ${cb1conf_url_pg}, ${imported}, ${event_message_pg}, ${label_pg})"\