So I'm trying to learn more about the Bitcoin protocol, and I'm writing some code to try to talk with a Bitcoin instance as a peer. My problem is that Bitcoin won't respond to any of the messages I try to send. Here's what I have:
An example of the raw "version" message I'm sending:
F9BEB4D976657273696F6E000000000055000000B4C3000001000000000000009E5A344F00000000010000000000000000000000000000000000FFFF7F000010208D010000000000000000000000000000000000FFFF7F00001061A8CB0170F938EC13C700D6880200
The above message broken apart:
Start : F9 BE B4 D9
Command : 76 65 72 73 69 6F 6E 00 00 00 00 00
Length : 55 00 00 00
Checksum :
Payload :
Version : B4 C3 00 00
Services : 01 00 00 00 00 00 00 00
Timestamp : 9E 5A 34 4F 00 00 00 00
RecipientAddress :
Services : 01 00 00 00 00 00 00 00
Ip : 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 10
Port : 20 8D
SenderAddress :
Services : 01 00 00 00 00 00 00 00
Ip : 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 10
Port : 61 A8
Nonce : CB 01 70 F9 38 EC 13 C7
SubVersion : 00
LastBlock : D6 88 02 00
Here's what I get in the Bitcoin debug.log file:
accepted connection 127.0.0.1:63714
...
PROCESSMESSAGE MESSAGESTART NOT FOUND
...
socket no message in first 60 seconds, 1 0
disconnecting node 127.0.0.1:63714
"PROCESSMESSAGE MESSAGESTART NOT FOUND" comes from main.cpp around line 2342.
"socket no message in first 60 seconds" comes from net.cpp, right near the end.
I've tried to follow the spec as outlined here:
https://en.bitcoin.it/wiki/Protocol_specification (particularly the "Message structure", "Network address" and "Version" sections), but when I send the message, I never get a response, and Bitcoin complains about the already mentioned errors (above) in the log file.
Any ideas as to what I'm doing wrong in building the message?