<p>There is no way to explicitly know that your node is on a minority-hashrate fork because to do so would mean awareness of all the new rules that makes the majority-hashrate fork valid, and then determining that more proof-of-work is accumulated on that chain. For that to be possible, you must be running an upgraded node already.</p>

<p>There are a few warning signs though: If your node hasn't received a new block in over two hours for example, you might want to manually check it - does it still have a good number of peers? Does log activity look OK?</p>

<p>High-volume Bitcoin merchants and exchanges usually simultaneously run several Bitcoin nodes, even a few different versions (0.19, 0.18, 0.17) and maybe even an alternative implementation (bcoin, btcd). This is how BitMex' <a href="https://forkmonitor.info" rel="nofollow noreferrer">https://forkmonitor.info</a> operates.</p>

<p>There is rpc <code>getchaintips</code>: <a href="https://chainquery.com/bitcoin-cli/getchaintips" rel="nofollow noreferrer">https://chainquery.com/bitcoin-cli/getchaintips</a></p>

<p>...but this is doing the opposite of what you asked: it will reveal to the user known chain forks (stale blocks, etc) but of course they are all lesser-work than the node's current tip which is always on the most-work valid chain.</p>

CC BY-SA 4.0
2020-06-15T16:32:52.757Z
Thanks for the answer. I guess the best way to check would be to API with a popular explorer, and check your own node's height against it every so often
Barney Chambers
CC BY-SA 4.0
2020-06-15T16:46:50.680Z
Yes if you trust that block explorer!
pinhead
CC BY-SA 4.0
2020-06-15T12:20:28.477Z
2020-06-15T15:47:09.393Z
2020-06-15T15:47:09.393Z
pinhead
<p>Implementing a rule change that all pre-existing bitcoin nodes will not follow is equivalent to creating a new altcoin network (similar to the creation of BCH, for example). </p>

<p>There is no sensical way for a pre-existing bitcoin node to watch for such changes, and decide that it should follow that new (otherwise invalid) chain instead. A bitcoin node can simply determine which bitcoin chain is valid-- altering the rules is a social phenomenon, not a programmatic one.</p>

CC BY-SA 4.0
2020-06-20T05:08:40.327Z
Maybe for the bitcoin network specifically, but some bitcoin forked coins add changes all the time which invalidate the consensus mechanisms of older versions of the coin (eg biblepay, monero, electroneum)
Barney Chambers
CC BY-SA 4.0
2020-06-20T05:19:30.077Z
Yes that is true, and I imagine that such a network would need some sort of rules about watching for upgrades. It creates a lot of centralization of power around protocol devs and processes though.
chytrik
CC BY-SA 4.0
2020-06-16T07:03:32.897Z
2020-06-16T07:03:32.897Z
chytrik
<p>There are some useful RPC commands that you can use in your bitcoin.conf file to trigger code when blocks have been confirmed, such as the <code>blocknotify</code> command. </p>

<p>Is there are similar command that will execute code when your node is on an old fork, or no longer synced to the tip of the blockchain?</p>

CC BY-SA 4.0
2020-06-15T02:16:32.800Z
I'm not sure I follow the scenario. Your node is never "on an old fork". Either it follows the one competing chaintip that it saw first out of two of equal accumulated difficulty, or it is reorganizing to the best chaintip as soon as it hears about a new block.
Murch
CC BY-SA 4.0
2020-06-15T02:18:10.917Z
My question is referring to when a blockchain adds new rules, and your node is no longer reaching consensus. For example, Monero hardforks every 6 months or so, and old nodes will no longer accept blocks because of the new consensus rules. This happens a lot on Bitcoin forked altcoins too, Biblepay is notorious for hardforking every couple of months
Barney Chambers
<json-rpc><blockchain-fork><daemon>
Is there an RPC command that checks for hardforks
Barney Chambers
# Is there an RPC command that checks for hardforks

(Asked by: username_0 on 2020-06-15)

There are some useful RPC commands that you can use in your bitcoin.conf file to trigger code when blocks have been confirmed, such as the `blocknotify` command.

Is there are similar command that will execute code when your node is on an old fork, or no longer synced to the tip of the blockchain?

**Tags:** json-rpc, blockchain-fork, daemon

> **Comments:**
> **username_1**: I'm not sure I follow the scenario. Your node is never "on an old fork". Either it follows the one competing chaintip that it saw first out of two of equal accumulated difficulty, or it is reorganizing to the best chaintip as soon as it hears about a new block.  
> **username_0**: My question is referring to when a blockchain adds new rules, and your node is no longer reaching consensus. For example, Monero hardforks every 6 months or so, and old nodes will no longer accept blocks because of the new consensus rules. This happens a lot on Bitcoin forked altcoins too, Biblepay is notorious for hardforking every couple of months  

---

## 2 answers

### Answer by username_2 on 2020-06-15. Score: 3 | Accepted answer

There is no way to explicitly know that your node is on a minority-hashrate fork because to do so would mean awareness of all the new rules that makes the majority-hashrate fork valid, and then determining that more proof-of-work is accumulated on that chain. For that to be possible, you must be running an upgraded node already.

There are a few warning signs though: If your node hasn't received a new block in over two hours for example, you might want to manually check it - does it still have a good number of peers? Does log activity look OK?

High-volume Bitcoin merchants and exchanges usually simultaneously run several Bitcoin nodes, even a few different versions (0.19, 0.18, 0.17) and maybe even an alternative implementation (bcoin, btcd). This is how BitMex' <https://forkmonitor.info> operates.

There is rpc `getchaintips`: <https://chainquery.com/bitcoin-cli/getchaintips>

...but this is doing the opposite of what you asked: it will reveal to the user known chain forks (stale blocks, etc) but of course they are all lesser-work than the node's current tip which is always on the most-work valid chain.

> **Comments:**
> **username_0**: Thanks for the answer. I guess the best way to check would be to API with a popular explorer, and check your own node's height against it every so often  
> **username_2**: Yes if you trust that block explorer!  

---

### Answer by username_3 on 2020-06-16. Score: 0

Implementing a rule change that all pre-existing bitcoin nodes will not follow is equivalent to creating a new altcoin network (similar to the creation of BCH, for example).

There is no sensical way for a pre-existing bitcoin node to watch for such changes, and decide that it should follow that new (otherwise invalid) chain instead. A bitcoin node can simply determine which bitcoin chain is valid-- altering the rules is a social phenomenon, not a programmatic one.

> **Comments:**
> **username_0**: Maybe for the bitcoin network specifically, but some bitcoin forked coins add changes all the time which invalidate the consensus mechanisms of older versions of the coin (eg biblepay, monero, electroneum)  
> **username_3**: Yes that is true, and I imagine that such a network would need some sort of rules about watching for upgrades. It creates a lot of centralization of power around protocol devs and processes though.  

---

