I'm trying to run a simple script to connect to a Bitcoin peer, like this one:
var bitcore = require('bitcore-lib')
var p2p = require('bitcore-p2p')
var Peer = p2p.Peer;
var peer = new Peer({host: 'localhost', port: 18333, network: Networks.testnet})
peer.on('connect', function () { console.log('connect'); })
peer.on('ready', function(){ console.log('ready'); });
peer.on('disconnect', function() { console.log('connection closed'); });
peer.connect()
However, the connection seems to never be established. I only get the 'connect' and the 'connection closed' output, but not 'connected'. The port I set is the one in the Bitcore config file.
Can someone please help me figure out what is the problem?