Fulcrum/src/bitcoin/block.cpp
Calin Culianu be56dd204f
Minor nit: Allow CBlock.ToString() to take an optional "verbose" arg.
Also in the deserializer, we print the number of junk bytes left at the
end if there are junk bytes.
2024-06-26 21:21:26 +03:00

32 lines
1,007 B
C++

// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "block.h"
#include "crypto/common.h"
#include "hash.h"
#include "tinyformat.h"
#include "utilstrencodings.h"
namespace bitcoin {
uint256 CBlockHeader::GetHash() const {
return SerializeHash(*this);
}
std::string CBlock::ToString(bool fVerbose) const {
std::stringstream s;
s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, "
"hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, "
"vtx=%u)\n",
GetHash().ToString(), nVersion, hashPrevBlock.ToString(),
hashMerkleRoot.ToString(), nTime, nBits, nNonce, vtx.size());
for (const auto &tx : vtx) {
s << " " << tx->ToString(fVerbose) << "\n";
}
return s.str();
}
} // end namespace bitcoin