1

I'm trying to send a protocol version message to my node on port 8333. I found this site that explains how to send a version message from the command line. I have a C++ app that is creating the message, but I thought I would try sending it from the command line before trying to do it in my C++ application.

I'm on a local network sending the message from 192.168.1.44 to the node at 192.168.1.47. The node is running Bitcoin Core 23.0.

According to the site linked above, the following command can be used to send a version message and print the verack that it receives. Instead, it pauses for a few seconds and prints nothing.

echo -en "f9beb4d976657273696f6e00000000005a000000365c501771110100010000000000000091211e6300000000010000000000000000000000000000000000ffffc0a8012f208d010000000000000000000000000000000000ffffc0a8012c208daabbccddeeff11350454657374d87f0b0000" | xxd -r -p | nc 192.168.1.47 8333 -i 2 | xxd

Here is a breakdown of the most recent message I've tried to send:

f9beb4d9
76657273696f6e0000000000
5a000000
365c5017

71110100
0100000000000000
91211e6300000000
010000000000000000000000000000000000ffffc0a8012f208d

010000000000000000000000000000000000ffffc0a8012c208d
aabbccddeeff1135
0454657374
d87f0b00

00

Here is what each of the above lines is supposed to be:

Mainnet byte sequence
"version" padded with zeroes
Length of payload (little endian)
Payload checksum (1st 4 bytes of double SHA256 converted to little endian)

Version 70001 (little endian)
NODE_NETWORK service
Timestamp (little endian)
Recipient address/port = 192.168.1.47:8333

Sender address/port = 192.168.1.44:8333
Nonce (random)
User agent = "Test"
Last block received = 753624 (little endian)

Relay = false

My bitcoin.conf file contains:

txindex=1
server=1
rpcbind=192.168.1.47:8901
rpcallowip=192.168.1.44
rpcuser=username
rpcpassword=xxxxxxxx

Is there something that needs to be added to bitcoin.conf?

Is there something wrong with the version message I am trying to send?

What else could the problem be?

5
  • Try adding "debug=net" to your bitcoin.conf, restart bitcoind, try your command again, and see if anything relevant appears in the debug.log file. Sep 11 at 18:54
  • It added a line in debug.log that looks like this: 76890:2022-09-11T19:16:25Z connection from 192.168.1.44:36780 accepted. However, it did not return a verack to the command I ran on the command line. I also noticed that while the command was waiting, an Unroutable Inbound peer with the same ip address appeared in bitcoin-qt and disappeared when the command finally finished.
    – Zephyrus
    Sep 11 at 19:23
  • Looking at some line in debug.log that came after that, I see a Wrong checksum message that shows the same 4-byte checksum that I sent. Going to look at it more carefully in a bit, but that's a big clue.
    – Zephyrus
    Sep 11 at 19:36
  • 1
    FWIW, the phrase "1st 4 bytes of double SHA256 converted to little endian" is meaningless. SHA256 outputs 32 bytes, the first 4 of those are the checksum. Bitcoin does in some places interpret the SHA256 output bytes as numbers (in particular, in block hashes when determining PoW), but there are no numbers involved here - just bytes. Sep 11 at 21:35
  • And that was my incorrect assumption, that those 4-bytes was interpreted as a number and needed to be converted to little endian. Commenting those lines out fixed the problem.
    – Zephyrus
    Sep 11 at 22:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.