<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>

CC BY-SA 4.0
2022-01-23T15:30:22.917Z
OMG, I went code blind and was fixated on a single assignment. 

It’s right bloody there!!!
LeosSire
CC BY-SA 4.0
2022-01-23T12:42:53.573Z
2022-01-23T12:56:18.887Z
2022-01-23T12:56:18.887Z
Murch
<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>

<bitcoin-core-development><peer-discovery>
Where is the magic number stated?
LeosSire
# Where is the magic number stated?

(Asked by: username_0 on 2022-01-23)

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?

**Tags:** bitcoin-core-development, peer-discovery


---

## 1 answers

### Answer by username_1 on 2022-01-23. Score: 1 | Accepted answer

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;

> **Comments:**
> **username_0**: OMG, I went code blind and was fixated on a single assignment.   It’s right bloody there!!!  

---

