File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- if [ -z $1 ];
3+ if [ -z " $1 " ];
44then
55 echo " You must include the raw transaction hex as an argument." ;
66 exit ;
77fi
88
9- usedtxid=( $( bitcoin-cli decoderawtransaction $1 | jq -r ' .vin | .[] | .txid' ) )
10- usedvout=( $( bitcoin-cli decoderawtransaction $1 | jq -r ' .vin | .[] | .vout' ) )
11- 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}' )
12- btcout=$( bitcoin-cli decoderawtransaction $1 | jq -r ' .vout [] | .value' | awk ' {s+=$1} END {print s}' )
13- btcout_f=$( awk -v btcout=" $btcout " ' BEGIN { printf("%f \n", btcout) }' < /dev/null)
9+ mapfile -t usedtxid < <( bitcoin-cli decoderawtransaction " $1 " | jq -r ' .vin | .[] | .txid' )
10+ mapfile -t usedvout < <( bitcoin-cli decoderawtransaction " $1 " | jq -r ' .vin | .[] | .vout' )
11+ 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}' )
12+ btcout=$( bitcoin-cli decoderawtransaction " $1 " | jq -r ' .vout [] | .value' | awk ' {s+=$1} END {print "%.8f\n, s}' )
13+ btcout_f=$( awk -v btcout=" $btcout " ' BEGIN { printf("%.8f \n", btcout) }' < /dev/null)
1414echo " $btcin -$btcout_f " | /usr/bin/bc
You can’t perform that action at this time.
0 commit comments