Skip to content

Commit

Permalink
add updated reward distribution script and .conf file template
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed May 24, 2024
1 parent 7067771 commit af94d11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/rewards/sendrewards.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WALLET_FILE="$HOME/.skycoin/wallets/<wallet-filename>.wlt"
FROM_ADDRESS="HWteH5YSjqax9dnvkHsFPU4JzHiTxugbet"
REWARD_WL_SK=<sec-key-of-pk-whitelisted-by-reward-system>
REWARD_SYS_URL="dmsg://036a70e6956061778e1883e928c1236189db14dfd446df23d83e45c321b330c91f:80"
22 changes: 22 additions & 0 deletions scripts/rewards/sendrewards.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit af94d11

Please sign in to comment.