#!/bin/bash
curl -s localhost:46941/json_rpc \
  -d '{"jsonrpc":"2.0","id":"0","method":"getlastblockheader"}' \
  -H 'Content-Type: application/json' | python3 -c "
import sys,json
b=json.load(sys.stdin)['result']['block_header']
btype = 'PoW' if b.get('major_version',0)==3 else 'PoS'
print(f'Latest Block #{b[\"height\"]:,}')
print(f'  Type:       {btype}')
print(f'  Reward:     {b[\"reward\"]/1e12:.4f} LTHN')
print(f'  Difficulty:  {b[\"difficulty\"]:,}')
print(f'  Hash:       {b[\"hash\"][:20]}...')
"
