user88065: This has been bugging me. I’d have expected the magic number to be in the chainParams.cpp but I can’t find it.
Where is bitcoin's magic number stored in the source code?

user5406: You may not have been able to find them because they're encoded as separate bytes. You can find them in src/chainparams.cpp, currently on lines 102–105. I found the code section after noticing that the Bitcoin Developer Guide referred to the value as "Start String" and searching the code base for that term.
This is the relevant section of code.
    /**
     * The message start string is designed to be unlikely to occur in normal data.
     * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
     * a large 32-bit integer with any alignment.
     */
    pchMessageStart[0] = 0xf9;
    pchMessageStart[1] = 0xbe;
    pchMessageStart[2] = 0xb4;
    pchMessageStart[3] = 0xd9;


88065: <p>This has been bugging me. I’d have expected the magic number to be in the <code>chainParams.cpp</code> but I can’t find it.</p>
<p>Where is bitcoin's magic number stored in the source code?</p>
 5406: <p>You may not have been able to find them because they're encoded as separate bytes. You can find them in <code>src/chainparams.cpp</code>, currently on <a href="https://github.com/bitcoin/bitcoin/blob/6d859cbd794a36ed1c0c72324a4ec54d029b3d3b/src/chainparams.cpp#L102" rel="nofollow noreferrer">lines 102–105</a>. I found the code section after noticing that the Bitcoin Developer Guide <a href="https://btcinformation.org/en/developer-reference#constants-and-defaults" rel="nofollow noreferrer">referred</a> to the value as &quot;Start String&quot; and searching the code base for that term.</p>
<p>This is the relevant section of code.</p>
<pre><code>    /**
     * The message start string is designed to be unlikely to occur in normal data.
     * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
     * a large 32-bit integer with any alignment.
     */
    pchMessageStart[0] = 0xf9;
    pchMessageStart[1] = 0xbe;
    pchMessageStart[2] = 0xb4;
    pchMessageStart[3] = 0xd9;
</code></pre>
