forked from bedri/sapphire_v1.3.3.2_staking_script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocknotify.sh
More file actions
executable file
·37 lines (25 loc) · 1.12 KB
/
blocknotify.sh
File metadata and controls
executable file
·37 lines (25 loc) · 1.12 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
#!/bin/bash
# First parameter $1 is ID
ID=$1
# Second parameter $2 is TICKER
TICKER=$2
# Third parameter $3 is the JSONRPC cli name
CLI=$3
# Forth parameter $4 is the API url
URL=$4
# Get response for "$CLI getinfo"
INFO=$( $CLI getinfo )
# Parse Version Info
VERSION=$( echo $INFO | jq ".version" )
# Parse Protocol Version Info
PROTOCOL_VERSION=$( echo $INFO | jq ".protocolversion" )
# Parse Block Height Info
BLOCK_HEIGHT=$( echo $INFO | jq ".blocks" )
# Get Blockhash for $BLOCK_HEIGHT
BLOCK_HASH=$( $CLI getblockhash $BLOCK_HEIGHT )
# Parse Number of Connections
CONNECTIONS=$( echo $INFO | jq ".connections" )
# Parse Difficulty
DIFFICULTY=$( echo $INFO | jq ".difficulty" )
# Execute the POST request
RESPONSE=$( curl -s --insecure -X POST "$(echo $URL)/node" -H "accept: /" -H "Content-Type: application/json" -d '{"nodeId":"'$( echo $ID )'","ticker":"'$( echo $TICKER )'","version":"'$( echo $VERSION )'","protocolVersion":"'$( echo $PROTOCOL_VERSION )'","numBlocks":'$( echo $BLOCK_HEIGHT )',"blockHash":"'$( echo $BLOCK_HASH )'","connections":'$( echo $CONNECTIONS )',"difficulty":'$( echo $DIFFICULTY )'}' 2>/dev/null )