merge
This commit is contained in:
commit
667abe102c
4 changed files with 47 additions and 6 deletions
|
@ -4,6 +4,7 @@ typedef struct DirEntry DirEntry;
|
|||
enum
|
||||
{
|
||||
TROOT,
|
||||
TBLOCKS,
|
||||
TADDR,
|
||||
TADDRSUB,
|
||||
TADDRTX,
|
||||
|
|
|
@ -10,13 +10,20 @@ Reqqueue *queue;
|
|||
static char *addrwalk(Fid *, char *, Qid *);
|
||||
char *balancestr(DirEntry *, Aux *);
|
||||
char *txstr(DirEntry *, Aux *);
|
||||
char *blocksstr(DirEntry *, Aux *);
|
||||
|
||||
DirEntry entr[] = {
|
||||
[TROOT] = {
|
||||
.name = "",
|
||||
.qid = {TROOT, 0, QTDIR},
|
||||
.par = TROOT,
|
||||
.sub = {TADDR},
|
||||
.sub = {TADDR, TBLOCKS},
|
||||
},
|
||||
[TBLOCKS] = {
|
||||
.name = "blocks",
|
||||
.qid = {TBLOCKS, 0, 0},
|
||||
.par = TROOT,
|
||||
.str = blocksstr,
|
||||
},
|
||||
[TADDR] = {
|
||||
.name = "addr",
|
||||
|
|
|
@ -74,14 +74,16 @@ parsetx(String *str, JSON *j, JSON *l)
|
|||
char *
|
||||
balancestr(DirEntry *, Aux *a)
|
||||
{
|
||||
char *s;
|
||||
char buf[512];
|
||||
|
||||
sprint(buf, "http://blockchain.info/q/addressbalance/%s", a->addr);
|
||||
s = graburl(buf);
|
||||
if(s == nil)
|
||||
return nil;
|
||||
return s;
|
||||
return graburl(buf);
|
||||
}
|
||||
|
||||
char *
|
||||
blocksstr(DirEntry *, Aux *)
|
||||
{
|
||||
return graburl("http://blockchain.info/q/getblockcount");
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
31
sys/src/cmd/btc/status
Executable file
31
sys/src/cmd/btc/status
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/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 } '
|
||||
|
Loading…
Reference in a new issue