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.
1251- `-BEGIN VERIFY SCRIPT-`1252- `-END VERIFY SCRIPT-`1254The scripted-diff is verified by the tool `test/lint/commit-script-check.sh`. The tool's default behavior, when supplied1255with a commit is to verify all scripted-diffs from the beginning of time up to said commit. Internally, the tool passes1256the first supplied argument to `git rev-list --reverse` to determine which commits to verify script-diffs for, ignoring1257commits that don't conform to the commit message format described above.1259For development, it might be more convenient to verify all scripted-diffs in a range `A..B`, for example:1261```bash1262test/lint/commit-script-check.sh origin/master..HEAD1263```1265### Suggestions and examples1267If you need to replace in multiple files, prefer `git ls-files` to `find` or globbing, and `git grep` to `grep`, to1268avoid changing files that are not under version control.1270For efficient replacement scripts, reduce the selection to the files that potentially need to be modified, so for1271example, instead of a blanket `git ls-files src | xargs sed -i s/apple/orange/`, use1272`git grep -l apple src | xargs sed -i s/apple/orange/`.1274Also, it is good to keep the selection of files as specific as possible — for example, replace only in directories where1275you expect replacements — because it reduces the risk that a rebase of your commit by re-running the script will1276introduce accidental changes.1278Some good examples of scripted-diff:1280- [scripted-diff: Rename InitInterfaces to NodeContext](https://github.com/bitcoin/bitcoin/commit/301bd41a2e6765b185bd55f4c541f9e27aeea29d)1281uses an elegant script to replace occurrences of multiple terms in all source files.1283- [scripted-diff: Remove g_connman, g_banman globals](https://github.com/bitcoin/bitcoin/commit/8922d7f6b751a3e6b3b9f6fb7961c442877fb65a)1284replaces specific terms in a list of specific source files.1286- [scripted-diff: Replace fprintf with tfm::format](https://github.com/bitcoin/bitcoin/commit/fac03ec43a15ad547161e37e53ea82482cc508f9)1287does a global replacement but excludes certain directories.1289To find all previous uses of scripted diffs in the repository, do:1291```1292git log --grep="-BEGIN VERIFY SCRIPT-"1293```1295## Release notes1297Release notes should be written for any PR that:1299- introduces a notable new feature1300- fixes a significant bug1301- changes an API or configuration model1302- makes any other visible change to the end-user experience.1304Release notes should be added to a PR-specific release note file at1305`/doc/release-notes-<PR number>.md` to avoid conflicts between multiple PRs.1306All `release-notes*` files are merged into a single `release-notes-<version>.md` file prior to the release.1308## RPC interface guidelines1310A few guidelines for introducing and reviewing new RPC interfaces:1312- Method naming: use consecutive lower-case names such as `getrawtransaction` and `submitblock`.1314- *Rationale*: Consistency with the existing interface.1316- Argument and field naming: please consider whether there is already a naming1317style or spelling convention in the API for the type of object in question1318(`blockhash`, for example), and if so, try to use that. If not, use snake case1319`fee_delta` (and not, e.g. `feedelta` or camel case `feeDelta`).1321- *Rationale*: Consistency with the existing interface.1323- Use the JSON parser for parsing, don't manually parse integers or strings from1324arguments unless absolutely necessary.1326- *Rationale*: Introduces hand-rolled string manipulation code at both the caller and callee sites,1327which is error-prone, and it is easy to get things such as escaping wrong.1328JSON already supports nested data structures, no need to re-invent the wheel.1330- *Exception*: AmountFromValue can parse amounts as string. This was introduced because many JSON1331parsers and formatters hard-code handling decimal numbers as floating-point1332values, resulting in potential loss of precision. This is unacceptable for1333monetary values. **Always** use `AmountFromValue` and `ValueFromAmount` when1334inputting or outputting monetary values. The only exceptions to this are1335`prioritisetransaction` and `getblocktemplate` because their interface1336is specified as-is in BIP22.1338- Missing arguments and 'null' should be treated the same: as default values. If there is no1339default value, both cases should fail in the same way. The easiest way to follow this1340guideline is to detect unspecified arguments with `params[x].isNull()` instead of1341`params.size() <= x`. The former returns true if the argument is either null or missing,1342while the latter returns true if is missing, and false if it is null.1344- *Rationale*: Avoids surprises when switching to name-based arguments. Missing name-based arguments1345are passed as 'null'.1347- Try not to overload methods on argument type. E.g. don't make `getblock(true)` and `getblock("hash")`1348do different things.1350- *Rationale*: This is impossible to use with `bitcoin-cli`, and can be surprising to users.1352- *Exception*: Some RPC calls can take both an `int` and `bool`, most notably when a bool was switched1353to a multi-value, or due to other historical reasons. **Always** have false map to 0 and1354true to 1 in this case.1356- For new RPC methods, if implementing a `verbosity` argument, use integer verbosity rather than boolean.1357Disallow usage of boolean verbosity (see `ParseVerbosity()` in [util.h](/src/rpc/util.h)).1359- *Rationale*: Integer verbosity allows for multiple values. Undocumented boolean verbosity is deprecated1360and new RPC methods should prevent its use.1362- Add every non-string RPC argument `(method, idx, name)` to the table `vRPCConvertParams` in `rpc/client.cpp`.1364- *Rationale*: `bitcoin-cli` and the GUI debug console use this table to determine how to1365convert a plaintext command line to JSON. If the types don't match, the method can be unusable1366from there.1368- A RPC method must either be a wallet method or a non-wallet method. Do not1369introduce new methods that differ in behavior based on the presence of a wallet.1371- *Rationale*: As well as complicating the implementation and interfering1372with the introduction of multi-wallet, wallet and non-wallet code should be1373separated to avoid introducing circular dependencies between code units.1375- Try to make the RPC response a JSON object.1377- *Rationale*: If a RPC response is not a JSON object, then it is harder to avoid API breakage if1378new data in the response is needed.1380- Wallet RPCs call BlockUntilSyncedToCurrentChain to maintain consistency with1381`getblockchaininfo`'s state immediately prior to the call's execution. Wallet1382RPCs whose behavior does *not* depend on the current chainstate may omit this1383call.1385- *Rationale*: In previous versions of Bitcoin Core, the wallet was always1386in-sync with the chainstate (by virtue of them all being updated in the1387same cs_main lock). In order to maintain the behavior that wallet RPCs1388return results as of at least the highest best-known block an RPC1389client may be aware of prior to entering a wallet RPC call, we must block1390until the wallet is caught up to the chainstate as of the RPC call's entry.1391This also makes the API much easier for RPC clients to reason about.1393- Use *invalid* bech32 addresses (e.g. in the constant array `EXAMPLE_ADDRESS`) for1394`RPCExamples` help documentation.1396- *Rationale*: Prevent accidental transactions by users and encourage the use1397of bech32 addresses by default.1399- Use the `UNIX_EPOCH_TIME` constant when describing UNIX epoch time or1400timestamps in the documentation.1402- *Rationale*: User-facing consistency.1404- Use `fs::path::u8string()`/`fs::path::utf8string()` and `fs::u8path()` functions when converting path1405to JSON strings, not `fs::PathToString` and `fs::PathFromString`1407- *Rationale*: JSON strings are Unicode strings, not byte strings, and1408RFC8259 requires JSON to be encoded as UTF-8.1410A few guidelines for modifying existing RPC interfaces:1412- It's preferable to avoid changing an RPC in a backward-incompatible manner, but in that case, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data type changes (e.g. from `{"warnings":""}` to `{"warnings":[]}`, changing a value from a string to a number, etc.), logical meaning changes of a value, key name changes (e.g. `{"warning":""}` to `{"warnings":""}`), or removing a key from an object. Adding a key to an object is generally considered backward-compatible. Include a release note that refers the user to the RPC help for details of feature deprecation and re-enabling previous behavior. [Example RPC help](https://github.com/bitcoin/bitcoin/blob/94f0adcc/src/rpc/blockchain.cpp#L1316-L1323).1414- *Rationale*: Changes in RPC JSON structure can break downstream application compatibility. Implementation of `deprecatedrpc` provides a grace period for downstream applications to migrate. Release notes provide notification to downstream users.1416## Feature deprecation and removal process1418Bitcoin Core uses a structured process for deprecating and removing features to give1419downstream users and applications time to migrate.1421### General principles1423- The minimum deprecation **grace period** for a feature that is going to be removed is one1424major release.1425- Any deprecation or removal must come with a release note.1427### RPC methods and fields1429- To deprecate an entire RPC method, gate the old behavior behind `-deprecatedrpc=<feature>`.1430Deprecated features should remain accessible via this flag during the grace period so1431downstream users are not immediately broken.1432- The RPC help text must mention the deprecation and the `-deprecatedrpc=<feature>` flag1433that re-enables it. For example:1434```1435"\nDeprecated in v25.0, use the `newfoo` RPC instead. Start bitcoind with"1436" `-deprecatedrpc=foo` to continue using this RPC.\n"1437```1439### Startup options1441- To deprecate a startup option, emit a warning via `LogWarning` or `InitWarning` when the1442option is used, so users are notified at startup.1443- Update the option's help text to indicate it is deprecated and, if applicable, will be1444removed in a future release.1446### REST interface1448- Deprecated REST endpoints or behaviors should be documented in `doc/REST-interface.md`1449with the version they were deprecated.1451### ZMQ1453- Deprecated ZMQ topics or behaviors should be documented in `doc/zmq.md` with the version1454they were deprecated.1456## Internal interface guidelines1458Internal interfaces between parts of the codebase that are meant to be1459independent (node, wallet, GUI), are defined in1460[`src/interfaces/`](../src/interfaces/). The main interface classes defined1461there are [`interfaces::Chain`](../src/interfaces/chain.h), used by wallet to1462access the node's latest chain state,1463[`interfaces::Node`](../src/interfaces/node.h), used by the GUI to control the1464node, [`interfaces::Wallet`](../src/interfaces/wallet.h), used by the GUI1465to control an individual wallet and [`interfaces::Mining`](../src/interfaces/mining.h),1466used by RPC to generate block templates. There are also more specialized interface1467types like [`interfaces::Handler`](../src/interfaces/handler.h)1468[`interfaces::ChainClient`](../src/interfaces/chain.h) passed to and from1469various interface methods.1471Interface classes are written in a particular style so node, wallet, and GUI1472code doesn't need to run in the same process, and so the class declarations1473work more easily with tools and libraries supporting interprocess1474communication:1476- Interface classes should be abstract and have methods that are [pure1477virtual](https://en.cppreference.com/w/cpp/language/abstract_class). This1478allows multiple implementations to inherit from the same interface class,1479particularly so one implementation can execute functionality in the local1480process, and other implementations can forward calls to remote processes.1482- Interface method definitions should wrap existing functionality instead of1483implementing new functionality. Any substantial new node or wallet1484functionality should be implemented in [`src/node/`](../src/node/) or1485[`src/wallet/`](../src/wallet/) and just exposed in1486[`src/interfaces/`](../src/interfaces/) instead of being implemented there,1487so it can be more modular and accessible to unit tests.1489- Interface method parameter and return types should either be serializable or1490be other interface classes. Interface methods shouldn't pass references to1491objects that can't be serialized or accessed from another process.1493Examples:1495```c++1496// Good: takes string argument and returns interface class pointer1497virtual unique_ptr<interfaces::Wallet> loadWallet(std::string filename) = 0;1499// Bad: returns CWallet reference that can't be used from another process1500virtual CWallet& loadWallet(std::string filename) = 0;
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.