doc: document -blocknotify, -walletnotify and other -*notify options #35518

Open
fernandguil wants to merge 1 commit from doc/notify-options into master AGit
fernandguil commented 2026-06-12 03:27:33 +00:00 (Migrated from github.com)

Partially addresses #14278, which asks for documentation of the user-facing -*notify behaviors. The five shell-command notification options currently have no documentation outside of --help text, and several behaviors are only discoverable by reading the source.

Adds doc/notifications.md (indexed in doc/README.md) covering:

-blocknotify

  • Suppressed during initial block download and reindex — only fires once the node reaches the post-init sync state (src/init.cpp, NotifyBlockTip_connect handler)
  • Each event runs the command in a detached thread, so there is no ordering guarantee between successive notifications — this directly documents the behavior behind the ordering question raised in #14278 and the test discrepancy noted in #14275

-walletnotify

  • Fires on mempool entry, confirmation, and when a transaction returns to unconfirmed due to a conflict with a newly connected block (CWallet::transactionRemovedFromMempool)
  • Documents all four substitutions (%s, %b, %h, %w) and the Windows limitation for %w

-alertnotify

  • Fires once per distinct warning condition; message is sanitized and single-quoted before substitution (src/node/kernel_notifications.cpp)

-startupnotify / -shutdownnotify

  • Startup command does not block initialization; shutdown commands may be specified multiple times, run in parallel, and shutdown waits for them to complete (src/init.cpp)

All described behavior is derived directly from the source.

Partially addresses #14278, which asks for documentation of the user-facing `-*notify` behaviors. The five shell-command notification options currently have no documentation outside of `--help` text, and several behaviors are only discoverable by reading the source. Adds `doc/notifications.md` (indexed in `doc/README.md`) covering: **`-blocknotify`** - Suppressed during initial block download and reindex — only fires once the node reaches the post-init sync state (`src/init.cpp`, `NotifyBlockTip_connect` handler) - Each event runs the command in a detached thread, so **there is no ordering guarantee** between successive notifications — this directly documents the behavior behind the ordering question raised in #14278 and the test discrepancy noted in #14275 **`-walletnotify`** - Fires on mempool entry, confirmation, and when a transaction returns to unconfirmed due to a conflict with a newly connected block (`CWallet::transactionRemovedFromMempool`) - Documents all four substitutions (`%s`, `%b`, `%h`, `%w`) and the Windows limitation for `%w` **`-alertnotify`** - Fires once per distinct warning condition; message is sanitized and single-quoted before substitution (`src/node/kernel_notifications.cpp`) **`-startupnotify` / `-shutdownnotify`** - Startup command does not block initialization; shutdown commands may be specified multiple times, run in parallel, and shutdown waits for them to complete (`src/init.cpp`) All described behavior is derived directly from the source.
DrahtBot commented 2026-06-12 03:27:41 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK sedited

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35518 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35518.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35518#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/35518#pullrequestreview-4764304499) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
sedited commented 2026-06-21 19:40:50 +00:00 (Migrated from github.com)

I don't think exhaustively documenting every command here is useful, and would prefer that the command-level docs continue to live in the help output / man page. Some of the documentation there could be expanded a bit, for example with the behaviour during IBD described here. The doc introduced here could be distilled down to a single paragraph explaining threading and ordering behaviour plus a list of the commands.

I don't think exhaustively documenting every command here is useful, and would prefer that the command-level docs continue to live in the help output / man page. Some of the documentation there could be expanded a bit, for example with the behaviour during IBD described here. The doc introduced here could be distilled down to a single paragraph explaining threading and ordering behaviour plus a list of the commands.
fernandguil commented 2026-06-23 02:11:55 +00:00 (Migrated from github.com)

Thanks for the feedback. I've distilled the doc down to a single paragraph on the threading/ordering behavior plus a list of the options, leaving the per-option details in --help. I've also opened #35586 to add the IBD/reindex note to the -blocknotify help text, per your suggestion.

Thanks for the feedback. I've distilled the doc down to a single paragraph on the threading/ordering behavior plus a list of the options, leaving the per-option details in `--help`. I've also opened #35586 to add the IBD/reindex note to the `-blocknotify` help text, per your suggestion.
sedited (Migrated from github.com) reviewed 2026-06-29 19:57:56 +00:00
sedited (Migrated from github.com) commented 2026-06-29 19:49:12 +00:00

I would drop this entire sentence about zmq. This is obvious for developers that know what zmq is.

I would drop this entire sentence about zmq. This is obvious for developers that know what zmq is.
sedited (Migrated from github.com) commented 2026-06-29 19:51:16 +00:00

nit: Skip the em dash. Just make this two sentences.

nit: Skip the em dash. Just make this two sentences.
Lines 15-18
sedited (Migrated from github.com) commented 2026-06-29 19:54:22 +00:00

I'm not sure I agree with this last sentence. It is already qualified that events may fire out of order, but internally they seem consistent to me. I would drop this sentence too.

I'm not sure I agree with this last sentence. It is already qualified that events may fire out of order, but internally they seem consistent to me. I would drop this sentence too.
fernandguil commented 2026-06-30 01:21:13 +00:00 (Migrated from github.com)

Thanks, all good points. Done: dropped the ZMQ comparison and the -shutdownnotify "return quickly" sentence, and split the em-dash sentence in two.

