pkahly / bitcoin-monitor

Monitors a full Bitcoin node and sends status emails and alerts
MIT License
0 stars 0 forks source link

Note: Still under construction -- needs productionized, automated tests, etc. See open issues.

Developed primarily for my own use, but feedback and contributions are welcome

Monitors a full Bitcoin node and sends status emails and alerts.

Sample alerts:

No blocks in 95 minutes

Difficulty Adjustment Occurred! Old: 9985348008059.555 New: 10183488432890 Change: 1.98 %

Above Maximum Hash Rate: 90.1 EH/s > 88.4 EH/s

Below Local Minimum Hash Rate: 31.5 EH/s < 44.7 EH/s

Unusual Block Time: 12.1 min

Block Reorg of 2 blocks has occurred

Price change of 10.50 %

Sample status update:

Blocks: 590,508 ( + 21 )
Minutes Since Last Block: 1

Network Hash Rate: 67.80 EH/s ( 3.56 % )
Blocks until next difficulty adjustment: 180

Average time between blocks
Last day: 10.61 min
Last month: 9.38 min

Total Coins Mined: 17,881,362 ( 85.15 % )
Remaining Coins: 3,118,638

Current Reward: 12.5
Blocks Until Next Halving: 39,491 ( ~274 days )

Price: $10,405.79 ( 0.20 % )
Market Cap: $186.07 billion

Sample daily summary:

Difference Since: 08-16 10:24 AM

Blocks: 590,517 ( + 124 )
Minutes Since Last Block: 5

Network Hash Rate: 68.95 EH/s ( -5.67 % )
Blocks until next difficulty adjustment: 171

Average time between blocks
Last day: 10.46 min
Last month: 9.39 min

Total Coins Mined: 17,881,475 ( 85.15 % )
Remaining Coins: 3,118,525

Current Reward: 12.5
Blocks Until Next Halving: 39,482 ( ~274 days )

Price: $10,327.64 ( 1.94 % )
Market Cap: $184.67 billion

All Time High Hash Rate: 88.4 EH/s
Lowest Recent Hash Rate: 44.7 EH/s

Historical Prices:
2018-08-17 :  $6,580.63      56.94 %
2017-08-17 :  $4,331.69     138.42 %
2016-08-17 :    $573.22    1701.69 %
2015-08-17 :    $257.98    3903.27 %
2014-08-17 :    $491.80    1999.97 %

Set Up Instructions:

Run a full Bitcoin node.

Install sqlite3 and python-bitcoinrpc

# Install Pip for Python3 if you don't have it
sudo apt install python3-pip

pip3 install python-bitcoinrpc
pip3 install plotly

Note: There is a known bug in python-bitcoinrpc which may cause errors when retrieving the network hashrate. https://github.com/jgarzik/python-bitcoinrpc/pull/63

Install the alerter. This will create a database of block info.

./main.py --install

Optional Import Historical Price Data.

./main.py --import_price_history

This will look for daily_history.csv in the current directory. The required format is as follows:

<date>,<open>,<high>,<low>,<close>

Example row:

Jul192019,10653.96,10716.98,10229.63,10530.73
# Several date formats are supported, create an issue or pull request if you need to add another format

I retrieved Mt. Gox data from https://bitcoincharts.com/charts/mtgoxUSD and recent aggregate data from https://coinmarketcap.com/

Edit the default config.json that was created automatically during the install. Format:

{
"enable_emails": false, 
"server": "", 
"port": "", 
"bot_email": "", 
"bot_password": "", 
"human_email": "", 
"bitcoind_user": "alerterbot", 
"bitcoind_pass": "DO_NOT_USE_76cf8e3a30fb29b4131a8babb", 
"use_testnet": false, 
"use_regtest": false, 
"status_frequency_in_hours": 6, 
"catch_errors": true, 
"block_reorg_threshold": 0, 
"minutes_between_blocks_threshold": 90, 
"price_percent_change_threshold": 5, 
"reorg_depth_cap": 5
}

Start the Bitcoin Alerter

./main.py --run