How to check if your PIVX wallet has forked.

in #pivx7 years ago

I don't know how or why your wallet can fork into its own chain if you are staking. Know that it can happen and a symptom of that situation is that you'll start to receive high rewards in short periods of time.

To verify that your wallet is still on the main chain you have to get the block hash for the latest block in your chain and compare it with the block hash found for that same block in a block explorer. Step by step instructions found here: My staking or masternode reward is much higher than expected.

I wrote a script to automate that process, here it is:

#!/bin/bash
# saved as did-it-fork.sh

set -e

pivxcli=~/.pivx/pivx-cli

function getBlockNumber() {
  $pivxcli getinfo | grep blocks | sed "s/.*: \([0-9]\+\).*/\1/"
}

function getLocalBlockHash() {
  $pivxcli getblockhash $1
}

function getRemoteBlockHash() {
  curl -# 'http://pivxscan.io/api/getblockhash?index='$1
}

blockNumber=`getBlockNumber`
localBlockHash=`getLocalBlockHash $blockNumber`
remoteBlockHash=`getRemoteBlockHash $blockNumber`

echo '            block: '$blockNumber
echo ' block hash local: '$localBlockHash
echo 'block hash remote: '$remoteBlockHash

if [ $localBlockHash == $remoteBlockHash ]; then
  echo 'GOOD: still on main'
else
  echo 'BAD: you are on a fork, got to re-sync'
fi

exit 0

Usage example:

./did-it-fork.sh 
######################################################################## 100.0%
            block: 757941
 block hash local: 61e98dad1653790d074b82633f57753ac80ac7e7a7098355cbdb99b0be8cf671
block hash remote: 61e98dad1653790d074b82633f57753ac80ac7e7a7098355cbdb99b0be8cf671
             GOOD: still on main
Sort:  

Congratulations @givanse! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got a First Reply

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Is this shitty tech or what? Does DASH do this too?

Coin Marketplace

STEEM 0.26
TRX 0.20
JST 0.038
BTC 96240.27
ETH 3591.45
USDT 1.00
SBD 3.91