WIP: private broadcast: Extra guard against unintended non-private broadcast of private transactions #36607

Draft
optout21 wants to merge 4 commits from 2610-privbcast-guard into master AGit
optout21 commented 2026-10-22 14:03:00 +00:00 (Migrated from github.com)

Motivation: Reduce the risk of accidental privacy leak happening when broadcasting non-privately a requested transaction that had been previously broadcast privately.

Background: During the initial phase of private broadcast implementation there were unforeseen instances when a private transaction could get broadcast non-privately (see #35032 #35319 #35410 #36309 #36312 #36277 #36330).

Currently known pathways:

  • Re-submission through submitpackage
  • Wallet-rebroadcast (when a private transaction is "picked up" by the wallet, and rebrodcast after 1-2 days)

Note that these are being addressed, but other, currently non-identified pathways cannot be excluded.

Change summary: Add a general, extra safeguard: whenever there is a transaction broadcast request, check if the given transaction has been previously broadcast privately, and if so, refuse to broadcast non-privately.

Transaction relay is not affected, as it should not be affected by private broadcast. When we receive a previously private-broadcast transaction for the first time (it's not yet in our mempool), we relay it as any other relayed transaction. Behavior is unchanged in this regard.

Notes:

  • Prerequisite: This is built on top of #36477, as keeping finished private broadcasts in the queue is a prerequisite for this change to work.
  • This proposed change is not an alternative to the use-case specific safeguards, but a complementary one.
  • Testing currently uses the two pathways listed above. When they are closed, testing will be more difficult (i.e., it is hard to establish whether non-private broadcast is prevented by the use-case specific or the present generic guard).
  • The private broadcast queue is not persisted, it doesn't survive node restarts
  • Entries deleted via abortprivatebroadcast will be forgotten.

Keeping as Draft, because the prerequisite #36477 is pending.

Motivation: Reduce the risk of accidental privacy leak happening when broadcasting non-privately a requested transaction that had been previously broadcast privately. Background: During the initial phase of private broadcast implementation there were unforeseen instances when a private transaction could get broadcast non-privately (see #35032 #35319 #35410 #36309 #36312 #36277 #36330). Currently known pathways: - Re-submission through `submitpackage` - Wallet-rebroadcast (when a private transaction is "picked up" by the wallet, and rebrodcast after 1-2 days) Note that these are being addressed, but other, currently non-identified pathways cannot be excluded. Change summary: Add a general, extra safeguard: whenever there is a transaction broadcast request, check if the given transaction has been previously broadcast privately, and if so, refuse to broadcast non-privately. Transaction relay is not affected, as it should not be affected by private broadcast. When we receive a previously private-broadcast transaction for the first time (it's not yet in our mempool), we relay it as any other relayed transaction. Behavior is unchanged in this regard. Notes: - Prerequisite: This is built on top of #36477, as keeping finished private broadcasts in the queue is a prerequisite for this change to work. - This proposed change is not an alternative to the use-case specific safeguards, but a complementary one. - Testing currently uses the two pathways listed above. When they are closed, testing will be more difficult (i.e., it is hard to establish whether non-private broadcast is prevented by the use-case specific or the present generic guard). - The private broadcast queue is not persisted, it doesn't survive node restarts - Entries deleted via `abortprivatebroadcast` will be forgotten. Keeping as Draft, because the prerequisite #36477 is pending.
DrahtBot commented 2026-10-22 14:03:11 +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.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36477 (private broadcast: show finished transactions in getprivatebroadcastinfo by vasild)
  • #36429 ([RFC] Scheduled transaction broadcast, minimal by optout21)
  • #35888 (net: reject oversized outbound messages by l0rinc)
  • #35502 (refactor: extract per-message helpers from ProcessMessage (move-only) by w0xlt)
  • #34824 (net: encapsulate TxRelay state and replace recursive mutexes by w0xlt)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • test/functional/p2p_private_broadcast_then_public.py: privateproadcast-aware → private-broadcast-aware [misspelling]

2026-11-02 11:36:49

<!--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/36607 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36607.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36607#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. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36477](https://github.com/bitcoin/bitcoin/pull/36477) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36477.svg"></sub> (private broadcast: show finished transactions in getprivatebroadcastinfo by vasild) * [#36429](https://github.com/bitcoin/bitcoin/pull/36429) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36429.svg"></sub> ([RFC] Scheduled transaction broadcast, minimal by optout21) * [#35888](https://github.com/bitcoin/bitcoin/pull/35888) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35888.svg"></sub> (net: reject oversized outbound messages by l0rinc) * [#35502](https://github.com/bitcoin/bitcoin/pull/35502) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35502.svg"></sub> (refactor: extract per-message helpers from ProcessMessage (move-only) by w0xlt) * [#34824](https://github.com/bitcoin/bitcoin/pull/34824) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34824.svg"></sub> (net: encapsulate TxRelay state and replace recursive mutexes by w0xlt) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible typos and grammar issues: - `test/functional/p2p_private_broadcast_then_public.py`: `privateproadcast-aware` → `private-broadcast-aware` [misspelling] <sup>2026-11-02 11:36:49</sup>
First-time contributor

2 additional verified findings in the full report.

Earlier concerns remain unresolved; see the full report for their current assessments.

🟠 Minor · A local resubmission can stop retries without announcing the transaction

If earlier private sends did not propagate the transaction, a later submitpackage can suppress its public announcement and end private retries while still reporting success.

Location: src/net_processing.cpp:2491 (head).

🟠 Minor · The guard does not suppress announcements of same-txid witness variants

A requested announcement of a valid alternate witness for a privately broadcast transaction is not suppressed, and the shared txid links it to the private transaction; no in-tree producer of such a variant was identified.

Location: src/private_broadcast.cpp:89 (head).

🟠 Minor · Calculate remaining attempts from retry eligibility

private_broadcast.cpp:198: a resolved entry that is still IsPending (echoed before all initial sends were picked) takes the else branch and reports m_max_send_attempts - sent, e.g. 999, although only the remaining planned sends can occur.

Location: src/private_broadcast.cpp:197 (head).

🔵 Suggestion · Eviction removes the guard for transactions that have not propagated

After a finished entry is evicted, a later wallet resend or submitpackage announces the transaction publicly; whether 10,000 entries cover the resend interval depends on unbounded private-broadcast volume.

Location: src/private_broadcast.cpp:41 (head).

🔵 Suggestion · Peers can still request suppressed transactions from the mempool

The guard stops the INV but leaves the transaction available to FindTxForGetData, so orphan resolution or a probing peer can still fetch it from this node.

Location: src/net_processing.cpp:2494 (head).

🔵 Suggestion · The fuzz model does not verify which finished entry is evicted

An implementation that evicts the newest or an arbitrary finished entry would still pass, although the header and release note promise oldest-first eviction.

Location: src/test/fuzz/private_broadcast.cpp:140 (head).


Reviewed: 350a7f37832c · Full review report · Previous reports

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:6f232c871bca65facadc248ad7ecd634f87b0b5f6936bc30593af890589888f1:0cfbbc826fdd30e42f35c9a5b7d389c0902089c94f2400654bb32123e69823f6 --> <!-- ralph-base:6ed5aad06111177c39f9b9f07a52634476380ae1 --> <!-- ralph-head:350a7f37832cba1fc4e453806efd2f4726553968 --> <!-- ralph-case:23f6dea6d3a54079a4235f1a120a653e214b3d6f738a1abcd087196541112070 --> [2 additional verified findings in the full report](<https://review.fish.foo/traces/36607-350a7f37832cba1fc4e453806efd2f4726553968-1713-8.html>). Earlier concerns remain unresolved; see the full report for their current assessments. **🟠 Minor · A local resubmission can stop retries without announcing the transaction** If earlier private sends did not propagate the transaction, a later `submitpackage` can suppress its public announcement and end private retries while still reporting success. Location: [`src/net_processing.cpp:2491`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/350a7f37832cba1fc4e453806efd2f4726553968/src/net_processing.cpp#L2491>) (head). **🟠 Minor · The guard does not suppress announcements of same-txid witness variants** A requested announcement of a valid alternate witness for a privately broadcast transaction is not suppressed, and the shared txid links it to the private transaction; no in-tree producer of such a variant was identified. Location: [`src/private_broadcast.cpp:89`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/350a7f37832cba1fc4e453806efd2f4726553968/src/private_broadcast.cpp#L89>) (head). **🟠 Minor · Calculate remaining attempts from retry eligibility** private_broadcast.cpp:198: a resolved entry that is still IsPending (echoed before all initial sends were picked) takes the else branch and reports m_max_send_attempts - sent, e.g. 999, although only the remaining planned sends can occur. Location: [`src/private_broadcast.cpp:197`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/350a7f37832cba1fc4e453806efd2f4726553968/src/private_broadcast.cpp#L197>) (head). **🔵 Suggestion · Eviction removes the guard for transactions that have not propagated** After a finished entry is evicted, a later wallet resend or `submitpackage` announces the transaction publicly; whether 10,000 entries cover the resend interval depends on unbounded private-broadcast volume. Location: [`src/private_broadcast.cpp:41`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/350a7f37832cba1fc4e453806efd2f4726553968/src/private_broadcast.cpp#L41>) (head). **🔵 Suggestion · Peers can still request suppressed transactions from the mempool** The guard stops the INV but leaves the transaction available to `FindTxForGetData`, so orphan resolution or a probing peer can still fetch it from this node. Location: [`src/net_processing.cpp:2494`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/350a7f37832cba1fc4e453806efd2f4726553968/src/net_processing.cpp#L2494>) (head). **🔵 Suggestion · The fuzz model does not verify which finished entry is evicted** An implementation that evicts the newest or an arbitrary finished entry would still pass, although the header and release note promise oldest-first eviction. Location: [`src/test/fuzz/private_broadcast.cpp:140`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/350a7f37832cba1fc4e453806efd2f4726553968/src/test/fuzz/private_broadcast.cpp#L140>) (head). <!-- Review tier: sensitive --> --- Reviewed: [`350a7f37832c`](<https://git.fish.foo/bitcoin/bitcoin/commit/350a7f37832cba1fc4e453806efd2f4726553968>) · [Full review report](<https://review.fish.foo/traces/36607-350a7f37832cba1fc4e453806efd2f4726553968-1713-8.html>) · [Previous reports](<https://review.fish.foo/traces/36607/>)
optout21 commented 2026-10-28 07:42:39 +00:00 (Migrated from github.com)

CI failure: TSan fails. It may be related to the test pushing the mock time by 36 hours, which may affect some rate limiting. Investigating.

CI failure: `TSan` fails. It may be related to the test pushing the mock time by 36 hours, which may affect some rate limiting. Investigating.
optout21 commented 2026-10-28 08:16:40 +00:00 (Migrated from github.com)

Attempted fix for "TSan" CI timeout.

Likely root cause: In the wallet resend part, node0's mocktime jumps 36 hours and then stays frozen. If node0's message handler processes the nodes[2] connection between the jump and the wallet resubmit, it resets that peer's inv trickle timer to the frozen time plus a random delay, so the timer never expires and the inv for the resent transaction is never sent.

Attempted fix: start node0 with -whitelist=noban,[email protected], which gives its manual connections noban permission so they skip the trickle timer, as wallet_resendwallettransactions.py does via noban_tx_relay.

git range-diff 7b2aae41d79624abc87198932d699ae77ec36323...0cd792580f01796d0ed16d9cf415f7b8a6ac5f20

Attempted fix for "TSan" CI timeout. Likely root cause: In the wallet resend part, node0's mocktime jumps 36 hours and then stays frozen. If node0's message handler processes the nodes[2] connection between the jump and the wallet resubmit, it resets that peer's inv trickle timer to the frozen time plus a random delay, so the timer never expires and the inv for the resent transaction is never sent. Attempted fix: start node0 with `-whitelist=noban,[email protected]`, which gives its manual connections `noban` permission so they skip the trickle timer, as `wallet_resendwallettransactions.py` does via `noban_tx_relay`. `git range-diff 7b2aae41d79624abc87198932d699ae77ec36323...0cd792580f01796d0ed16d9cf415f7b8a6ac5f20`
maflcko commented 2026-10-28 08:37:13 +00:00 (Migrated from github.com)

Attempted fix: start node0 with -whitelist=noban,[email protected], which gives its manual connections noban permission so they skip the trickle timer, as wallet_resendwallettransactions.py does via noban_tx_relay.

Haven't looked closely, but I wonder if this is the correct fix here. wallet_resendwallettransactions.py only cares about the day-long resend-delay, not the second-long trickle-delay, so it seems correct for that test. However, for the test here, either the test here cares about trickle-delay, in which case it would be cleaner to not use noban permission and instead make the test deterministic with syncs or so? Or, the test doesn't care about trickle delay, and can just set noban_tx_relay globally? Just wondering, up to you.

> Attempted fix: start node0 with `-whitelist=noban,[email protected]`, which gives its manual connections `noban` permission so they skip the trickle timer, as `wallet_resendwallettransactions.py` does via `noban_tx_relay`. Haven't looked closely, but I wonder if this is the correct fix here. `wallet_resendwallettransactions.py` only cares about the day-long resend-delay, not the second-long trickle-delay, so it seems correct for that test. However, for the test here, either the test here cares about trickle-delay, in which case it would be cleaner to not use `noban` permission and instead make the test deterministic with syncs or so? Or, the test doesn't care about trickle delay, and can just set `noban_tx_relay` globally? Just wondering, up to you.
optout21 commented 2026-10-28 09:40:29 +00:00 (Migrated from github.com)

Thanks for chiming in! Indeed, the global noban_tx_relay seems to be a cleaner way.
I used LLM assistance for finding the failure reason, I've reviewed that it looks plausible, and reproduced locally (both with and without).
This test doesn't care about trickle delay, so disabling it globally is a simpler solution. Changed now.

git range-diff 0cd792580f01796d0ed16d9cf415f7b8a6ac5f20...350a7f37832cba1fc4e453806efd2f4726553968
git range-diff 7b2aae41d79624abc87198932d699ae77ec36323...350a7f37832cba1fc4e453806efd2f4726553968

Thanks for chiming in! Indeed, the global `noban_tx_relay` seems to be a cleaner way. I used LLM assistance for finding the failure reason, I've reviewed that it looks plausible, and reproduced locally (both with and without). This test doesn't care about trickle delay, so disabling it globally is a simpler solution. Changed now. `git range-diff 0cd792580f01796d0ed16d9cf415f7b8a6ac5f20...350a7f37832cba1fc4e453806efd2f4726553968` `git range-diff 7b2aae41d79624abc87198932d699ae77ec36323...350a7f37832cba1fc4e453806efd2f4726553968`
DrahtBot commented 2026-10-29 16:45:33 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
optout21 commented 2026-11-02 11:36:30 +00:00 (Migrated from github.com)

Rebased (due to conflict)
(git range-diff 350a7f37832cba1fc4e453806efd2f4726553968...d1e83a230e65774e5b5637fe05e51ef2ad6b64bf)

Rebased (due to conflict) (`git range-diff 350a7f37832cba1fc4e453806efd2f4726553968...d1e83a230e65774e5b5637fe05e51ef2ad6b64bf`)
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!36607
No description provided.