Thanks, all good points. Done: dropped the ZMQ comparison and the `-shutdownnotify` "return quickly" sentence, and split the em-dash sentence in two.
sedited (Migrated from github.com) approved these changes 2026-07-23 13:06:00 +00:00
sedited (Migrated from github.com) left a comment
ACK 5801ce70b34b5429ed184645daf85b2fb2ab7200
willcl-ark commented 2026-09-15 12:00:57 +00:00 (Migrated from github.com)

I will take a look here soon.

I did once have a got at correcting this myself with the intention of closing out #14278 in one go, but the branch may be outdated now: https://github.com/willcl-ark/bitcoin/tree/callback-docs-cleanup

I remember adding a few tests for guarantees I we were giving but were untested (see commits in the branch), that may be something we want to do here too, if it makes sense...

edit: yeah re-reading my old branch I don't feel that happy with it now, I have now updated it and will compare with this branch soon

I will take a look here soon. I did once have a got at correcting this myself with the intention of closing out #14278 in one go, but the branch may be outdated now: https://github.com/willcl-ark/bitcoin/tree/callback-docs-cleanup I remember adding a few tests for guarantees I we were giving but were untested (see commits in the branch), that may be something we want to do here too, if it makes sense... edit: yeah re-reading my old branch I don't feel that happy with it now, I have now updated it and will compare with this branch soon
sedited commented 2026-09-16 08:27:14 +00:00 (Migrated from github.com)

I remember adding a few tests for guarantees I we were giving but were untested (see commits in the branch), that may be something we want to do here too, if it makes sense...

I'm not sure if we really want to guarantee order. It just seems like a brittle thing to be promising. The tests might also not fully capture the ordering guarantee. A test exercising ordering between e.g. rpc and zmq might not catch something in a different component, or in some edge case that we didn't happen to think of. Has anybody complained about this since the original issue was opened? I can also see an argument for it though: We implicitly guarantee order and unwittingly changing something might break somebody's deployment.

> I remember adding a few tests for guarantees I we were giving but were untested (see commits in the branch), that may be something we want to do here too, if it makes sense... I'm not sure if we really want to guarantee order. It just seems like a brittle thing to be promising. The tests might also not fully capture the ordering guarantee. A test exercising ordering between e.g. rpc and zmq might not catch something in a different component, or in some edge case that we didn't happen to think of. Has anybody complained about this since the original issue was opened? I can also see an argument for it though: We implicitly guarantee order and unwittingly changing something might break somebody's deployment.
willcl-ark commented 2026-09-16 10:18:12 +00:00 (Migrated from github.com)

I'm not sure if we really want to guarantee order. It just seems like a brittle thing to be promising.

Agreed, and ordering (or really any notification legitimacy) is called out here in my branch as basically never being guaranteed:

Bitcoin Core can notify external software about node, chain, mempool, wallet,
and warning events. Notifications are useful for waking up external processes,
but they are not a substitute for querying the node for current state. When a
notification is received, use the RPC interface to confirm the state that is
relevant to the application.

The tested guarantees I was talking about are here as standalone commits.

> I'm not sure if we really want to guarantee order. It just seems like a brittle thing to be promising. Agreed, and ordering (or really any notification legitimacy) is called out [here](https://github.com/bitcoin/bitcoin/compare/master...willcl-ark:bitcoin:callback-docs-cleanup#diff-4ed99d7ef56e26c306806d3e87483f669177e0af8c63d4bb88c63b0df327f762R3-R7) in my branch as basically never being guaranteed: > Bitcoin Core can notify external software about node, chain, mempool, wallet, and warning events. Notifications are useful for waking up external processes, but they are not a substitute for querying the node for current state. When a notification is received, use the RPC interface to confirm the state that is relevant to the application. The tested guarantees I was talking about are [here](https://github.com/bitcoin/bitcoin/compare/master...willcl-ark:bitcoin:callback-docs-cleanup) as standalone commits.
sedited commented 2026-10-31 11:07:59 +00:00 (Migrated from github.com)

I will take a look here soon.

Ping @willcl-ark

> I will take a look here soon. Ping @willcl-ark
First-time contributor

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: 5801ce70b34b · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:8541d3fafd3ea45d3ad824914bf78a806527457ae4801671a2c4a580beddb288:1e657457416e20a18d8d2d136919c48e28e1bfed7a76c26939ab1ca10a232c6a --> <!-- ralph-base:ab7e668cc6af5d716ad40166d1f88235a2f6d25d --> <!-- ralph-head:5801ce70b34b5429ed184645daf85b2fb2ab7200 --> <!-- ralph-case:70e012e3903c0f746778c6652a16c0d4270c58b98b98f8538eb8f31948a6a455 --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`5801ce70b34b`](<https://git.fish.foo/bitcoin/bitcoin/commit/5801ce70b34b5429ed184645daf85b2fb2ab7200>) · [Full review report](<https://review.fish.foo/traces/35518-5801ce70b34b5429ed184645daf85b2fb2ab7200-1890-1.html>) · [Previous reports](<https://review.fish.foo/traces/35518/>) [permalink](<https://review.fish.foo/traces/35518-5801ce70b34b5429ed184645daf85b2fb2ab7200-1890-1.html>)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35518
No description provided.