shithub: riscv

ref: 9ec1a07af2537e5485524c8d079a07abfee6f96d
dir: /sys/src/cmd/btc/status/

View raw version
#!/bin/rc
wallet=$home/lib/wallet
btc=/mnt/btc
addr=`{awk ' { print $1 } ' < $wallet}
last=`{cat $btc/blocks}
cat $btc/addr/$addr/tx | sort +0n | uniq | tail -n 10 | awk '
	BEGIN {
		split("'^$"addr^'", addrs)
		for(x in addrs)
			my[addrs[x]] = 1
		last='^$last^'
	}
	{
		f = -1
		bal = 0
		for(i = 4; i <= NF; i++){
			if($i == "|")
				f = 1
			else if(my[$i]){
				i++
				bal += f*$i
			}else
				i++
		}
		d = last - $3
		printf "%s %+15.4f %c %s\n", $1, bal/1e8, (d > 9) ? 32 : (d + 48), $2
	}
'
echo '================================================================================================'
cat $btc/addr/$addr/balance | awk ' { a += $1 } END { printf "balance %18.4f BTC\n", a/1e8 } '