mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-19 13:44:53 +01:00
Fixed sqlite3 replaceable bool and rawtx with LF in DB
This commit is contained in:
@@ -441,7 +441,7 @@ batchspend() {
|
|||||||
|
|
||||||
# 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
|
||||||
tx_details=$(get_transaction ${txid} "spender")
|
tx_details=$(get_transaction ${txid} "spender")
|
||||||
tx_raw_details=$(get_rawtransaction ${txid})
|
tx_raw_details=$(get_rawtransaction ${txid} | tr -d '\n')
|
||||||
|
|
||||||
# Amounts and fees are negative when spending so we absolute those fields
|
# Amounts and fees are negative when spending so we absolute those fields
|
||||||
local tx_hash=$(echo "${tx_raw_details}" | jq '.result.hash')
|
local tx_hash=$(echo "${tx_raw_details}" | jq '.result.hash')
|
||||||
@@ -456,13 +456,13 @@ batchspend() {
|
|||||||
local fees=$(echo "${tx_details}" | jq '.result.fee | fabs' | awk '{ printf "%.8f", $0 }')
|
local fees=$(echo "${tx_details}" | jq '.result.fee | fabs' | awk '{ printf "%.8f", $0 }')
|
||||||
# Sometimes raw tx are too long to be passed as paramater, so let's write
|
# Sometimes raw tx are too long to be passed as paramater, so let's write
|
||||||
# it to a temp file for it to be read by sqlite3 and then delete the file
|
# it to a temp file for it to be read by sqlite3 and then delete the file
|
||||||
echo "${tx_raw_details}" > batchspend-rawtx-${txid}.blob
|
echo "${tx_raw_details}" > batchspend-rawtx-${txid}-$$.blob
|
||||||
|
|
||||||
# Get the info on the batch before setting it to done
|
# Get the info on the batch before setting it to done
|
||||||
row=$(sql "SELECT COUNT(id), COALESCE(MIN(inserted_ts), 0), COALESCE(SUM(amount), 0.00000000) FROM recipient WHERE tx_id IS NULL AND batcher_id=${batcher_id}")
|
row=$(sql "SELECT COUNT(id), COALESCE(MIN(inserted_ts), 0), COALESCE(SUM(amount), 0.00000000) FROM recipient WHERE tx_id IS NULL AND batcher_id=${batcher_id}")
|
||||||
|
|
||||||
# Let's insert the txid in our little DB -- then we'll already have it when receiving confirmation
|
# Let's insert the txid in our little DB -- then we'll already have it when receiving confirmation
|
||||||
id_inserted=$(sql "INSERT OR IGNORE INTO tx (txid, hash, confirmations, timereceived, fee, size, vsize, is_replaceable, conf_target, raw_tx) VALUES (\"${txid}\", ${tx_hash}, 0, ${tx_ts_firstseen}, ${fees}, ${tx_size}, ${tx_vsize}, ${tx_replaceable}, ${conf_target}, readfile('batchspend-rawtx-${txid}.blob')); SELECT LAST_INSERT_ROWID();")
|
id_inserted=$(sql "INSERT OR IGNORE INTO tx (txid, hash, confirmations, timereceived, fee, size, vsize, is_replaceable, conf_target, raw_tx) VALUES (\"${txid}\", ${tx_hash}, 0, ${tx_ts_firstseen}, ${fees}, ${tx_size}, ${tx_vsize}, ${tx_replaceable}, ${conf_target}, readfile('batchspend-rawtx-${txid}-$$.blob')); SELECT LAST_INSERT_ROWID();")
|
||||||
returncode=$?
|
returncode=$?
|
||||||
trace_rc ${returncode}
|
trace_rc ${returncode}
|
||||||
if [ "${returncode}" -eq 0 ]; then
|
if [ "${returncode}" -eq 0 ]; then
|
||||||
@@ -487,7 +487,7 @@ batchspend() {
|
|||||||
response="${response},\"error\":null}"
|
response="${response},\"error\":null}"
|
||||||
|
|
||||||
# Delete the temp file containing the raw tx (see above)
|
# Delete the temp file containing the raw tx (see above)
|
||||||
rm batchspend-rawtx-${txid}.blob
|
rm batchspend-rawtx-${txid}-$$.blob
|
||||||
|
|
||||||
batch_webhooks "[${webhooks_data}]" '"batcherId":'${batcher_id}',"confTarget":'${conf_target}',"nbOutputs":'${count}',"oldest":"'${oldest}'","total":'${total}',"status":"accepted","txid":"'${txid}'","hash":'${tx_hash}',"details":{"firstseen":'${tx_ts_firstseen}',"size":'${tx_size}',"vsize":'${tx_vsize}',"replaceable":'${tx_replaceable}',"fee":'${fees}'}'
|
batch_webhooks "[${webhooks_data}]" '"batcherId":'${batcher_id}',"confTarget":'${conf_target}',"nbOutputs":'${count}',"oldest":"'${oldest}'","total":'${total}',"status":"accepted","txid":"'${txid}'","hash":'${tx_hash}',"details":{"firstseen":'${tx_ts_firstseen}',"size":'${tx_size}',"vsize":'${tx_vsize}',"replaceable":'${tx_replaceable}',"fee":'${fees}'}'
|
||||||
|
|
||||||
@@ -826,7 +826,7 @@ getbatchdetails() {
|
|||||||
# Using txid
|
# Using txid
|
||||||
outerclause="AND r.tx_id=${tx_id}"
|
outerclause="AND r.tx_id=${tx_id}"
|
||||||
|
|
||||||
tx=$(sql "SELECT '\"txid\":\"' || txid || '\",\"hash\":\"' || hash || '\",\"details\":{\"firstseen\":' || timereceived || ',\"size\":' || size || ',\"vsize\":' || vsize || ',\"replaceable\":' || (CASE WHEN is_replaceable>0 THEN \"\\\"true\\\"\") || ',\"fee\":' || fee || '}' FROM tx WHERE id=${tx_id}")
|
tx=$(sql "SELECT '\"txid\":\"' || txid || '\",\"hash\":\"' || hash || '\",\"details\":{\"firstseen\":' || timereceived || ',\"size\":' || size || ',\"vsize\":' || vsize || ',\"replaceable\":' || CASE is_replaceable WHEN 1 THEN 'true' ELSE 'false' END || ',\"fee\":' || fee || '}' FROM tx WHERE id=${tx_id}")
|
||||||
else
|
else
|
||||||
# null txid
|
# null txid
|
||||||
outerclause="AND r.tx_id IS NULL"
|
outerclause="AND r.tx_id IS NULL"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ compute_vin_total_amount()
|
|||||||
vin_raw_tx=$(sql "SELECT raw_tx FROM tx WHERE txid=\"${vin_txid}\"")
|
vin_raw_tx=$(sql "SELECT raw_tx FROM tx WHERE txid=\"${vin_txid}\"")
|
||||||
if [ -z "${vin_raw_tx}" ]; then
|
if [ -z "${vin_raw_tx}" ]; then
|
||||||
txid_already_inserted=false
|
txid_already_inserted=false
|
||||||
vin_raw_tx=$(get_rawtransaction "${vin_txid}")
|
vin_raw_tx=$(get_rawtransaction "${vin_txid}" | tr -d '\n')
|
||||||
returncode=$?
|
returncode=$?
|
||||||
if [ "${returncode}" -ne 0 ]; then
|
if [ "${returncode}" -ne 0 ]; then
|
||||||
return ${returncode}
|
return ${returncode}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ confirmation() {
|
|||||||
|
|
||||||
local tx=$(sql "SELECT id FROM tx WHERE txid=\"${txid}\"")
|
local tx=$(sql "SELECT id FROM tx WHERE txid=\"${txid}\"")
|
||||||
local id_inserted
|
local id_inserted
|
||||||
local tx_raw_details=$(get_rawtransaction ${txid})
|
local tx_raw_details=$(get_rawtransaction ${txid} | tr -d '\n')
|
||||||
local tx_nb_conf=$(echo "${tx_details}" | jq -r '.result.confirmations // 0')
|
local tx_nb_conf=$(echo "${tx_details}" | jq -r '.result.confirmations // 0')
|
||||||
|
|
||||||
# Sometimes raw tx are too long to be passed as paramater, so let's write
|
# Sometimes raw tx are too long to be passed as paramater, so let's write
|
||||||
|
|||||||
@@ -113,11 +113,11 @@ testbatching() {
|
|||||||
id2=$(echo "${response}" | jq ".result.batcherId")
|
id2=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id2}"
|
echo "batcherId=${id2}"
|
||||||
if [ "${id2}" -ne "1" ]; then
|
if [ "${id2}" -ne "1" ]; then
|
||||||
exit 40
|
exit 47
|
||||||
fi
|
fi
|
||||||
id2=$(echo "${response}" | jq -e ".result.outputId")
|
id2=$(echo "${response}" | jq -e ".result.outputId")
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 42
|
exit 50
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id2}"
|
echo "outputId=${id2}"
|
||||||
echo "Tested addtobatch."
|
echo "Tested addtobatch."
|
||||||
@@ -128,7 +128,7 @@ testbatching() {
|
|||||||
echo "response=${response}"
|
echo "response=${response}"
|
||||||
echo "${response}" | jq -e ".error"
|
echo "${response}" | jq -e ".error"
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 44
|
exit 55
|
||||||
fi
|
fi
|
||||||
echo "Tested batchspend."
|
echo "Tested batchspend."
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ testbatching() {
|
|||||||
id=$(echo "${response}" | jq ".result.batcherId")
|
id=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id}"
|
echo "batcherId=${id}"
|
||||||
if [ "${id}" -ne "1" ]; then
|
if [ "${id}" -ne "1" ]; then
|
||||||
exit 50
|
exit 60
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"outputId":'${id2}'}' localhost:8888/removefrombatch)
|
response=$(curl -sd '{"outputId":'${id2}'}' localhost:8888/removefrombatch)
|
||||||
@@ -155,7 +155,7 @@ testbatching() {
|
|||||||
id=$(echo "${response}" | jq ".result.batcherId")
|
id=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id}"
|
echo "batcherId=${id}"
|
||||||
if [ "${id}" -ne "1" ]; then
|
if [ "${id}" -ne "1" ]; then
|
||||||
exit 54
|
exit 64
|
||||||
fi
|
fi
|
||||||
echo "Tested removefrombatch."
|
echo "Tested removefrombatch."
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ testbatching() {
|
|||||||
data2=$(echo "${response}" | jq ".result.nbOutputs")
|
data2=$(echo "${response}" | jq ".result.nbOutputs")
|
||||||
echo "nbOutputs=${data2}"
|
echo "nbOutputs=${data2}"
|
||||||
if [ "${data2}" -ne "$((${data}-2))" ]; then
|
if [ "${data2}" -ne "$((${data}-2))" ]; then
|
||||||
exit 58
|
exit 68
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
echo "Tested getbatchdetails."
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ testbatching() {
|
|||||||
echo "response=${response}"
|
echo "response=${response}"
|
||||||
id=$(echo "${response}" | jq -e ".result.batcherId")
|
id=$(echo "${response}" | jq -e ".result.batcherId")
|
||||||
if [ "$?" -ne "0" ]; then
|
if [ "$?" -ne "0" ]; then
|
||||||
exit 60
|
exit 70
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# List batchers (should show at least default and testbatcher batchers)
|
# List batchers (should show at least default and testbatcher batchers)
|
||||||
@@ -199,7 +199,7 @@ testbatching() {
|
|||||||
id=$(echo "${response}" | jq '.result[] | select(.batcherLabel == "testbatcher") | .batcherId')
|
id=$(echo "${response}" | jq '.result[] | select(.batcherLabel == "testbatcher") | .batcherId')
|
||||||
echo "batcherId=${id}"
|
echo "batcherId=${id}"
|
||||||
if [ -z "${id}" ]; then
|
if [ -z "${id}" ]; then
|
||||||
exit 70
|
exit 75
|
||||||
fi
|
fi
|
||||||
echo "Tested listbatchers."
|
echo "Tested listbatchers."
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ testbatching() {
|
|||||||
fi
|
fi
|
||||||
echo "${response}" | jq -e ".result.outputs"
|
echo "${response}" | jq -e ".result.outputs"
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 32
|
exit 110
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"batcherId":'${id}'}' localhost:8888/getbatchdetails)
|
response=$(curl -sd '{"batcherId":'${id}'}' localhost:8888/getbatchdetails)
|
||||||
@@ -241,11 +241,11 @@ testbatching() {
|
|||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
echo "batcherLabel=${data}"
|
||||||
if [ "${data}" != "testbatcher" ]; then
|
if [ "${data}" != "testbatcher" ]; then
|
||||||
exit 35
|
exit 120
|
||||||
fi
|
fi
|
||||||
echo "${response}" | jq -e ".result.outputs"
|
echo "${response}" | jq -e ".result.outputs"
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 37
|
exit 130
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
echo "Tested getbatchdetails."
|
||||||
|
|
||||||
@@ -258,11 +258,11 @@ testbatching() {
|
|||||||
data=$(echo "${response}" | jq ".result.batcherId")
|
data=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${data}"
|
echo "batcherId=${data}"
|
||||||
if [ "${data}" -ne "${id}" ]; then
|
if [ "${data}" -ne "${id}" ]; then
|
||||||
exit 40
|
exit 140
|
||||||
fi
|
fi
|
||||||
id2=$(echo "${response}" | jq -e ".result.outputId")
|
id2=$(echo "${response}" | jq -e ".result.outputId")
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 42
|
exit 142
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id2}"
|
echo "outputId=${id2}"
|
||||||
|
|
||||||
@@ -273,11 +273,11 @@ testbatching() {
|
|||||||
data=$(echo "${response}" | jq ".result.batcherId")
|
data=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${data}"
|
echo "batcherId=${data}"
|
||||||
if [ "${data}" -ne "${id}" ]; then
|
if [ "${data}" -ne "${id}" ]; then
|
||||||
exit 40
|
exit 150
|
||||||
fi
|
fi
|
||||||
id2=$(echo "${response}" | jq -e ".result.outputId")
|
id2=$(echo "${response}" | jq -e ".result.outputId")
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 42
|
exit 152
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id2}"
|
echo "outputId=${id2}"
|
||||||
echo "Tested addtobatch."
|
echo "Tested addtobatch."
|
||||||
@@ -288,12 +288,12 @@ testbatching() {
|
|||||||
echo "response=${response}"
|
echo "response=${response}"
|
||||||
data2=$(echo "${response}" | jq -e ".result.txid")
|
data2=$(echo "${response}" | jq -e ".result.txid")
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 44
|
exit 160
|
||||||
fi
|
fi
|
||||||
echo "txid=${data2}"
|
echo "txid=${data2}"
|
||||||
data=$(echo "${response}" | jq ".result.outputs | length")
|
data=$(echo "${response}" | jq ".result.outputs | length")
|
||||||
if [ "${data}" -ne "2" ]; then
|
if [ "${data}" -ne "2" ]; then
|
||||||
exit 42
|
exit 162
|
||||||
fi
|
fi
|
||||||
echo "Tested batchspend."
|
echo "Tested batchspend."
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ testbatching() {
|
|||||||
data=$(echo "${response}" | jq ".result.nbOutputs")
|
data=$(echo "${response}" | jq ".result.nbOutputs")
|
||||||
echo "nbOutputs=${data}"
|
echo "nbOutputs=${data}"
|
||||||
if [ "${data}" -ne "2" ]; then
|
if [ "${data}" -ne "2" ]; then
|
||||||
exit 42
|
exit 170
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
echo "Tested getbatchdetails."
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ spend() {
|
|||||||
|
|
||||||
# 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
|
||||||
tx_details=$(get_transaction ${txid} "spender")
|
tx_details=$(get_transaction ${txid} "spender")
|
||||||
tx_raw_details=$(get_rawtransaction ${txid})
|
tx_raw_details=$(get_rawtransaction ${txid} | tr -d '\n')
|
||||||
|
|
||||||
# Amounts and fees are negative when spending so we absolute those fields
|
# Amounts and fees are negative when spending so we absolute those fields
|
||||||
local tx_hash=$(echo "${tx_raw_details}" | jq '.result.hash')
|
local tx_hash=$(echo "${tx_raw_details}" | jq '.result.hash')
|
||||||
|
|||||||
Reference in New Issue
Block a user