mirror of
				https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
				synced 2025-10-31 10:27:29 +00:00 
			
		
		
		
	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 ```
This commit is contained in:
		
							parent
							
								
									2323ed4e1a
								
							
						
					
					
						commit
						eadefbcf0c
					
				| @ -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) }' </dev/null) | ||||
| echo "$btcin-$btcout"| /usr/bin/bc | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user