Closed fed-franz closed 7 years ago
After many tries, I figured out that: 1) the port number should actually be that of the Bitcoind server (default 8333, or 18333 for testnet) 2) when connecting to a livenet peer, the code works perfectly, but when connecting to a testnet node it immediately disconnect. I tried both with my node, and with a public one.
So, it seems to me that this is a bug of the bitcore-p2p library. Otherwise, there is something different with testnet peers that I am not aware of.
In any case, I need some help (I cannot develop using the mainnet...)
I found something I think to be wrong:
In the Peer code (peer.js
), when sending the version
message to the peer, it sends the livenet network object, instead of the testnet one:
{
"command": "version",
"network": {
"name": "livenet",
"alias": "mainnet",
...
Is it a bug or something I set up wrong?
@frz-dev can you point on the line in code?
@fanatid
I went a little further, up to Peer.prototype._sendVersion
(peer.js#L200)
If I print the message created at line 202, I obtain the same wrong network as above
@frz-dev if you check Peer constructor you can see that messages are created with network and you can set custom network via options new Peer({ network: 'testnet' })
Just noticed. I actually removed it because it caused some error (probably due to the wrong nvm version). Now it seems to connect.
Thanks, and sorry for the storm in a tea cup :)
Hi, I'm trying to run a simple script, like this:
However, the connection seems to be never established... I only get the 'connect' and the 'connection closed' output.
What am I doing wrong?