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.

2

1 Answer 1

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.

8
  • 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. Commented Apr 6, 2015 at 19:09
  • @AnimalTesting, see updated answer.
    – morsecoder
    Commented Apr 6, 2015 at 19:16
  • How would I use the new code? What command do I have to pass into the daemon? Commented Apr 6, 2015 at 19:34
  • 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
    Commented Apr 6, 2015 at 19:35
  • 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. Commented Apr 6, 2015 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.