Author

Topic: Invalid message checksum from Satoshi 0.9.0 ??? (Read 642 times)

legendary
Activity: 1232
Merit: 1094
hero member
Activity: 714
Merit: 662
My bug now fixed, it validates... shame on me. Shocked
hero member
Activity: 714
Merit: 662
Most network libraries return the number of bytes read.  You have to keep reading until you have fully read the packet.

I am so stupid, that was it... I did socket.Read without checking the return readen. I spent hours to review the SHA256 code and searching for bug in the bitcoin core implementation. Shocked
I always have the  same problem, but I can move forward at least. Now I don't get a bunch of 0 address at least !

Thank a lot !
legendary
Activity: 1232
Merit: 1094
I am developping a C# based node implementation.

Are you calculating the checksum before even attempting to process the packet?  How are you working out the data length to checksum?   I assume you are using the message's length field?

Maybe, you aren't fully downloading the packet?  Most packets are only a few hundred bytes.  They will generally arrive in 1 IP packet.

If you create a buffer and then only fill it with the first hundred bytes of the packet, then you would get what you are seeing.

Most network libraries return the number of bytes read.  You have to keep reading until you have fully read the packet.
hero member
Activity: 714
Merit: 662
I am developping a C# based node implementation.

But I am having a problem : Remote nodes send me addr messages with an invalid checksum. (Satoshi 0.9.0, from DNS Seed)
I think there is something I am missing, because I can correctly validate all checksum from message documented in https://en.bitcoin.it/wiki/Protocol_specification

I am taking the payload, calculate the double SHA256 and take the low 4 bytes, but my checksum does not match the one in the message header I get from the network. (I can validate other addr payload from the network that get only 3 or 4 entry)

You can verify by running the Test "CanRead1000Addresses" in the unit tests of https://github.com/NicolasDorier/NBitcoin
The test messages I can validate from the protocol specification are in the unit test CanParseMessages.

Can someone verify if this message have the correct checksum ? Alternatively, is there a way to verify if the checksum is indeed correct without having to compile/run test of the bitcoin core implementation ?

One thing I also don't understand is why the node is sending me 1000 addresses, with 952 of them set to 000000000, instead of just 48.

The faulty message is this one : https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin.Tests/data/1000Addresses.txt
And I receive a lot of such message, so I don't think the problem is only from a single node.
Jump to: