Trying to find the raw genesis transaction length

0

I see that many different altcoins have different lengths for the initial genesis tx. How would I go about finding the length of the initial genesis tx? I saw another answer but I have no need of making it as complicated; I just need the length and nothing else.

For example, Bitcoin's is

01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000.

However, altcoins have different lengths. Is there an identifier I can use to determine the length of the genesis tx and nothing else?

EDIT: I am making a block explorer so I cannot use a block explorer to help me in getting info.

AnimalTesting

Posted 2015-04-06T18:35:36.013

Reputation: 3

The transaction you posted is 204 bytes. Is that what you're looking for? – Nick ODell – 2015-04-06T18:50:39.567

@NickODell That's only for bitcoin. What I need is http://bitcoin.stackexchange.com/questions/36321/extract-genesis-block-raw-tx-data in a condensed format, preferably done in bash instead of python.

– AnimalTesting – 2015-04-06T18:58:47.887

Answers

2

Unfortunately, the genesis block is not indexed in most altcoins (because they forked from bitcoin and kept the same bug), so you can't really get access to it via the RPC methods.

What you could do instead:

  • Use a block explorer that will tell you the size of the transaction. For example, blockchain.info makes this information available (204 bytes).
  • Find the parameters file and put a print the size of the genesis block to stdout.

The second option basically entails putting the following lines at the end of CMainParams() and then compiling.

CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
ssBlock << genesis;
printf("block: %s\n", HexStr(ssBlock.begin(), ssBlock.end()).c_str());
printf("block size: %i\n", (int)::GetSerializeSize(genesis, SER_NETWORK, PROTOCOL_VERSION));
printf("tx size: %i\n", (int)::GetSerializeSize(genesis.vtx[0], SER_NETWORK, PROTOCOL_VERSION));

This will print the raw block data, it's size, and the transaction's size. (Note, this is untested, but something along these lines should work)

NOTE: It's possible, although not the norm, to put multiple transactions in a genesis block. Just check that your assumption is correct.

morsecoder

Posted 2015-04-06T18:35:36.013

Reputation: 13 123

Size would definitely work for this situation. Only problem is that I am trying to make the block explorer for the coin via Abe, so option 1 isn't available to me. Could you explain the second option? I am guessing you mean chainparams.cpp but I have no idea how to print the size of the genesis block. – AnimalTesting – 2015-04-06T19:09:00.447

@AnimalTesting, see updated answer. – morsecoder – 2015-04-06T19:16:32.957

How would I use the new code? What command do I have to pass into the daemon? – AnimalTesting – 2015-04-06T19:34:28.950

It requires actually re-compiling the daemon after you have put the code in place. Then just start the daemon and it will print. – morsecoder – 2015-04-06T19:35:28.137

Also, will this say the size of the block or transaction? You said "This will print the raw block data and it's size." But in the first option, you show how to find the size of the transaction. – AnimalTesting – 2015-04-06T19:38:55.167

It gave this error when compiling: http://pastebin.com/qgAjUFyg

– AnimalTesting – 2015-04-06T19:39:53.047

@AnimalTesting, updated answer. – morsecoder – 2015-04-06T19:41:58.137

Let us continue this discussion in chat.

– AnimalTesting – 2015-04-06T19:43:03.520