To my knowledge, there is currently no way to do this, so I wrote one.
The details of decoding peers.dat are described in my blog post Demystifying Bitcoin's peers.dat.
The result of that is an open source tool written in go that can read all peer info from peers.dat. As always, one should review the code before running this on any machine that hold a wallet. The tool should be able to work with any Bitcoin-based altcoin as well. I have tested it against Bitcoin, Litecoin, and Dogecoin peers.dat
s.
Installing bitpeers
is quite simple, provided you have go installed, and your GOPATH
set up. If not, go has a handy getting started guide which you can use to fix that.
Once go is set up, simply run
go get -u github.com/RaghavSood/bitpeers/cmd/bitpeers
If your go environment is set up properly, you should now have a bitpeers
command available. If not, try finding your GOBIN
(GOPATH/bin
) and adding it to your PATH
.
bitpeers
to easily dump peers.dat
addresses as either human-readable plaintext or JSON. It accepts three flags:
Usage of bitpeers:
--addressonly outputs only addresses if specified
--filepath string the path to peers.dat
--format string the output format {json|text} (default "json")
Running bitpeers --filepath /mnt/doge/.dogecoin/peers.dat --addressonly
will produce a JSON array of all the IPs and ports in peers.dat
. You can also pass the --format text
option to produce a list of all IPs and ports, one IP:port per line.
Running without the --addressonly
option will produce the full JSON/text output, which contains the following:
$ bitpeers --filepath ./peers.dat --format text
SerializationVersion: 34fc0100
Time: 1526192792
ServiceFlags: 0x000000000000000d
IP: 42.5.143.180:8333
Source: 8.8.8.8
LastSuccess: 1526746622
Attempts: 0
If you happen to find any inconsistencies or issues with the parser or output, please open an issue on the GitHub repo.