Skip to content

Instantly share code, notes, and snippets.

@sl-he
Last active February 11, 2021 10:37
Show Gist options
  • Save sl-he/c511a62068de4b060cf8b938e08f1f08 to your computer and use it in GitHub Desktop.
Save sl-he/c511a62068de4b060cf8b938e08f1f08 to your computer and use it in GitHub Desktop.
solana_withdrawal.sh
#!/bin/bash
BIN_FILE="/root/.local/share/solana/install/active_release/bin/solana"
MIN_BALANCE=65
WALLET="CXUGSygKbaiatbGxCpJ1XxaBbuuYFeXZVQkHgUs1E3b1"
$BIN_FILE withdraw-from-vote-account ~/solana/vote-account-keypair.json ~/solana/validator-keypair.json ALL --authorized-withdrawer ~/solana/vote-account-keypair.json --url http://127.0.0.1:8899
VOTE_BALANCE=$($BIN_FILE balance -k ~/solana/vote-account-keypair.json | awk '{print $1}')
echo -e "Vote Balance: $VOTE_BALANCE"
BALANCE=$($BIN_FILE balance -k ~/solana/validator-keypair.json | awk '{print $1}')
echo -e "Identity Balance: $BALANCE"
REWARD=$(echo "$BALANCE-$MIN_BALANCE" | bc)
if [[ $(bc -l <<< "$REWARD>0") -eq 1 ]]; then
echo "Let's withdraw $REWARD of REWARD tokens"
$BIN_FILE transfer -k ~/solana/validator-keypair.json --url http://127.0.0.1:8899 $WALLET $REWARD
else
echo "Reward is $REWARD"
fi
echo "DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment