Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zbalance: quickly get your zcash addresses (taddr and zaddr) and their balances
#!/bin/sh
# zbalance: quickly get your zcash addresses (taddr and zaddr) and their balances.
# REQUIRES zcash-cli (https://z.cash) AND jq (https://stedolan.github.io/jq)
zaddr_withbalance () {
while read a
do echo $(zcash-cli z_getbalance $a) $a
done
}
taddr_withbalance () {
unspent=$(zcash-cli listunspent | jq -r '.[] | "\(.amount) \(.address)"')
while read a
do
row=$(echo $unspent | grep " $a\$")
if test $? -eq 0
then echo $row
else echo 0 $a
fi
done
}
getbalances () {
( zcash-cli listreceivedbyaddress 0 true | jq -r '.[] | .address' ; \
zcash-cli listunspent | jq -r '.[] | .address' ) \
| sort -u | taddr_withbalance
zcash-cli z_listaddresses | jq -r '.[]' | zaddr_withbalance
}
prettybalances () {
while read line
do
bal=$( echo $line | cut -d' ' -f1)
addr=$(echo $line | cut -d' ' -f2)
echo $(printf %.8f $bal) $addr
done
}
getbalances | prettybalances
@lucasem

This comment has been minimized.

Copy link
Owner Author

@lucasem lucasem commented Sep 10, 2017

See lucasem/cryptocurrency-things for an up-to-date version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.