mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 21:25:06 +01:00
Added -r to jq when tr -d double-quotes
This commit is contained in:
@@ -16,8 +16,7 @@
|
|||||||
|
|
||||||
. ./trace.sh
|
. ./trace.sh
|
||||||
|
|
||||||
verify_sign()
|
verify_sign() {
|
||||||
{
|
|
||||||
local returncode
|
local returncode
|
||||||
|
|
||||||
local header64=$(echo "${1}" | cut -sd '.' -f1)
|
local header64=$(echo "${1}" | cut -sd '.' -f1)
|
||||||
@@ -38,7 +37,7 @@ verify_sign()
|
|||||||
|
|
||||||
if [ ${exp} -gt ${current} ]; then
|
if [ ${exp} -gt ${current} ]; then
|
||||||
trace "[verify_sign] Not expired, let's validate signature"
|
trace "[verify_sign] Not expired, let's validate signature"
|
||||||
local id=$(echo "${payload}" | jq ".id" | tr -d '"')
|
local id=$(echo "${payload}" | jq -r ".id")
|
||||||
trace "[verify_sign] id=${id}"
|
trace "[verify_sign] id=${id}"
|
||||||
|
|
||||||
# Check for code injection
|
# Check for code injection
|
||||||
@@ -82,8 +81,7 @@ verify_sign()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_group()
|
verify_group() {
|
||||||
{
|
|
||||||
trace "[verify_group] Verifying group..."
|
trace "[verify_group] Verifying group..."
|
||||||
|
|
||||||
local id=${1}
|
local id=${1}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ checknotifier() {
|
|||||||
response=$(mosquitto_rr -h broker -W 15 -t notifier -e "response/$$" -m "{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"http://proxy:8888/helloworld\"}")
|
response=$(mosquitto_rr -h broker -W 15 -t notifier -e "response/$$" -m "{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"http://proxy:8888/helloworld\"}")
|
||||||
returncode=$?
|
returncode=$?
|
||||||
[ "${returncode}" -ne "0" ] && return 115
|
[ "${returncode}" -ne "0" ] && return 115
|
||||||
http_code=$(echo "${response}" | jq ".http_code" | tr -d '"')
|
http_code=$(echo "${response}" | jq -r ".http_code")
|
||||||
[ "${http_code}" -ge "400" ] && return 118
|
[ "${http_code}" -ge "400" ] && return 118
|
||||||
|
|
||||||
echo -e "\e[1;36mNotifier rocks!" > /dev/console
|
echo -e "\e[1;36mNotifier rocks!" > /dev/console
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ main() {
|
|||||||
trace "[main] New msg just arrived!"
|
trace "[main] New msg just arrived!"
|
||||||
trace "[main] msg=${msg}"
|
trace "[main] msg=${msg}"
|
||||||
|
|
||||||
cmd=$(echo ${msg} | jq ".cmd" | tr -d '"')
|
cmd=$(echo ${msg} | jq -r ".cmd")
|
||||||
trace "[main] cmd=${cmd}"
|
trace "[main] cmd=${cmd}"
|
||||||
|
|
||||||
response_topic=$(echo ${msg} | jq '."response-topic"' | tr -d '"')
|
response_topic=$(echo ${msg} | jq -r '."response-topic"')
|
||||||
trace "[main] response_topic=${response_topic}"
|
trace "[main] response_topic=${response_topic}"
|
||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
. ./trace.sh
|
. ./trace.sh
|
||||||
. ./sendtobitcoinnode.sh
|
. ./sendtobitcoinnode.sh
|
||||||
|
|
||||||
get_best_block_hash()
|
get_best_block_hash() {
|
||||||
{
|
|
||||||
trace "Entering get_best_block_hash()..."
|
trace "Entering get_best_block_hash()..."
|
||||||
|
|
||||||
local data='{"method":"getbestblockhash"}'
|
local data='{"method":"getbestblockhash"}'
|
||||||
@@ -12,8 +11,7 @@ get_best_block_hash()
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
getestimatesmartfee()
|
getestimatesmartfee() {
|
||||||
{
|
|
||||||
trace "Entering getestimatesmartfee()..."
|
trace "Entering getestimatesmartfee()..."
|
||||||
|
|
||||||
local nb_blocks=${1}
|
local nb_blocks=${1}
|
||||||
@@ -22,8 +20,7 @@ getestimatesmartfee()
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
get_block_info()
|
get_block_info() {
|
||||||
{
|
|
||||||
trace "Entering get_block_info()..."
|
trace "Entering get_block_info()..."
|
||||||
|
|
||||||
local block_hash=${1}
|
local block_hash=${1}
|
||||||
@@ -34,18 +31,16 @@ get_block_info()
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
get_best_block_info()
|
get_best_block_info() {
|
||||||
{
|
|
||||||
trace "Entering get_best_block_info()..."
|
trace "Entering get_best_block_info()..."
|
||||||
|
|
||||||
local block_hash=$(echo "$(get_best_block_hash)" | jq ".result" | tr -d '"')
|
local block_hash=$(echo "$(get_best_block_hash)" | jq -r ".result")
|
||||||
trace "[get_best_block_info] block_hash=${block_hash}"
|
trace "[get_best_block_info] block_hash=${block_hash}"
|
||||||
get_block_info ${block_hash}
|
get_block_info ${block_hash}
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
get_rawtransaction()
|
get_rawtransaction() {
|
||||||
{
|
|
||||||
trace "Entering get_rawtransaction()..."
|
trace "Entering get_rawtransaction()..."
|
||||||
|
|
||||||
local txid=${1}
|
local txid=${1}
|
||||||
@@ -74,8 +69,7 @@ get_transaction() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
get_blockchain_info()
|
get_blockchain_info() {
|
||||||
{
|
|
||||||
trace "Entering get_blockchain_info()..."
|
trace "Entering get_blockchain_info()..."
|
||||||
|
|
||||||
local data='{"method":"getblockchaininfo"}'
|
local data='{"method":"getblockchaininfo"}'
|
||||||
@@ -83,8 +77,7 @@ get_blockchain_info()
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
get_mempool_info()
|
get_mempool_info() {
|
||||||
{
|
|
||||||
trace "Entering get_mempool_info()..."
|
trace "Entering get_mempool_info()..."
|
||||||
|
|
||||||
local data='{"method":"getmempoolinfo"}'
|
local data='{"method":"getmempoolinfo"}'
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
. ./trace.sh
|
. ./trace.sh
|
||||||
|
|
||||||
ln_create_invoice()
|
ln_create_invoice() {
|
||||||
{
|
|
||||||
trace "Entering ln_create_invoice()..."
|
trace "Entering ln_create_invoice()..."
|
||||||
|
|
||||||
local result
|
local result
|
||||||
@@ -11,15 +10,15 @@ ln_create_invoice()
|
|||||||
local id
|
local id
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local msatoshi=$(echo "${request}" | jq ".msatoshi" | tr -d '"')
|
local msatoshi=$(echo "${request}" | jq -r ".msatoshi")
|
||||||
trace "[ln_create_invoice] msatoshi=${msatoshi}"
|
trace "[ln_create_invoice] msatoshi=${msatoshi}"
|
||||||
local label=$(echo "${request}" | jq ".label" | tr -d '"')
|
local label=$(echo "${request}" | jq -r ".label")
|
||||||
trace "[ln_create_invoice] label=${label}"
|
trace "[ln_create_invoice] label=${label}"
|
||||||
local description=$(echo "${request}" | jq ".description" | tr -d '"')
|
local description=$(echo "${request}" | jq -r ".description")
|
||||||
trace "[ln_create_invoice] description=${description}"
|
trace "[ln_create_invoice] description=${description}"
|
||||||
local expiry=$(echo "${request}" | jq ".expiry" | tr -d '"')
|
local expiry=$(echo "${request}" | jq -r ".expiry")
|
||||||
trace "[ln_create_invoice] expiry=${expiry}"
|
trace "[ln_create_invoice] expiry=${expiry}"
|
||||||
local callback_url=$(echo "${request}" | jq ".callbackUrl" | tr -d '"')
|
local callback_url=$(echo "${request}" | jq -r ".callbackUrl")
|
||||||
trace "[ln_create_invoice] callback_url=${callback_url}"
|
trace "[ln_create_invoice] callback_url=${callback_url}"
|
||||||
|
|
||||||
#/proxy $ ./lightning-cli invoice 10000 "t1" "t1d" 60
|
#/proxy $ ./lightning-cli invoice 10000 "t1" "t1d" 60
|
||||||
@@ -38,11 +37,11 @@ ln_create_invoice()
|
|||||||
if [ "${returncode}" -ne "0" ]; then
|
if [ "${returncode}" -ne "0" ]; then
|
||||||
data=${result}
|
data=${result}
|
||||||
else
|
else
|
||||||
local bolt11=$(echo "${result}" | jq ".bolt11" | tr -d '"')
|
local bolt11=$(echo "${result}" | jq -r ".bolt11")
|
||||||
trace "[ln_create_invoice] bolt11=${bolt11}"
|
trace "[ln_create_invoice] bolt11=${bolt11}"
|
||||||
local payment_hash=$(echo "${result}" | jq ".payment_hash" | tr -d '"')
|
local payment_hash=$(echo "${result}" | jq -r ".payment_hash")
|
||||||
trace "[ln_create_invoice] payment_hash=${payment_hash}"
|
trace "[ln_create_invoice] payment_hash=${payment_hash}"
|
||||||
local expires_at=$(echo "${result}" | jq ".expires_at" | tr -d '"')
|
local expires_at=$(echo "${result}" | jq -r ".expires_at")
|
||||||
trace "[ln_create_invoice] expires_at=${expires_at}"
|
trace "[ln_create_invoice] expires_at=${expires_at}"
|
||||||
|
|
||||||
# Let's get the connect string if provided in configuration
|
# Let's get the connect string if provided in configuration
|
||||||
@@ -88,15 +87,14 @@ get_connection_string() {
|
|||||||
echo ${getinfo} | jq -e '.address[0]' > /dev/null
|
echo ${getinfo} | jq -e '.address[0]' > /dev/null
|
||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
# If there's an address
|
# If there's an address
|
||||||
connectstring="$(echo ${getinfo} | jq '((.id + "@") + (.address[0] | ((.address + ":") + (.port | tostring))))' | tr -d '"')"
|
connectstring="$(echo ${getinfo} | jq -r '((.id + "@") + (.address[0] | ((.address + ":") + (.port | tostring))))')"
|
||||||
trace "[get_connection_string] connectstring=${connectstring}"
|
trace "[get_connection_string] connectstring=${connectstring}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${connectstring}"
|
echo "${connectstring}"
|
||||||
}
|
}
|
||||||
|
|
||||||
ln_getinfo()
|
ln_getinfo() {
|
||||||
{
|
|
||||||
trace "Entering ln_get_info()..."
|
trace "Entering ln_get_info()..."
|
||||||
|
|
||||||
local result
|
local result
|
||||||
@@ -190,11 +188,11 @@ ln_connectfund() {
|
|||||||
local msg
|
local msg
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local peer=$(echo "${request}" | jq ".peer" | tr -d '"')
|
local peer=$(echo "${request}" | jq -r ".peer")
|
||||||
trace "[ln_connectfund] peer=${peer}"
|
trace "[ln_connectfund] peer=${peer}"
|
||||||
local msatoshi=$(echo "${request}" | jq ".msatoshi")
|
local msatoshi=$(echo "${request}" | jq ".msatoshi")
|
||||||
trace "[ln_connectfund] msatoshi=${msatoshi}"
|
trace "[ln_connectfund] msatoshi=${msatoshi}"
|
||||||
local callback_url=$(echo "${request}" | jq ".callbackUrl" | tr -d '"')
|
local callback_url=$(echo "${request}" | jq -r ".callbackUrl")
|
||||||
trace "[ln_connectfund] callback_url=${callback_url}"
|
trace "[ln_connectfund] callback_url=${callback_url}"
|
||||||
|
|
||||||
# Let's first try to connect to peer
|
# Let's first try to connect to peer
|
||||||
@@ -215,7 +213,7 @@ ln_connectfund() {
|
|||||||
# ./lightning-cli connect 021a1b197aa79242532b23cb9a8d9cb78631f95f811457675fa1b362fe6d1c24b8@172.81.180.244:9735
|
# ./lightning-cli connect 021a1b197aa79242532b23cb9a8d9cb78631f95f811457675fa1b362fe6d1c24b8@172.81.180.244:9735
|
||||||
# { "code" : -1, "message" : "172.1.180.244:9735: Connection establishment: Operation timed out. " }
|
# { "code" : -1, "message" : "172.1.180.244:9735: Connection establishment: Operation timed out. " }
|
||||||
|
|
||||||
nodeId=$(echo "${result}" | jq ".id" | tr -d '"')
|
nodeId=$(echo "${result}" | jq -r ".id")
|
||||||
trace "[ln_connectfund] nodeId=${nodeId}"
|
trace "[ln_connectfund] nodeId=${nodeId}"
|
||||||
|
|
||||||
# Now let's fund a channel with peer
|
# Now let's fund a channel with peer
|
||||||
@@ -288,7 +286,7 @@ ln_pay() {
|
|||||||
local payment_hash
|
local payment_hash
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local bolt11=$(echo "${request}" | jq ".bolt11" | tr -d '"')
|
local bolt11=$(echo "${request}" | jq -r ".bolt11")
|
||||||
trace "[ln_pay] bolt11=${bolt11}"
|
trace "[ln_pay] bolt11=${bolt11}"
|
||||||
local expected_msatoshi=$(echo "${request}" | jq ".expected_msatoshi")
|
local expected_msatoshi=$(echo "${request}" | jq ".expected_msatoshi")
|
||||||
trace "[ln_pay] expected_msatoshi=${expected_msatoshi}"
|
trace "[ln_pay] expected_msatoshi=${expected_msatoshi}"
|
||||||
@@ -344,7 +342,7 @@ ln_pay() {
|
|||||||
|
|
||||||
if [ "${code}" -eq "200" ]; then
|
if [ "${code}" -eq "200" ]; then
|
||||||
trace "[ln_pay] Code 200, let's fetch status in data, should be pending..."
|
trace "[ln_pay] Code 200, let's fetch status in data, should be pending..."
|
||||||
status=$(echo "${result}" | jq ".data.status" | tr -d '"')
|
status=$(echo "${result}" | jq -r ".data.status")
|
||||||
trace "[ln_pay] status=${status}"
|
trace "[ln_pay] status=${status}"
|
||||||
else
|
else
|
||||||
trace "[ln_pay] Failure code, response will be the cli result."
|
trace "[ln_pay] Failure code, response will be the cli result."
|
||||||
@@ -352,14 +350,14 @@ ln_pay() {
|
|||||||
else
|
else
|
||||||
# code tag not found
|
# code tag not found
|
||||||
trace "[ln_pay] No error code, getting the status..."
|
trace "[ln_pay] No error code, getting the status..."
|
||||||
status=$(echo "${result}" | jq ".status" | tr -d '"')
|
status=$(echo "${result}" | jq -r ".status")
|
||||||
trace "[ln_pay] status=${status}"
|
trace "[ln_pay] status=${status}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${status}" = "pending" ]; then
|
if [ "${status}" = "pending" ]; then
|
||||||
trace "[ln_pay] Ok let's deal with pending status with waitsendpay."
|
trace "[ln_pay] Ok let's deal with pending status with waitsendpay."
|
||||||
|
|
||||||
payment_hash=$(echo "${result}" | jq ".data.payment_hash" | tr -d '"')
|
payment_hash=$(echo "${result}" | jq -r ".data.payment_hash")
|
||||||
trace "[ln_pay] ./lightning-cli waitsendpay ${payment_hash} 15"
|
trace "[ln_pay] ./lightning-cli waitsendpay ${payment_hash} 15"
|
||||||
result=$(./lightning-cli waitsendpay ${payment_hash} 15)
|
result=$(./lightning-cli waitsendpay ${payment_hash} 15)
|
||||||
returncode=$?
|
returncode=$?
|
||||||
@@ -420,8 +418,7 @@ ln_pay() {
|
|||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
ln_newaddr()
|
ln_newaddr() {
|
||||||
{
|
|
||||||
trace "Entering ln_newaddr()..."
|
trace "Entering ln_newaddr()..."
|
||||||
|
|
||||||
local result
|
local result
|
||||||
|
|||||||
@@ -5,81 +5,76 @@
|
|||||||
. ./importaddress.sh
|
. ./importaddress.sh
|
||||||
. ./confirmation.sh
|
. ./confirmation.sh
|
||||||
|
|
||||||
manage_not_imported()
|
manage_not_imported() {
|
||||||
{
|
# When we tried to import watched addresses in the watching node,
|
||||||
# When we tried to import watched addresses in the watching node,
|
# if it didn't succeed, we try again here.
|
||||||
# if it didn't succeed, we try again here.
|
|
||||||
|
|
||||||
trace "[Entering manage_not_imported()]"
|
trace "[Entering manage_not_imported()]"
|
||||||
|
|
||||||
local watches=$(sql 'SELECT address FROM watching WHERE watching AND NOT imported')
|
local watches=$(sql 'SELECT address FROM watching WHERE watching AND NOT imported')
|
||||||
trace "[manage_not_imported] watches=${watches}"
|
trace "[manage_not_imported] watches=${watches}"
|
||||||
|
|
||||||
local result
|
local result
|
||||||
local returncode
|
local returncode
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for address in ${watches}
|
for address in ${watches}
|
||||||
do
|
do
|
||||||
result=$(importaddress_rpc "${address}")
|
result=$(importaddress_rpc "${address}")
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
if [ "${returncode}" -eq 0 ]; then
|
if [ "${returncode}" -eq 0 ]; then
|
||||||
sql "UPDATE watching SET imported=1 WHERE address=\"${address}\""
|
sql "UPDATE watching SET imported=1 WHERE address=\"${address}\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
manage_missed_conf()
|
manage_missed_conf() {
|
||||||
{
|
# Maybe we missed confirmations, because we were down or no network or
|
||||||
# Maybe we missed confirmations, because we were down or no network or
|
# whatever, so we look at what might be missed and do confirmations.
|
||||||
# whatever, so we look at what might be missed and do confirmations.
|
|
||||||
|
|
||||||
trace "[Entering manage_missed_conf()]"
|
trace "[Entering manage_missed_conf()]"
|
||||||
|
|
||||||
# local watches=$(sql 'SELECT address FROM watching WHERE txid IS NULL AND watching AND imported')
|
local watches=$(sql 'SELECT address FROM watching w LEFT JOIN watching_tx ON w.id = watching_id LEFT JOIN tx t ON t.id = tx_id WHERE watching AND imported AND (tx_id IS NULL OR t.confirmations=0)')
|
||||||
#local watches=$(sql 'SELECT address FROM watching LEFT JOIN watching_tx ON id = watching_id WHERE watching AND imported AND tx_id IS NULL')
|
trace "[manage_missed_conf] watches=${watches}"
|
||||||
local watches=$(sql 'SELECT address FROM watching w LEFT JOIN watching_tx ON w.id = watching_id LEFT JOIN tx t ON t.id = tx_id WHERE watching AND imported AND (tx_id IS NULL OR t.confirmations=0)')
|
if [ ${#watches} -eq 0 ]; then
|
||||||
trace "[manage_missed_conf] watches=${watches}"
|
trace "[manage_missed_conf] Nothing missed!"
|
||||||
if [ ${#watches} -eq 0 ]; then
|
return 0
|
||||||
trace "[manage_missed_conf] Nothing missed!"
|
fi
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local addresses
|
local addresses
|
||||||
local data
|
local data
|
||||||
local result
|
local result
|
||||||
local returncode
|
local returncode
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for address in ${watches}
|
for address in ${watches}
|
||||||
do
|
do
|
||||||
if [ -z ${addresses} ]; then
|
if [ -z ${addresses} ]; then
|
||||||
addresses="[\"${address}\""
|
addresses="[\"${address}\""
|
||||||
else
|
else
|
||||||
addresses="${addresses},\"${address}\""
|
addresses="${addresses},\"${address}\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
addresses="${addresses}]"
|
addresses="${addresses}]"
|
||||||
|
|
||||||
# Watching addresses with UTXO are transactions being watched that went through without us knowing it, we missed the conf
|
# Watching addresses with UTXO are transactions being watched that went through without us knowing it, we missed the conf
|
||||||
data="{\"method\":\"listunspent\",\"params\":[0, 9999999, ${addresses}]}"
|
data="{\"method\":\"listunspent\",\"params\":[0, 9999999, ${addresses}]}"
|
||||||
local unspents
|
local unspents
|
||||||
unspents=$(send_to_watcher_node ${data})
|
unspents=$(send_to_watcher_node ${data})
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
if [ "${returncode}" -ne 0 ]; then
|
if [ "${returncode}" -ne 0 ]; then
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# | tr -d '"'
|
local txids=$(echo "${unspents}" | jq -r ".result[].txid")
|
||||||
local txids=$(echo "${unspents}" | jq ".result[].txid" | tr -d '"')
|
for txid in ${txids}
|
||||||
for txid in ${txids}
|
do
|
||||||
do
|
confirmation "${txid}"
|
||||||
confirmation "${txid}"
|
done
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ notify_web() {
|
|||||||
# The response looks like this: {"curl_code":0,"http_code":200,"body":"..."} where the body
|
# The response looks like this: {"curl_code":0,"http_code":200,"body":"..."} where the body
|
||||||
# is the base64(response body) but we don't need the response content here.
|
# is the base64(response body) but we don't need the response content here.
|
||||||
trace "[notify_web] response=${response}"
|
trace "[notify_web] response=${response}"
|
||||||
curl_code=$(echo "${response}" | jq ".curl_code" | tr -d '"')
|
curl_code=$(echo "${response}" | jq -r ".curl_code")
|
||||||
trace "[notify_web] curl_code=${curl_code}"
|
trace "[notify_web] curl_code=${curl_code}"
|
||||||
http_code=$(echo "${response}" | jq ".http_code" | tr -d '"')
|
http_code=$(echo "${response}" | jq -r ".http_code")
|
||||||
trace "[notify_web] http_code=${http_code}"
|
trace "[notify_web] http_code=${http_code}"
|
||||||
|
|
||||||
if [ "${curl_code}" -eq "0" ] && [ "${returncode}" -eq "0" ]; then
|
if [ "${curl_code}" -eq "0" ] && [ "${returncode}" -eq "0" ]; then
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ serve_ots_stamp() {
|
|||||||
trace "Entering serve_ots_stamp()..."
|
trace "Entering serve_ots_stamp()..."
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local hash=$(echo "${request}" | jq ".hash" | tr -d '"')
|
local hash=$(echo "${request}" | jq -r ".hash")
|
||||||
trace "[serve_ots_stamp] hash=${hash}"
|
trace "[serve_ots_stamp] hash=${hash}"
|
||||||
local callbackUrl=$(echo "${request}" | jq ".callbackUrl" | tr -d '"')
|
local callbackUrl=$(echo "${request}" | jq -r ".callbackUrl")
|
||||||
trace "[serve_ots_stamp] callbackUrl=${callbackUrl}"
|
trace "[serve_ots_stamp] callbackUrl=${callbackUrl}"
|
||||||
|
|
||||||
local result
|
local result
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
. ./ots.sh
|
. ./ots.sh
|
||||||
. ./newblock.sh
|
. ./newblock.sh
|
||||||
|
|
||||||
main()
|
main() {
|
||||||
{
|
|
||||||
trace "Entering main()..."
|
trace "Entering main()..."
|
||||||
|
|
||||||
local step=0
|
local step=0
|
||||||
@@ -269,7 +268,7 @@ main()
|
|||||||
# POST http://192.168.111.152:8080/addtobatch
|
# POST http://192.168.111.152:8080/addtobatch
|
||||||
# BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","amount":0.00233}
|
# BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","amount":0.00233}
|
||||||
|
|
||||||
response=$(addtobatching $(echo "${line}" | jq ".address" | tr -d '"') $(echo "${line}" | jq ".amount"))
|
response=$(addtobatching $(echo "${line}" | jq -r ".address") $(echo "${line}" | jq ".amount"))
|
||||||
response_to_client "${response}" ${?}
|
response_to_client "${response}" ${?}
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ ln_waitanyinvoice() {
|
|||||||
trace "[ln_waitanyinvoice] result=${result}"
|
trace "[ln_waitanyinvoice] result=${result}"
|
||||||
|
|
||||||
if [ "${returncode}" -eq "0" ]; then
|
if [ "${returncode}" -eq "0" ]; then
|
||||||
bolt11=$(echo "${result}" | jq ".bolt11" | tr -d '"')
|
bolt11=$(echo "${result}" | jq -r ".bolt11")
|
||||||
pay_index=$(echo "${result}" | jq ".pay_index" | tr -d '"')
|
pay_index=$(echo "${result}" | jq -r ".pay_index")
|
||||||
msatoshi_received=$(echo "${result}" | jq ".msatoshi_received" | tr -d '"')
|
msatoshi_received=$(echo "${result}" | jq -r ".msatoshi_received")
|
||||||
status=$(echo "${result}" | jq ".status" | tr -d '"')
|
status=$(echo "${result}" | jq -r ".status")
|
||||||
paid_at=$(echo "${result}" | jq ".paid_at" | tr -d '"')
|
paid_at=$(echo "${result}" | jq -r ".paid_at")
|
||||||
|
|
||||||
sql "UPDATE ln_invoice SET status=\"${status}\", pay_index=${pay_index}, msatoshi_received=${msatoshi_received}, paid_at=${paid_at} WHERE bolt11=\"${bolt11}\""
|
sql "UPDATE ln_invoice SET status=\"${status}\", pay_index=${pay_index}, msatoshi_received=${msatoshi_received}, paid_at=${paid_at} WHERE bolt11=\"${bolt11}\""
|
||||||
row=$(sql "SELECT id, label, bolt11, callback_url, payment_hash, msatoshi, status, pay_index, msatoshi_received, paid_at, description, expires_at FROM ln_invoice WHERE NOT calledback AND bolt11=\"${bolt11}\"")
|
row=$(sql "SELECT id, label, bolt11, callback_url, payment_hash, msatoshi, status, pay_index, msatoshi_received, paid_at, description, expires_at FROM ln_invoice WHERE NOT calledback AND bolt11=\"${bolt11}\"")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ spend() {
|
|||||||
|
|
||||||
local data
|
local data
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local address=$(echo "${request}" | jq ".address" | tr -d '"')
|
local address=$(echo "${request}" | jq -r ".address")
|
||||||
trace "[spend] address=${address}"
|
trace "[spend] address=${address}"
|
||||||
local amount=$(echo "${request}" | jq ".amount" | awk '{ printf "%.8f", $0 }')
|
local amount=$(echo "${request}" | jq ".amount" | awk '{ printf "%.8f", $0 }')
|
||||||
trace "[spend] amount=${amount}"
|
trace "[spend] amount=${amount}"
|
||||||
@@ -23,7 +23,7 @@ spend() {
|
|||||||
trace "[spend] response=${response}"
|
trace "[spend] response=${response}"
|
||||||
|
|
||||||
if [ "${returncode}" -eq 0 ]; then
|
if [ "${returncode}" -eq 0 ]; then
|
||||||
local txid=$(echo "${response}" | jq ".result" | tr -d '"')
|
local txid=$(echo "${response}" | jq -r ".result")
|
||||||
trace "[spend] txid=${txid}"
|
trace "[spend] txid=${txid}"
|
||||||
|
|
||||||
# Let's get transaction details on the spending wallet so that we have fee information
|
# Let's get transaction details on the spending wallet so that we have fee information
|
||||||
@@ -66,7 +66,7 @@ bumpfee() {
|
|||||||
trace "Entering bumpfee()..."
|
trace "Entering bumpfee()..."
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local txid=$(echo "${request}" | jq ".txid" | tr -d '"')
|
local txid=$(echo "${request}" | jq -r ".txid")
|
||||||
trace "[bumpfee] txid=${txid}"
|
trace "[bumpfee] txid=${txid}"
|
||||||
|
|
||||||
local confTarget
|
local confTarget
|
||||||
@@ -273,7 +273,7 @@ batchspend() {
|
|||||||
trace "[batchspend] response=${response}"
|
trace "[batchspend] response=${response}"
|
||||||
|
|
||||||
if [ "${returncode}" -eq 0 ]; then
|
if [ "${returncode}" -eq 0 ]; then
|
||||||
local txid=$(echo "${response}" | jq ".result" | tr -d '"')
|
local txid=$(echo "${response}" | jq -r ".result")
|
||||||
trace "[batchspend] txid=${txid}"
|
trace "[batchspend] txid=${txid}"
|
||||||
|
|
||||||
# Let's get transaction details on the spending wallet so that we have fee information
|
# Let's get transaction details on the spending wallet so that we have fee information
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ watchrequest() {
|
|||||||
|
|
||||||
local returncode
|
local returncode
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local address=$(echo "${request}" | jq ".address" | tr -d '"')
|
local address=$(echo "${request}" | jq -r ".address")
|
||||||
local cb0conf_url=$(echo "${request}" | jq ".unconfirmedCallbackURL" | tr -d '"')
|
local cb0conf_url=$(echo "${request}" | jq -r ".unconfirmedCallbackURL")
|
||||||
local cb1conf_url=$(echo "${request}" | jq ".confirmedCallbackURL" | tr -d '"')
|
local cb1conf_url=$(echo "${request}" | jq -r ".confirmedCallbackURL")
|
||||||
local imported
|
local imported
|
||||||
local inserted
|
local inserted
|
||||||
local id_inserted
|
local id_inserted
|
||||||
@@ -76,17 +76,17 @@ watchpub32request() {
|
|||||||
|
|
||||||
local returncode
|
local returncode
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local label=$(echo "${request}" | jq ".label" | tr -d '"')
|
local label=$(echo "${request}" | jq -r ".label")
|
||||||
trace "[watchpub32request] label=${label}"
|
trace "[watchpub32request] label=${label}"
|
||||||
local pub32=$(echo "${request}" | jq ".pub32" | tr -d '"')
|
local pub32=$(echo "${request}" | jq -r ".pub32")
|
||||||
trace "[watchpub32request] pub32=${pub32}"
|
trace "[watchpub32request] pub32=${pub32}"
|
||||||
local path=$(echo "${request}" | jq ".path" | tr -d '"')
|
local path=$(echo "${request}" | jq -r ".path")
|
||||||
trace "[watchpub32request] path=${path}"
|
trace "[watchpub32request] path=${path}"
|
||||||
local nstart=$(echo "${request}" | jq ".nstart")
|
local nstart=$(echo "${request}" | jq ".nstart")
|
||||||
trace "[watchpub32request] nstart=${nstart}"
|
trace "[watchpub32request] nstart=${nstart}"
|
||||||
local cb0conf_url=$(echo "${request}" | jq ".unconfirmedCallbackURL" | tr -d '"')
|
local cb0conf_url=$(echo "${request}" | jq -r ".unconfirmedCallbackURL")
|
||||||
trace "[watchpub32request] cb0conf_url=${cb0conf_url}"
|
trace "[watchpub32request] cb0conf_url=${cb0conf_url}"
|
||||||
local cb1conf_url=$(echo "${request}" | jq ".confirmedCallbackURL" | tr -d '"')
|
local cb1conf_url=$(echo "${request}" | jq -r ".confirmedCallbackURL")
|
||||||
trace "[watchpub32request] cb1conf_url=${cb1conf_url}"
|
trace "[watchpub32request] cb1conf_url=${cb1conf_url}"
|
||||||
|
|
||||||
watchpub32 ${label} ${pub32} ${path} ${nstart} ${cb0conf_url} ${cb1conf_url}
|
watchpub32 ${label} ${pub32} ${path} ${nstart} ${cb0conf_url} ${cb1conf_url}
|
||||||
@@ -297,11 +297,11 @@ watchtxidrequest() {
|
|||||||
local returncode
|
local returncode
|
||||||
local request=${1}
|
local request=${1}
|
||||||
trace "[watchtxidrequest] request=${request}"
|
trace "[watchtxidrequest] request=${request}"
|
||||||
local txid=$(echo "${request}" | jq ".txid" | tr -d '"')
|
local txid=$(echo "${request}" | jq -r ".txid")
|
||||||
trace "[watchtxidrequest] txid=${txid}"
|
trace "[watchtxidrequest] txid=${txid}"
|
||||||
local cb1conf_url=$(echo "${request}" | jq ".confirmedCallbackURL" | tr -d '"')
|
local cb1conf_url=$(echo "${request}" | jq -r ".confirmedCallbackURL")
|
||||||
trace "[watchtxidrequest] cb1conf_url=${cb1conf_url}"
|
trace "[watchtxidrequest] cb1conf_url=${cb1conf_url}"
|
||||||
local cbxconf_url=$(echo "${request}" | jq ".xconfCallbackURL" | tr -d '"')
|
local cbxconf_url=$(echo "${request}" | jq -r ".xconfCallbackURL")
|
||||||
trace "[watchtxidrequest] cbxconf_url=${cbxconf_url}"
|
trace "[watchtxidrequest] cbxconf_url=${cbxconf_url}"
|
||||||
local nbxconf=$(echo "${request}" | jq ".nbxconf")
|
local nbxconf=$(echo "${request}" | jq ".nbxconf")
|
||||||
trace "[watchtxidrequest] nbxconf=${nbxconf}"
|
trace "[watchtxidrequest] nbxconf=${nbxconf}"
|
||||||
|
|||||||
@@ -2,46 +2,45 @@
|
|||||||
|
|
||||||
. ./trace.sh
|
. ./trace.sh
|
||||||
|
|
||||||
derive()
|
derive() {
|
||||||
{
|
trace "Entering derive()..."
|
||||||
trace "Entering derive()..."
|
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local pub32=$(echo "${request}" | jq ".pub32" | tr -d '"')
|
local pub32=$(echo "${request}" | jq -r ".pub32")
|
||||||
local path=$(echo "${request}" | jq ".path" | tr -d '"')
|
local path=$(echo "${request}" | jq -r ".path")
|
||||||
|
|
||||||
local result
|
local result
|
||||||
local returncode
|
local returncode
|
||||||
trace "[derive] path=${path}"
|
trace "[derive] path=${path}"
|
||||||
trace "[derive] pub32=${pub32}"
|
trace "[derive] pub32=${pub32}"
|
||||||
|
|
||||||
result=$(ku -n BTC -s ${path} -a E:${pub32})
|
result=$(ku -n BTC -s ${path} -a E:${pub32})
|
||||||
|
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
trace "[derive] result=${result}"
|
trace "[derive] result=${result}"
|
||||||
|
|
||||||
local notfirst=false
|
local notfirst=false
|
||||||
|
|
||||||
echo -n "{\"addresses\":["
|
echo -n "{\"addresses\":["
|
||||||
|
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for address in ${result}
|
for address in ${result}
|
||||||
do
|
do
|
||||||
if ${notfirst}; then
|
if ${notfirst}; then
|
||||||
echo ","
|
echo ","
|
||||||
else
|
else
|
||||||
notfirst=true
|
notfirst=true
|
||||||
fi
|
fi
|
||||||
trace "[derive] address=${address}"
|
trace "[derive] address=${address}"
|
||||||
|
|
||||||
data="{\"address\":\"${address}\"}"
|
data="{\"address\":\"${address}\"}"
|
||||||
trace "[derive] data=${data}"
|
trace "[derive] data=${data}"
|
||||||
|
|
||||||
echo -n "${data}"
|
echo -n "${data}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "]}"
|
echo "]}"
|
||||||
|
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user