0

I have tried to serialize as follows without success: bitcoin tag v22.0 from github.

In the file src/miner.cpp and the function

function std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)

I have placed the line std::cout << pblock << std::endl; at the very end before it returns (Here). The value that is printed to the terminal is:

0x7fc9f4009410

This is too little data, I would expect the entire block data to be serialized and printed in hex. What am I doing wrong? I know pblock is a pointer to a CBlock class, but it should still work.

What is the proper way to serialize CBlock data, and also the CBlockHeader data?

Thank you!

1
  • Since it is a std::unique_ptr, the << operator outputs the pointer value rather than the object pointed to. Try dereferencing the pointer first.
    – Ava Chow
    Jan 27, 2022 at 3:21

1 Answer 1

2

Since pblock is a pointer, you are printing an address. Dereference it to get the format you want:

std::cout << *pblock << std::endl;

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.