Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Many Coins on February 22, 2018, 12:56:55 PM



Title: pchMessageStart - what is for? (in BC 0.8)
Post by: Many Coins on February 22, 2018, 12:56:55 PM
Hello!

Tell me please, what is for:

Code:
pchMessageStart[0] = 0xfc;

and

Code:
pchMessageStart[4] = { 0xfb, 0xc0, 0xb6, 0xdb };

What does it do?

Thank you!



Title: Re: pchMessageStart - what is for? (in BC 0.8)
Post by: achow101 on February 22, 2018, 04:12:54 PM
Those are the magic bytes. They prepend every single network message so that the message can be identified as being a Bitcoin message.


Title: Re: pchMessageStart - what is for? (in BC 0.8)
Post by: Many Coins on February 23, 2018, 06:38:11 AM
Those are the magic bytes. They prepend every single network message so that the message can be identified as being a Bitcoin message.

Is it different from, for example, litecoin? But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.

And are these values ​​arbitrary? Or are there any rules for choosing them?


Title: Re: pchMessageStart - what is for? (in BC 0.8)
Post by: Xynerise on February 23, 2018, 07:31:03 AM
Is it different from, for example, litecoin? But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.
Apparently Litecoin and Viacoin (the only 2 bitcoin code forks I checked) have the same magic bytes:
Code:
pchMessageStart[0] = 0xfb;
        pchMessageStart[1] = 0xc0;
        pchMessageStart[2] = 0xb6;
        pchMessageStart[3] = 0xdb;
https://github.com/litecoin-project/litecoin/blob/master/src/chainparams.cpp
Quote
And are these values ​​arbitrary? Or are there any rules for choosing them?
The same file linked above has this comment:
Code:
The message start string is designed to be unlikely to occur in normal data.
         * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
         * a large 32-bit integer with any alignment.


Title: Re: pchMessageStart - what is for? (in BC 0.8)
Post by: Many Coins on February 23, 2018, 07:28:45 PM

Apparently Litecoin and Viacoin (the only 2 bitcoin code forks I checked) have the same magic bytes:


why not  :)


Title: Re: pchMessageStart - what is for? (in BC 0.8)
Post by: achow101 on February 24, 2018, 04:17:40 AM
Is it different from, for example, litecoin?
Yes.

But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.
To make sure that there's no crosstalk or confusion in the first place as figuring out that they have different genesis blocks still costs bandwidth and computing power.

And are these values ​​arbitrary? Or are there any rules for choosing them?
They're arbitrary. The common recommendation for new altcoins is to just randomly generate new magic bytes.


Title: Re: pchMessageStart - what is for? (in BC 0.8)
Post by: Many Coins on February 24, 2018, 10:41:40 AM
But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.
To make sure that there's no crosstalk or confusion in the first place as figuring out that they have different genesis blocks still costs bandwidth and computing power.

And are these values ​​arbitrary? Or are there any rules for choosing them?
They're arbitrary. The common recommendation for new altcoins is to just randomly generate new magic bytes.

Thank you!

It is clear now.