btc-tx-cost (481B)
1 #!/usr/bin/env bash 2 3 usage () { 4 printf "usage: %s <inputs> <outputs> <sat/b>" "$0" 5 exit 1 6 } 7 8 [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] && usage 9 10 inputs="$1" 11 outputs="$2" 12 satsb="$3" 13 14 15 btc=$(printf "(%d * 180 + %d * 34 + 10) * %d * 0.00000001 \n" \ 16 "$inputs" "$outputs" "$satsb" | bc -l) 17 18 mbtc=$(printf "%f * 1000\n" "$btc" | bc -l) 19 20 price=$(btc) 21 cad=$(printf "%f * %f\n" "$btc" "$price" | bc -l) 22 23 printf "%f BTC\n%f mBTC\n%f CAD (@ ${price}/btc)\n" "$btc" "$mbtc" "$cad"