Created
March 31, 2017 19:52
-
-
Save lorepozo/eadd6340ac1a96ad85ca8a09caf9f497 to your computer and use it in GitHub Desktop.
zbalance: quickly get your zcash addresses (taddr and zaddr) and their balances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See lucasem/cryptocurrency-things for an up-to-date version.