BlockchainCommons / Learning-Bitcoin-from-the-Command-Line

A complete course for learning Bitcoin programming and usage from the command
3.11k stars 754 forks source link

Fix bc error with scientific numbers in txfee_calc #611

Open mccwdev opened 5 months ago

mccwdev commented 5 months ago

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