mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 05:05:12 +01:00
Typo
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
. ./trace.sh
|
. ./trace.sh
|
||||||
|
|
||||||
send_to_watcher_node() {
|
send_to_watcher_node() {
|
||||||
trace "Entering send_to_watcher_node()..."
|
trace "Entering send_to_watcher_node()..."
|
||||||
send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET} ${WATCHER_NODE_RPC_CFG} $@
|
send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET} ${WATCHER_NODE_RPC_CFG} $@
|
||||||
local returncode=$?
|
local returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
|
|
||||||
if [ "${returncode}" -ne 0 ]; then
|
if [ "${returncode}" -ne 0 ]; then
|
||||||
# Ok, since we now have multiple watching wallets, we need to try them all if it fails
|
# Ok, since we now have multiple watching wallets, we need to try them all if it fails
|
||||||
@@ -14,65 +14,65 @@ send_to_watcher_node() {
|
|||||||
send_to_watcher_node_wallet ${WATCHER_BTC_NODE_XPUB_WALLET} $@
|
send_to_watcher_node_wallet ${WATCHER_BTC_NODE_XPUB_WALLET} $@
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
}
|
fi
|
||||||
|
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_to_watcher_node_wallet() {
|
send_to_watcher_node_wallet() {
|
||||||
trace "Entering send_to_watcher_node_wallet()..."
|
trace "Entering send_to_watcher_node_wallet()..."
|
||||||
local walletname=$1
|
local walletname=$1
|
||||||
shift
|
shift
|
||||||
trace "[send_to_watcher_node_wallet] walletname=${walletname}"
|
trace "[send_to_watcher_node_wallet] walletname=${walletname}"
|
||||||
send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${walletname} ${WATCHER_NODE_RPC_CFG} $@
|
send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${walletname} ${WATCHER_NODE_RPC_CFG} $@
|
||||||
local returncode=$?
|
local returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_to_spender_node()
|
send_to_spender_node()
|
||||||
{
|
{
|
||||||
trace "Entering send_to_spender_node()..."
|
trace "Entering send_to_spender_node()..."
|
||||||
send_to_bitcoin_node ${SPENDER_NODE_RPC_URL}/${SPENDER_BTC_NODE_DEFAULT_WALLET} ${SPENDER_NODE_RPC_CFG} $@
|
send_to_bitcoin_node ${SPENDER_NODE_RPC_URL}/${SPENDER_BTC_NODE_DEFAULT_WALLET} ${SPENDER_NODE_RPC_CFG} $@
|
||||||
local returncode=$?
|
local returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_to_bitcoin_node()
|
send_to_bitcoin_node()
|
||||||
{
|
{
|
||||||
trace "Entering send_to_bitcoin_node()..."
|
trace "Entering send_to_bitcoin_node()..."
|
||||||
local returncode
|
local returncode
|
||||||
local result
|
local result
|
||||||
local errorstring
|
local errorstring
|
||||||
local node_url=${1}
|
local node_url=${1}
|
||||||
local config=${2}
|
local config=${2}
|
||||||
local data=${3}
|
local data=${3}
|
||||||
|
|
||||||
trace "[send_to_bitcoin_node] curl -s --config ${config} -H \"Content-Type: application/json\" -d \"${data}\" ${node_url}"
|
trace "[send_to_bitcoin_node] curl -s --config ${config} -H \"Content-Type: application/json\" -d \"${data}\" ${node_url}"
|
||||||
result=$(curl -s --config ${config} -H "Content-Type: application/json" -d "${data}" ${node_url})
|
result=$(curl -s --config ${config} -H "Content-Type: application/json" -d "${data}" ${node_url})
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
trace "[send_to_bitcoin_node] result=${result}"
|
trace "[send_to_bitcoin_node] result=${result}"
|
||||||
|
|
||||||
if [ "${returncode}" -eq 0 ]; then
|
if [ "${returncode}" -eq 0 ]; then
|
||||||
# Node responded, let's see if we got an error message from the node
|
# Node responded, let's see if we got an error message from the node
|
||||||
# jq -e will have a return code of 1 if the supplied tag is null.
|
# jq -e will have a return code of 1 if the supplied tag is null.
|
||||||
errorstring=$(echo "${result}" | jq -e ".error")
|
errorstring=$(echo "${result}" | jq -e ".error")
|
||||||
if [ "$?" -eq "0" ]; then
|
if [ "$?" -eq "0" ]; then
|
||||||
# Error tag not null, so there's an error
|
# Error tag not null, so there's an error
|
||||||
trace "[send_to_bitcoin_node] Node responded, error found in response: ${errorstring}"
|
trace "[send_to_bitcoin_node] Node responded, error found in response: ${errorstring}"
|
||||||
returncode=1
|
returncode=1
|
||||||
else
|
else
|
||||||
trace "[send_to_bitcoin_node] Node responded, no error found in response, yayy!"
|
trace "[send_to_bitcoin_node] Node responded, no error found in response, yayy!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output response to stdout before exiting with return code
|
# Output response to stdout before exiting with return code
|
||||||
echo "${result}"
|
echo "${result}"
|
||||||
|
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${0}" in *sendtobitcoinnode.sh) send_to_bitcoin_node $@;; esac
|
case "${0}" in *sendtobitcoinnode.sh) send_to_bitcoin_node $@;; esac
|
||||||
|
|||||||
@@ -4,79 +4,79 @@
|
|||||||
. ./sql.sh
|
. ./sql.sh
|
||||||
|
|
||||||
unwatchrequest() {
|
unwatchrequest() {
|
||||||
trace "Entering unwatchrequest()..."
|
trace "Entering unwatchrequest()..."
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local address=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
local address=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
||||||
local returncode
|
local returncode
|
||||||
trace "[unwatchrequest] Unwatch request on address ${address}"
|
trace "[unwatchrequest] Unwatch request on address ${address}"
|
||||||
|
|
||||||
sql "UPDATE watching SET watching=0 WHERE address=\"${address}\""
|
sql "UPDATE watching SET watching=0 WHERE address=\"${address}\""
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
|
|
||||||
data="{\"event\":\"unwatch\",\"address\":\"${address}\"}"
|
data="{\"event\":\"unwatch\",\"address\":\"${address}\"}"
|
||||||
trace "[unwatchrequest] responding=${data}"
|
trace "[unwatchrequest] responding=${data}"
|
||||||
|
|
||||||
echo "${data}"
|
echo "${data}"
|
||||||
|
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
unwatchpub32request() {
|
unwatchpub32request() {
|
||||||
trace "Entering unwatchpub32request()..."
|
trace "Entering unwatchpub32request()..."
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local pub32=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
local pub32=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
||||||
local id
|
local id
|
||||||
local returncode
|
local returncode
|
||||||
trace "[unwatchpub32request] Unwatch pub32 ${pub32}"
|
trace "[unwatchpub32request] Unwatch pub32 ${pub32}"
|
||||||
|
|
||||||
id=$(sql "SELECT id FROM watching_by_pub32 WHERE pub32='${pub32}'")
|
id=$(sql "SELECT id FROM watching_by_pub32 WHERE pub32='${pub32}'")
|
||||||
trace "[unwatchpub32request] id: ${id}"
|
trace "[unwatchpub32request] id: ${id}"
|
||||||
|
|
||||||
sql "UPDATE watching_by_pub32 SET watching=0 WHERE id=${id}"
|
sql "UPDATE watching_by_pub32 SET watching=0 WHERE id=${id}"
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
|
|
||||||
sql "UPDATE watching SET watching=0 WHERE watching_by_pub32_id=\"${id}\""
|
sql "UPDATE watching SET watching=0 WHERE watching_by_pub32_id=\"${id}\""
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
|
|
||||||
data="{\"event\":\"unwatchxpubbyxpub\",\"pub32\":\"${pub32}\"}"
|
data="{\"event\":\"unwatchxpubbyxpub\",\"pub32\":\"${pub32}\"}"
|
||||||
trace "[unwatchpub32request] responding=${data}"
|
trace "[unwatchpub32request] responding=${data}"
|
||||||
|
|
||||||
echo "${data}"
|
echo "${data}"
|
||||||
|
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
unwatchpub32labelrequest() {
|
unwatchpub32labelrequest() {
|
||||||
trace "Entering unwatchpub32labelrequest()..."
|
trace "Entering unwatchpub32labelrequest()..."
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local label=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
local label=$(echo "${request}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
||||||
local id
|
local id
|
||||||
local returncode
|
local returncode
|
||||||
trace "[unwatchpub32labelrequest] Unwatch xpub label ${label}"
|
trace "[unwatchpub32labelrequest] Unwatch xpub label ${label}"
|
||||||
|
|
||||||
id=$(sql "SELECT id FROM watching_by_pub32 WHERE label='${label}'")
|
id=$(sql "SELECT id FROM watching_by_pub32 WHERE label='${label}'")
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
trace "[unwatchpub32labelrequest] id: ${id}"
|
trace "[unwatchpub32labelrequest] id: ${id}"
|
||||||
|
|
||||||
sql "UPDATE watching_by_pub32 SET watching=0 WHERE id=${id}"
|
sql "UPDATE watching_by_pub32 SET watching=0 WHERE id=${id}"
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
|
|
||||||
sql "UPDATE watching SET watching=0 WHERE watching_by_pub32_id=\"${id}\""
|
sql "UPDATE watching SET watching=0 WHERE watching_by_pub32_id=\"${id}\""
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
|
|
||||||
data="{\"event\":\"unwatchxpubbylabel\",\"label\":\"${label}\"}"
|
data="{\"event\":\"unwatchxpubbylabel\",\"label\":\"${label}\"}"
|
||||||
trace "[unwatchpub32labelrequest] responding=${data}"
|
trace "[unwatchpub32labelrequest] responding=${data}"
|
||||||
|
|
||||||
echo "${data}"
|
echo "${data}"
|
||||||
|
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user