Skip to content

Instantly share code, notes, and snippets.

@mr0wnage
Forked from AGx10k/solana-restake-daily.sh
Last active February 4, 2021 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr0wnage/ed53c51fa4d20701e715d99338f4d264 to your computer and use it in GitHub Desktop.
Save mr0wnage/ed53c51fa4d20701e715d99338f4d264 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
vote_account="/root/solana/vote-account-keypair.json"
identity_account="/root/solana/validator-keypair.json"
new_stake="/root/solana/validator-stake-keypair-$(printf '%(%Y-%m-%d)T').json"
min_vote_balance=100
available_for_withdraw=$(solana balance $vote_account | awk -F\. '{print $1}')
re='^[0-9]+$'
if ! [[ $available_for_withdraw =~ $re ]] ; then
echo "error: \"$available_for_withdraw\"Not a number" >&2; exit 1
fi
available_for_withdraw=$(($available_for_withdraw - $min_vote_balance))
if (( $available_for_withdraw < 0 )); then
echo "too small withdraw=$available_for_withdraw"; exit 2
fi
echo "available for withdraw=$available_for_withdraw"
solana withdraw-from-vote-account $vote_account $identity_account $available_for_withdraw --authorized-withdrawer $vote_account
solana-keygen new -o $new_stake
echo backup new key:
echo $new_stake: && cat $new_stake &&echo
solana create-stake-account $new_stake $available_for_withdraw
solana delegate-stake $new_stake $vote_account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment