Created
November 29, 2021 10:43
-
-
Save anilcse/cc2c9ca928cabd4ea24a6c88b29ebc55 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
#!/usr/bin/env bash | |
export OSMOSIS_CHAIN_ID="osmosis-1" | |
export OSMOSIS_BROADCAST_MODE="sync" | |
export NODE="http://143.198.234.89:26657" | |
HACKED_ACCOUNT="osmo1vcgt5wz8jtp99lkunn4axwdyt3lkd586y4utna" | |
RECOVER_ACCOUNT="" | |
declare -a unbond_times=(2021-12-01T20:06:18.759183863Z) | |
declare -a unbond_amounts=(199000000) | |
account_sequence(){ | |
osmosisd query account "$HACKED_ACCOUNT" -o json --node http://143.198.234.89:26657 --chain-id osmosis-1 | jq -r '.sequence' | |
} | |
account_number(){ | |
osmosisd query account "$HACKED_ACCOUNT" -o json --node http://143.198.234.89:26657 --chain-id osmosis-1 | jq -r '.account_number' | |
} | |
# get sequence number | |
sequence=$(account_sequence) | |
acc_num=$(account_number) | |
for i in {0..50..1} | |
do | |
acc_seq=$(( $sequence + $i )) | |
osmosisd tx bank send $HACKED_ACCOUNT $RECOVER_ACCOUNT 199000000uosmo --chain-id osmosis-1 --offline --from $RECOVER_ACCOUNT --sequence $acc_seq --generate-only > unsinged.txt | |
osmosisd tx sign unsinged.txt --from $HACKED_ACCOUNT --chain-id osmosis-1 --offline --account-number $acc_num --sequence $acc_seq > "tx-$acc_seq-$unbond_amounts.json" | |
done |
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
#!/usr/bin/env bash | |
export OSMOSIS_CHAIN_ID="osmosis-1" | |
export OSMOSIS_BROADCAST_MODE="sync" | |
HACKED_ACCOUNT="osmo1vcgt5wz8jtp99lkunn4axwdyt3lkd586y4utna" | |
declare -a unbond_times=(2021-12-01T20:06:18.759183863Z) | |
declare -a unbond_amounts=(199000000) | |
# broadcast tx +- 30 seconds around unbond time | |
declare -i pad=30 | |
# sleep 1/2 second between broadcasts | |
broadcast_delay="0.5" | |
declare -a unbond_secs | |
for time in "${unbond_times[@]}"; do | |
unbond_secs+=( $(date --date="$time" "+%s") ) | |
done | |
run_osmosis() { | |
# Edit to suit your system if necessary, for example: | |
# | |
# /usr/local/bin/osmosisd --node "my.host:26657" "$@" | |
osmosisd "$@" | |
} | |
account_sequence(){ | |
run_osmosis query account "$HACKED_ACCOUNT" -o json | jq -r '.sequence' | |
} | |
handle_target(){ | |
declare -li now=$1 | |
declare -li target=$2 | |
declare -li amount=$3 | |
# sleep until $pad seconds before unbond | |
if [ $((now + pad)) -lt $target ]; then | |
declare -li delta=$((target - now - pad)) | |
echo "$target $amount: waiting $delta seconds..." | |
sleep $delta | |
fi | |
# loop until $pad seconds after unbond | |
while [ $((now - pad)) -lt $target ]; do | |
# get sequence number | |
declare -li sequence=$(account_sequence) | |
# broadcast appropriate tx | |
run_osmosis tx broadcast "tx-$sequence-$amount.json" | |
# sleep $delay | |
sleep "$broadcast_delay" | |
now=$(date "+%s") | |
done | |
} | |
run_targets() { | |
for target in "${unbond_secs[@]}"; do | |
declare -li now=$(date "+%s") | |
declare -li amount=${unbond_amounts[0]} | |
unbond_amounts=( "${unbond_amounts[@]:1}" ) | |
if [ $((now - pad)) -gt $target ]; then | |
echo "skipping $target $amount" | |
continue | |
fi | |
handle_target $now $target $amount | |
done | |
} | |
ensure_runnable() { | |
if ! run_osmosis status >/dev/null 2>&1 ; then | |
echo "osmosis must be installed and configured." | |
exit 1 | |
fi | |
if ! which jq >/dev/null 2>&1; then | |
echo "jq must be installed." | |
exit 1 | |
fi | |
echo "system ready. continuing...." | |
} | |
ensure_runnable | |
run_targets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment