Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: cudjex on February 02, 2014, 05:45:46 PM



Title: What does "pchMessage" mean ?
Post by: cudjex on February 02, 2014, 05:45:46 PM
Hey

I'm trying to understand some things about coins.

When I look to Saturncoin's main.cpp (https://github.com/saturncoinnet/Saturncoin/blob/master/src/main.cpp#L2434), pchMessage value is :a
Code:
unsigned char pchMessageStart[4] = { 0xfa, 0xb4, 0xad, 0xcb };
In Litecoin's main.cpp (https://github.com/saturncoinnet/Saturncoin/blob/master/src/main.cpp#L2434) :
Code:
unsigned char pchMessageStart[4] = { 0xfb, 0xc0, 0xb6, 0xdb };
In Dogecoin (https://github.com/dogecoin/dogecoin/blob/master-1.5/src/main.cpp#L3141) :
Code:
unsigned char pchMessageStart[4] = { 0xc0, 0xc0, 0xc0, 0xc0 };

So what is this and how it works ?



Title: Re: What does "pchMessage" mean ?
Post by: cudjex on February 02, 2014, 08:17:13 PM
Nobody knows this ?


Title: Re: What does "pchMessage" mean ?
Post by: jimhsu on February 02, 2014, 08:26:41 PM
These are the magic bytes. They serve a variety of purposes, including indicating the proper network, and serving as a start for explorers such as Abe to parse. Some altcoins that don't change the magic bytes (n00b launches) have problems such as trying to download the litecoin blockchain on start.

As for what "pchMessage" means exactly, I don't know.

For more info, see http://james.lab6.com/2012/01/12/bitcoin-285-bytes-that-changed-the-world/


Title: Re: What does "pchMessage" mean ?
Post by: cudjex on February 02, 2014, 08:38:04 PM

Thanks for your clarification jimhsu. I didn't know it's affecting to download different blockchain.


Title: Re: What does "pchMessage" mean ?
Post by: Sharrow on February 02, 2014, 08:51:21 PM
These entries should always be altered when creating an altcoin otherwise there could be cross-talk with other currencies using similar code. It's best to do it right at the very start, before the genesis hash is created and the coin is released otherwise you will have a major fork to deal with.

One way to do it is to go to an online hexadecimal converter and use it to produce random characters for the end of your pchMessage 0x?? strings. Think up four random numbers between 0 and 255 and convert them from decimal to hex i.e. 177 = b1, 223 = df.

Change the last part of your 0x?? strings to your new values and make sure it's done for the main network in main.cpp.


Title: Re: What does "pchMessage" mean ?
Post by: cudjex on February 02, 2014, 09:39:03 PM
These entries should always be altered when creating an altcoin otherwise there could be cross-talk with other currencies using similar code. It's best to do it right at the very start, before the genesis hash is created and the coin is released otherwise you will have a major fork to deal with.

One way to do it is to go to an online hexadecimal converter and use it to produce random characters for the end of your pchMessage 0x?? strings. Think up four random numbers between 0 and 255 and convert them from decimal to hex i.e. 177 = b1, 223 = df.

Change the last part of your 0x?? strings to your new values and make sure it's done for the main network in main.cpp.


Thanks for your great answer.


Title: Re: What does "pchMessage" mean ?
Post by: nibyokwy on February 02, 2014, 10:30:55 PM
As for what "pchMessage" means exactly, I don't know.
the 'pch' is hungarian notation and usually means 'pointer to character'. it's a way of encoding the type of the variable in the variable name to make readers of the code understand the intended types easier.