From af94d118f603edcadf45083627ece2c65ddecc74 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Fri, 24 May 2024 08:22:37 -0500 Subject: [PATCH] add updated reward distribution script and .conf file template --- scripts/rewards/sendrewards.conf | 4 ++++ scripts/rewards/sendrewards.sh | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 scripts/rewards/sendrewards.conf create mode 100755 scripts/rewards/sendrewards.sh diff --git a/scripts/rewards/sendrewards.conf b/scripts/rewards/sendrewards.conf new file mode 100644 index 0000000000..8837732fc1 --- /dev/null +++ b/scripts/rewards/sendrewards.conf @@ -0,0 +1,4 @@ +WALLET_FILE="$HOME/.skycoin/wallets/.wlt" +FROM_ADDRESS="HWteH5YSjqax9dnvkHsFPU4JzHiTxugbet" +REWARD_WL_SK= +REWARD_SYS_URL="dmsg://036a70e6956061778e1883e928c1236189db14dfd446df23d83e45c321b330c91f:80" diff --git a/scripts/rewards/sendrewards.sh b/scripts/rewards/sendrewards.sh new file mode 100755 index 0000000000..cb8ec9acaf --- /dev/null +++ b/scripts/rewards/sendrewards.sh @@ -0,0 +1,22 @@ +#!/usr/bin/bash +## source configuration file +source sendrewards.conf +## check that skycoin wallet is running +skycoin-cli status ; [[ $? -ne 0 ]] && (echo 'skycoin wallet not running ; exiting' && exit 1) +## check that skywire-reward.service isn't running to ensure rewards calculation not ongoing +skywire dmsg curl $REWARD_SYS_URL/skycoin-rewards/s | jq -r '.' +[[ "$(skywire dmsg curl $REWARD_SYS_URL/skycoin-rewards/s | jq -r '.active')" == "active"* ]] && echo "skywire-rewards are calculating - reward service active ; not executing distribution to avoid partial file download" && exit 0 +## preview current reward statistics +source sendrewards.conf ; skywire dmsg curl $REWARD_SYS_URL/$(skywire dmsg curl $REWARD_SYS_URL/skycoin-rewards/csv | sed 's/_rewardtxn0.csv/_stats.txt/g') +## allow to accept or decline +read -n 1 -p "Send rewards? [Y/n]: " user_input +echo +if [[ "$user_input" != "Y" && "$user_input" != "y" ]]; then + echo "exiting" + exit 0 +fi +## get link to the latest CSV +#skywire dmsg curl $REWARD_SYS_URL/skycoin-rewards/csv -s $REWARD_WL_SK +## get reward csv data +# skywire dmsg curl $REWARD_SYS_URL/$(skywire dmsg curl $REWARD_SYS_URL/skycoin-rewards/csv -s $REWARD_WL_SK) -s $REWARD_WL_SK | tr -d ' ' | awk -F, '{printf "%s,%.3f\n", $1, int($2*1000)/1000}' | grep -v '^,0.000$' +skywire dmsg curl $REWARD_SYS_URL/reward -d "$(skycoin-cli createRawTransaction $WALLET_FILE -a $FROM_ADDRESS --csv <(skywire dmsg curl $REWARD_SYS_URL/$(skywire dmsg curl $REWARD_SYS_URL/skycoin-rewards/csv -s $REWARD_WL_SK) -s $REWARD_WL_SK | tr -d ' ' | awk -F, '{printf "%s,%.3f\n", $1, int($2*1000)/1000}' | grep -v '^,0.000$'))" -s $REWARD_WL_SK