Last active
November 21, 2018 03:35
-
-
Save scottjbarr/ccc81499e7f0d0de0d59c83d9359a4e0 to your computer and use it in GitHub Desktop.
Show the Bitcoin SV nodes from JSON returned from getpeerinfo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Bitcoin SV:0.1.0(EB128.0; bitcoin-abc)/ 3.120.248.245:8333 | |
/Bitcoin SV:0.1.0(EB128.0)/ 47.92.157.192:8333 | |
/Bitcoin SV:0.1.0(EB128.0)/ 77.72.125.206:8333 | |
/Bitcoin SV:0.1.0(EB128.0)/ 138.201.221.79:8333 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return a list of Bitcoin SV nodes. | |
// | |
// Usage: | |
// | |
// node ./sv_nodes.js peerinfo.json | |
// | |
// where "sv_nodes.js" is the name of this file, and "peerinfo.json" was | |
// created from the following command. | |
// | |
// bitcoin-cli getpeerinfo > peerinfo.json | |
// | |
// Author : Scott Barr | |
// Date : 17 Nov 2018 | |
const fs = require('fs'); | |
// get the filename from the args (assumes you give the filename as the arg) | |
const filename = process.argv[2]; | |
// read the file | |
const content = fs.readFileSync(filename); | |
// parse the JSON | |
const peers = JSON.parse(content); | |
// filter the nodes, giving only nodes that claim to be "Bitcoin SV" | |
peers | |
.filter(o => o.subver.startsWith('/Bitcoin SV')) | |
.forEach(o => console.log(o.subver, o.addr)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment