Skip to content

Instantly share code, notes, and snippets.

@AGx10k
Created November 6, 2019 21:16
Show Gist options
  • Save AGx10k/9e711552359fdbd82385a682a276869d to your computer and use it in GitHub Desktop.
Save AGx10k/9e711552359fdbd82385a682a276869d to your computer and use it in GitHub Desktop.
#!/bin/bash
stegosout=$(echo "show balance" | /root/stegos/stegos --data-dir /data/stegos/data/)
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" | /root/stegos/stegos --data-dir /data/stegos/data/)
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" | /root/stegos/stegos --data-dir /data/stegos/data/)
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