-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaybackdelegates.sh
More file actions
50 lines (41 loc) · 1.64 KB
/
paybackdelegates.sh
File metadata and controls
50 lines (41 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed. Aborting."; exit 1; }
APINODE="https://wallet.rise.vision/"
MAXDELEGATES=`curl -s $APINODE/api/delegates?limit=1 | jq .totalCount`
SECRET="<ENTER SEVRET OF PAYING ACCOUNT HERE>"
SECSECRET="<ENTER SECOND SCRET HERE>"
#Amount of transaction * 10^8. Example: to send 1.1234 RISE, use 112340000 as amount */,
#Set to 15 RISE
SENDAMOUNT="2500000000"
OFFSET=0
echo Amount of Delegates on Blockchain: $MAXDELEGATES
# first batch of delegates
echo get delegate $((1+$OFFSET)) up to $((100+$OFFSET)) of $MAXDELEGATES
DELLINES=`curl -s $APINODE/api/delegates?limit=100\&offset=$OFFSET | jq '.delegates[] .address'`
let OFFSET=$OFFSET+100
while [ $OFFSET -le $MAXDELEGATES ]
do
echo get delegate $((1+$OFFSET)) up to $((100+$OFFSET)) of $MAXDELEGATES
DELLINES=$DELLINES"\n"`curl -s $APINODE/api/delegates?limit=100\&offset=$OFFSET | jq '.delegates[] .address'`
DELLINES=`echo -e "$DELLINES"`
let OFFSET=$OFFSET+100
done
echo have `echo "$DELLINES" | wc -l` Delegates in the queue
read -p "Are you sure to send $(($SENDAMOUNT/100000000)) to $MAXDELEGATES Delegates? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit
fi
for VAR in $DELLINES
do
echo "Pay $(($SENDAMOUNT/100000000)) to $VAR"
HEADER="Content-Type: application/json"
if [ -z "$SECSECRET" ]; then
BODY="{\"secret\":\"$SECRET\",\"amount\":$SENDAMOUNT,\"recipientId\":"$VAR"}"
else
BODY="{\"secret\":\"$SECRET\",\"secondSecret\":\"$SECSECRET\",\"amount\":$SENDAMOUNT,\"recipientId\":"$VAR"}"
fi
curl -s -k -H "$HEADER" -X PUT -d "$BODY" "$APINODE/api/transactions" | jq
sleep 0.5
done