Learning-Bitcoin-from-the-Command-Line icon indicating copy to clipboard operation
Learning-Bitcoin-from-the-Command-Line copied to clipboard

Fix bc error with scientific numbers in txfee_calc

Open mccwdev opened this issue 11 months ago • 0 comments

bitcoin-cli sometimes returns scientific numbers, which results in errors with bc

$ ./txfee-calc.sh $signedtx
(standard_in) 1: syntax error

$ echo "$btcin-$btcout_f"
8.859e-05-0.000088

# fixed by rewriting numbers with printf
$ echo $(printf '%.8f-%.8f' $btcin $btcout_f) | /usr/bin/bc
.00000059

mccwdev avatar Mar 25 '24 20:03 mccwdev