Bitcoin Forum
September 27, 2018, 10:23:06 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Invalid message checksum from Satoshi 0.9.0 ???  (Read 584 times)
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 700
Merit: 501


View Profile
April 28, 2014, 03:51:01 PM
 #1

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.

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538086986
Hero Member
*
Offline Offline

Posts: 1538086986

View Profile Personal Message (Offline)

Ignore
1538086986
Reply with quote  #2

1538086986
Report to moderator
1538086986
Hero Member
*
Offline Offline

Posts: 1538086986

View Profile Personal Message (Offline)

Ignore
1538086986
Reply with quote  #2

1538086986
Report to moderator
TierNolan
Legendary
*
Offline Offline

Activity: 1190
Merit: 1001


View Profile
April 28, 2014, 04:11:19 PM
 #2

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.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 700
Merit: 501


View Profile
April 28, 2014, 04:38:16 PM
 #3

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 !

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 700
Merit: 501


View Profile
April 28, 2014, 04:46:24 PM
 #4

My bug now fixed, it validates... shame on me. Shocked

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
TierNolan
Legendary
*
Offline Offline

Activity: 1190
Merit: 1001


View Profile
April 28, 2014, 04:52:14 PM
 #5

Thank a lot !

Glad to help Smiley.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!