Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1501```1503```c++1504// Good: accepts and returns primitive types1505virtual bool findBlock(const uint256& hash, int& out_height, int64_t& out_time) = 0;1507// Bad: returns pointer to internal node in a linked list inaccessible to1508// other processes1509virtual const CBlockIndex* findBlock(const uint256& hash) = 0;1510```1512```c++1513// Good: takes plain callback type and returns interface pointer1514using TipChangedFn = std::function<void(int block_height, int64_t block_time)>;1515virtual std::unique_ptr<interfaces::Handler> handleTipChanged(TipChangedFn fn) = 0;1517// Bad: returns btcsignals connection specific to local process1518using TipChangedFn = std::function<void(int block_height, int64_t block_time)>;1519virtual btcsignals::scoped_connection connectTipChanged(TipChangedFn fn) = 0;1520```1522- Interface methods should not be overloaded.1524*Rationale*: consistency and friendliness to code generation tools.1526Example:1528```c++1529// Good: method names are unique1530virtual bool disconnectByAddress(const CNetAddr& net_addr) = 0;1531virtual bool disconnectById(NodeId id) = 0;1533// Bad: methods are overloaded by type1534virtual bool disconnect(const CNetAddr& net_addr) = 0;1535virtual bool disconnect(NodeId id) = 0;1536```1538### Internal interface naming style1540- Interface method names should be `lowerCamelCase` and standalone function names should be1541`UpperCamelCase`.1543*Rationale*: consistency and friendliness to code generation tools.1545Examples:1547```c++1548// Good: lowerCamelCase method name1549virtual void blockConnected(const CBlock& block, int height) = 0;1551// Bad: uppercase class method1552virtual void BlockConnected(const CBlock& block, int height) = 0;1553```1555```c++1556// Good: UpperCamelCase standalone function name1557std::unique_ptr<Node> MakeNode(LocalInit& init);1559// Bad: lowercase standalone function1560std::unique_ptr<Node> makeNode(LocalInit& init);1561```1563Note: This last convention isn't generally followed outside of1564[`src/interfaces/`](../src/interfaces/), though it did come up for discussion1565before in [#14635](https://github.com/bitcoin/bitcoin/pull/14635).
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.