-
-
Save mr0wnage/d8e4a817a490628678b59aa50449898b to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
stegosout=$(echo "show balance" | /data/stegos/stegos --data-dir /data/stegos/db) | |
stegosexit=$? | |
if [ $stegosexit -gt 0 ]; then | |
echo stegosout: "$stegosout" | |
exit $stegosexit | |
fi | |
if grep -q -i error <<< "$stegosout"; then | |
echo stegos returned error: | |
echo "$stegosout" | |
exit 10 | |
fi | |
public_balance=$(echo "$stegosout" | grep -w public_payment -A2 | grep available | awk '{ print $2 }') | |
re='^[0-9]+$' | |
if ! [[ $public_balance =~ $re ]] ; then | |
echo "public_balance=$public_balance" | |
echo "stegosout=$stegosout" | |
echo "error: \$public_balance is Not a number" >&2; exit 1 | |
fi | |
if [ $public_balance -gt 4999999 ]; then | |
stegosout=$(echo "cloak" | /data/stegos/stegos --data-dir /data/stegos/db) | |
stegosexit=$? | |
if [ $stegosexit -gt 0 ]; then | |
echo stegosout: "$stegosout" | |
exit $stegosexit | |
fi | |
echo "$stegosout" | grep transaction_created -A7 #### check what output cloak does | |
fi | |
balance=$(echo "$stegosout" | grep -w payment -A2 | grep available | awk '{ print $2 }') | |
re='^[0-9]+$' | |
if ! [[ $balance =~ $re ]] ; then | |
echo "balance=$balance" | |
echo "stegosout=$stegosout" | |
echo "error: \$balance is Not a number" >&2; exit 1 | |
fi | |
if [ $balance -gt 4999999 ]; then | |
stegosout=$(echo "stake $balance" | /data/stegos/stegos --data-dir /data/stegos/db) | |
stegosexit=$? | |
if [ $stegosexit -gt 0 ]; then | |
echo stegosout: "$stegosout" | |
exit $stegosexit | |
fi | |
echo "$stegosout" | grep transaction_created -A7 | |
else | |
echo balance=$balance will not stake | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment