File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ read -r -d ' ' help << EOM
4+ $0 - helper script for displaying miner of a mined block.
5+
6+ Options:
7+
8+ -h Display this message.
9+
10+ --height Specify blockheight.
11+ --hash Specify blockhash.
12+ EOM
13+
14+ while getopts " :h-:" optchar; do
15+ case " ${optchar} " in
16+ -)
17+ case " ${OPTARG} " in
18+ hash)
19+ blockhash=" ${! OPTIND} " ; OPTIND=$(( $OPTIND + 1 ))
20+ ;;
21+ height)
22+ blockheight=" ${! OPTIND} " ; OPTIND=$(( $OPTIND + 1 ))
23+ blockhash=$( lbcctl getblockhash ${blockheight} )
24+ ;;
25+ * ) echo " Unknown long option --${OPTARG} " >&2 ; exit -2 ;;
26+ esac
27+ ;;
28+ h) printf " ${help} \n\n" ; exit 2;;
29+ * ) echo " Unknown option -${OPTARG} " >&2 ; exit -2;;
30+ esac
31+ done
32+
33+
34+ block=$( lbcctl getblock $blockhash )
35+ blockheight=$( lbcctl getblock $blockhash | jq -r .height)
36+
37+ coinbase_txid=$( echo ${block} | jq -r ' .tx[0]' )
38+ coinbase_raw=$( lbcctl getrawtransaction ${coinbase_txid} 1)
39+ coinbase=$( echo ${coinbase_raw} | jq ' .vin[0].coinbase' )
40+ miner=$( echo ${coinbase} | grep -o ' 2f.*2f' | xxd -r -p | strings)
41+
42+ echo ${blockheight} : ${blockhash} : ${miner}
You can’t perform that action at this time.
0 commit comments