From eadefbcf0ccd7434f248d82fa5178da74bc67f96 Mon Sep 17 00:00:00 2001 From: psqnt Date: Sun, 1 Nov 2020 08:43:04 -0500 Subject: [PATCH 1/2] fix for jq auto formatting decimals jq auto formats decimals to scientific notation so the calculation on the last line of the script fails on a syntax error: For example: ``` $ echo "0.0001 - 9.5e-05" | /usr/bin/bc (standard_in) 1: syntax error ``` vs this: ``` $ echo "0.0001 - 0.000095" | /usr/bin/bc .000005 ``` --- src/04_2_i_txfee-calc.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/04_2_i_txfee-calc.sh b/src/04_2_i_txfee-calc.sh index b031ab6..3a7384f 100644 --- a/src/04_2_i_txfee-calc.sh +++ b/src/04_2_i_txfee-calc.sh @@ -10,4 +10,5 @@ usedtxid=($(bitcoin-cli decoderawtransaction $1 | jq -r '.vin | .[] | .txid')) usedvout=($(bitcoin-cli decoderawtransaction $1 | jq -r '.vin | .[] | .vout')) btcin=$(for ((i=0; i<${#usedtxid[*]}; i++)); do txid=${usedtxid[i]}; vout=${usedvout[i]}; bitcoin-cli listunspent | jq -r '.[] | select (.txid | contains("'${txid}'")) | select(.vout | contains('$vout')) | .amount'; done | awk '{s+=$1} END {print s}') btcout=$(bitcoin-cli decoderawtransaction $1 | jq -r '.vout [] | .value' | awk '{s+=$1} END {print s}') +btcout_f=$(awk -v btcout="$btcout" 'BEGIN { printf("%f\n", btcout) }' Date: Sun, 1 Nov 2020 08:45:50 -0500 Subject: [PATCH 2/2] Update 04_2_i_txfee-calc.sh use $btcout_f --- src/04_2_i_txfee-calc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/04_2_i_txfee-calc.sh b/src/04_2_i_txfee-calc.sh index 3a7384f..64a884a 100644 --- a/src/04_2_i_txfee-calc.sh +++ b/src/04_2_i_txfee-calc.sh @@ -11,4 +11,4 @@ usedvout=($(bitcoin-cli decoderawtransaction $1 | jq -r '.vin | .[] | .vout')) btcin=$(for ((i=0; i<${#usedtxid[*]}; i++)); do txid=${usedtxid[i]}; vout=${usedvout[i]}; bitcoin-cli listunspent | jq -r '.[] | select (.txid | contains("'${txid}'")) | select(.vout | contains('$vout')) | .amount'; done | awk '{s+=$1} END {print s}') btcout=$(bitcoin-cli decoderawtransaction $1 | jq -r '.vout [] | .value' | awk '{s+=$1} END {print s}') btcout_f=$(awk -v btcout="$btcout" 'BEGIN { printf("%f\n", btcout) }'