wallet: extend -walletbroadcast to allow initial send only #36380

Open
vasild wants to merge 1 commit from walletrebroadcast into master AGit
vasild commented 2026-09-29 09:01:33 +00:00 (Migrated from github.com)

-walletbroadcast was a boolean 0 or 1 meaning either "do not broadcast transactions or "initial broadcast plus periodic re-broadcast (every 12-36 hours)".

Add a new possible value initialonly which would allow the user to configure the wallet to do the initial broadcast only and not to do the periodic rebroadcasts.

No new configuration options and no change in default behavior.

`-walletbroadcast` was a boolean `0` or `1` meaning either "do not broadcast transactions or "initial broadcast plus periodic re-broadcast (every 12-36 hours)". Add a new possible value `initialonly` which would allow the user to configure the wallet to do the initial broadcast only and not to do the periodic rebroadcasts. No new configuration options and no change in default behavior.
DrahtBot commented 2026-09-29 09:01: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
Concept NACK achow101

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36897 (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101)
  • #36481 (wallet, rpc, gui: Allow users to manually rebroadcast a wallet transaction by achow101)
  • #36398 (wallet: only rebroadcast transactions originating from the wallet by mzumsande)
  • #35786 (wallet: drop spent parents redundant cache invalidation and notification by furszy)
  • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)

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.

<!--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/36380 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36380.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36380#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 | | ---- | --------- | | Concept NACK | [achow101](https://github.com/bitcoin/bitcoin/pull/36380#issuecomment-5940478231) | 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. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36897](https://github.com/bitcoin/bitcoin/pull/36897) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36897.svg"></sub> (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101) * [#36481](https://github.com/bitcoin/bitcoin/pull/36481) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36481.svg"></sub> (wallet, rpc, gui: Allow users to manually rebroadcast a wallet transaction by achow101) * [#36398](https://github.com/bitcoin/bitcoin/pull/36398) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36398.svg"></sub> (wallet: only rebroadcast transactions originating from the wallet by mzumsande) * [#35786](https://github.com/bitcoin/bitcoin/pull/35786) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35786.svg"></sub> (wallet: drop spent parents redundant cache invalidation and notification by furszy) * [#27865](https://github.com/bitcoin/bitcoin/pull/27865) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27865.svg"></sub> (wallet: Track no-longer-spendable TXOs separately by achow101) 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-->
DrahtBot commented 2026-09-29 09:12:34 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/36546473252/job/109333967547
LLM reason (✨ experimental): CI failed because the lint “doc” check detected undocumented command-line arguments: -walletbroadcast and -walletrebroadcast (AssertionError).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `lint`: https://github.com/bitcoin/bitcoin/actions/runs/36546473252/job/109333967547</sub> <sub>LLM reason (✨ experimental): CI failed because the lint “doc” check detected undocumented command-line arguments: `-walletbroadcast` and `-walletrebroadcast` (AssertionError).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
First-time contributor

Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive linked from the Review report for their assessments.

🔵 Suggestion · initialonly also disables non-relaying mempool restoration

With -walletbroadcast=initialonly, startup and descriptor import skip non-relaying restoration, leaving missing pending transactions outside the local mempool and their change unavailable to default coin selection.

Location: src/wallet/wallet.cpp:1884 (head).

🔵 Suggestion · No test exercises -walletbroadcast=initialonly

No checked-in test selects the new mode, so mapping initialonly to either NEVER or INITIAL_AND_PERIODIC would escape the existing assertions.

Location: src/wallet/wallet.cpp:2865 (head).


Reviewed: 17bad7c1073d · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:312ddb2095238aa2ca395a9cc39b05ab5a38a7177afbdb0d69098df9c3e0bef9:9a7f127b15c6116c267953d38288a9f17ec7c7bcd3a975fb71a2db8bfd974dbf --> <!-- ralph-base:afedb19cca4c3b40d89514fb0c66b0c20e4f5d62 --> <!-- ralph-head:17bad7c1073dc22d6dd8596e3786b0a01236db16 --> <!-- ralph-case:c1fd97f6e32caa093f12d38304c8c5b513a8b9c84b442f484bcbd1b43e67c3ec --> Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive linked from the Review report for their assessments. **🔵 Suggestion · `initialonly` also disables non-relaying mempool restoration** With `-walletbroadcast=initialonly`, startup and descriptor import skip non-relaying restoration, leaving missing pending transactions outside the local mempool and their change unavailable to default coin selection. Location: [`src/wallet/wallet.cpp:1884`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/17bad7c1073dc22d6dd8596e3786b0a01236db16/src/wallet/wallet.cpp#L1884>) (head). **🔵 Suggestion · No test exercises `-walletbroadcast=initialonly`** No checked-in test selects the new mode, so mapping `initialonly` to either `NEVER` or `INITIAL_AND_PERIODIC` would escape the existing assertions. Location: [`src/wallet/wallet.cpp:2865`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/17bad7c1073dc22d6dd8596e3786b0a01236db16/src/wallet/wallet.cpp#L2865>) (head). <!-- Review tier: sensitive --> --- Reviewed: [`17bad7c1073d`](<https://git.fish.foo/bitcoin/bitcoin/commit/17bad7c1073dc22d6dd8596e3786b0a01236db16>) · [Review report](<https://review.fish.foo/report/36380-17bad7c1073dc22d6dd8596e3786b0a01236db16-3337-4.html>) · [Previous reports](<https://review.fish.foo/traces/36380/>) [permalink](<https://review.fish.foo/report/36380-17bad7c1073dc22d6dd8596e3786b0a01236db16-3337-4.html>)
vicjuma (Migrated from github.com) reviewed 2026-09-29 16:27:07 +00:00
vicjuma (Migrated from github.com) commented 2026-09-29 16:26:27 +00:00

Why default to false? I feel like the responsibility for privacy should be left to users desiring privacy. The majority of them probably just want convenience. The initial -walletbroadcast did not require any setup from the user. For this, what if the user forgets to set up the -walletrebroadcast option?. IMO, I think rebroadcasting outweighs privacy so defaulting to true would be convenient. Just a thought though, I might be missing something.

Why default to false? I feel like the responsibility for privacy should be left to users desiring privacy. The majority of them probably just want convenience. The initial `-walletbroadcast` did not require any setup from the user. For this, what if the user forgets to set up the `-walletrebroadcast` option?. IMO, I think rebroadcasting outweighs privacy so defaulting to true would be convenient. Just a thought though, I might be missing something.
w0xlt commented 2026-09-29 18:53:50 +00:00 (Migrated from github.com)

Can we safely disable wallet re-broadcasting? If so, why do we need re-broadcasting at all?

Even if we choose this approach, I think extending -walletbroadcast with new modes would be cleaner than introducing another parameter with a very similar name.

Can we safely disable wallet re-broadcasting? If so, why do we need re-broadcasting at all? Even if we choose this approach, I think extending `-walletbroadcast` with new modes would be cleaner than introducing another parameter with a very similar name.
vasild (Migrated from github.com) reviewed 2026-09-30 07:51:55 +00:00
vasild (Migrated from github.com) commented 2026-09-30 07:51:55 +00:00

No strong opinion. I was influenced by https://github.com/bitcoin/bitcoin/pull/36330 which would completely disable wallet re-broadcast with no way to enable it, if privatebroadcast=1. So, this PR, even with the default to "off" is softer than that because it makes it possible to enable the wallet rebroadcast if needed.

Also, my thinking, ignoring https://github.com/bitcoin/bitcoin/pull/36330 is that the wallet re-broadcast does more harm than good. It is a privacy nightmare and only provides some service in rare cases. But this is just my guess. For sure, there are users that use it and for them it is not "rare".

This is why I think it makes sense to have the wallet re-broadcast configurable in the first place. I am fine with a default to "on" (as in master without this PR).

No strong opinion. I was influenced by https://github.com/bitcoin/bitcoin/pull/36330 which would completely disable wallet re-broadcast with no way to enable it, if `privatebroadcast=1`. So, this PR, even with the default to "off" is softer than that because it makes it possible to enable the wallet rebroadcast if needed. Also, my thinking, ignoring https://github.com/bitcoin/bitcoin/pull/36330 is that the wallet re-broadcast does more harm than good. It is a privacy nightmare and only provides some service in rare cases. But this is just my guess. For sure, there are users that use it and for them it is not "rare". This is why I think it makes sense to have the wallet re-broadcast configurable in the first place. I am fine with a default to "on" (as in `master` without this PR).
vasild commented 2026-09-30 08:04:54 +00:00 (Migrated from github.com)

Can we safely disable wallet re-broadcasting?

I think yes. Most users don't need it, but are nevertheless exposed to the privacy leaks it brings even if they never use it.

If so, why do we need re-broadcasting at all?

It serves this scenario:

  • The user creates a transaction in the wallet and broadcasts it to the network. So far so good.
  • The transaction is not very high fee so is not mined immediately.
  • Global mempool pressure increases and that causes the transaction to be evicted from everybody's mempools.
  • Global mempool pressure decreases.
  • Nobody knows about the transaction, except the user that created it.
  • It would have been mined if miners where aware of it but is never mined because the network "forgot" about it. In this case the user rebroadcasting the transaction would help.

Up to your judgement if this is rare or not, but is good to have wallet rebroadcast in such cases.

Even if we choose this approach, I think extending -walletbroadcast with new modes would be cleaner than introducing another parameter with a very similar name.

Hmm, sounds like something worth considering. Currently -walletbroadcast is a boolean. What would you suggest? Something like this maybe:

  • 0 no initial, no rebroadcast
  • 1 initial and rebroadcast
  • initialonly initial, no rebroadcast

?

> Can we safely disable wallet re-broadcasting? I think yes. Most users don't need it, but are nevertheless exposed to the privacy leaks it brings even if they never use it. > If so, why do we need re-broadcasting at all? It serves this scenario: * The user creates a transaction in the wallet and broadcasts it to the network. So far so good. * The transaction is not very high fee so is not mined immediately. * Global mempool pressure increases and that causes the transaction to be evicted from everybody's mempools. * Global mempool pressure decreases. * Nobody knows about the transaction, except the user that created it. * It would have been mined if miners where aware of it but is never mined because the network "forgot" about it. In this case the user rebroadcasting the transaction would help. Up to your judgement if this is rare or not, but is good to have wallet rebroadcast in such cases. > Even if we choose this approach, I think extending `-walletbroadcast` with new modes would be cleaner than introducing another parameter with a very similar name. Hmm, sounds like something worth considering. Currently `-walletbroadcast` is a boolean. What would you suggest? Something like this maybe: * `0` no initial, no rebroadcast * `1` initial and rebroadcast * `initialonly` initial, no rebroadcast ?
mzumsande commented 2026-10-01 14:29:29 +00:00 (Migrated from github.com)

I opened #36398 for a fix escpecially targeted at https://github.com/bitcoin/bitcoin/issues/3828, which doesn't have an option. One thing to note is that if we disable rebroadcast, we should probably also disable artificial resubmission to mempool (as explained there).

I opened #36398 for a fix escpecially targeted at https://github.com/bitcoin/bitcoin/issues/3828, which doesn't have an option. One thing to note is that if we disable rebroadcast, we should probably also disable artificial resubmission to mempool (as explained there).
achow101 commented 2026-10-01 19:49:31 +00:00 (Migrated from github.com)

I've opened #36403 where we can have more high level discussion about transaction rebroadcast in general.

I've opened #36403 where we can have more high level discussion about transaction rebroadcast in general.
achow101 commented 2026-10-01 21:02:14 +00:00 (Migrated from github.com)

The new -walletrebroadcast is introduced with a default to false, which is a change in the default behavior.

Concept NACK

Disabling rebroadcasts by default has bad effects for the wallet.

> The new `-walletrebroadcast` is introduced with a default to `false`, which is a change in the default behavior. Concept NACK Disabling rebroadcasts by default has bad effects for the wallet.
vasild (Migrated from github.com) reviewed 2026-10-05 09:50:15 +00:00
vasild (Migrated from github.com) commented 2026-10-05 09:50:15 +00:00

Modified the PR to not change the default behavior.

Modified the PR to not change the default behavior.
vasild commented 2026-10-05 09:59:35 +00:00 (Migrated from github.com)

57cbe86d86733d95d116c84a880c70c15dc99562...155eb27489f4fdbf9570dfb064e36fa12f37f399: don't introduce a new option, instead extend the allowed values of -walletbroadcast.

Concept NACK
Disabling rebroadcasts by default has bad effects for the wallet.

Changed the PR. Now the default behavior is unmodified.

Now this PR allows -walletbroadcast=initialonly (in addition to the existent 0 and 1) to instruct it to only do the initial broadcasts and skip the periodic rebroadcasts.

`57cbe86d86733d95d116c84a880c70c15dc99562...155eb27489f4fdbf9570dfb064e36fa12f37f399`: don't introduce a new option, instead extend the allowed values of `-walletbroadcast`. > Concept NACK > Disabling rebroadcasts by default has bad effects for the wallet. Changed the PR. Now the default behavior is unmodified. Now this PR allows `-walletbroadcast=initialonly` (in addition to the existent `0` and `1`) to instruct it to only do the initial broadcasts and skip the periodic rebroadcasts.
DrahtBot commented 2026-11-24 16:59:24 +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).
vasild commented 2026-11-30 11:35:37 +00:00 (Migrated from github.com)

155eb27489f4fdbf9570dfb064e36fa12f37f399...17bad7c1073dc22d6dd8596e3786b0a01236db16: rebase due to conflicts

Concept NACK
Disabling rebroadcasts by default has bad effects for the wallet.

@achow101, this PR does not disable rebroadcasts by default anymore. Just adds the possibility to switch them off. No changes in default behavior and no new config options. Would you reevaluate your NACK?

I think the option to disable automatic wallet rebroadcasts (this PR) would click well with the possibility to manually rebroadcast desired transactions (https://github.com/bitcoin/bitcoin/pull/36481).

https://github.com/bitcoin/bitcoin/pull/36398 is very much related to this, it disables the automatic wallet rebroadacast based on whether the wallet is sender or receiver. So we have:

  1. Initial wallet broadcast (obviously, the wallet is the sender)
  2. Subsequent automatic periodic rebroadcast if wallet is sender of the transaction
  3. Subsequent automatic periodic rebroadcast if wallet is recipient of the transaction

Right now -walletbroadcast=0 disables all and =1 enables all.
This PR makes it possible to optionally disable 2 & 3, via -walletbroadcast=initialonly
https://github.com/bitcoin/bitcoin/pull/36398 disables 3, unconditionally. @mzumsande what about making that configurable via e.g. -walletbroadcast=senderonly?

`155eb27489f4fdbf9570dfb064e36fa12f37f399...17bad7c1073dc22d6dd8596e3786b0a01236db16`: rebase due to conflicts > Concept NACK > Disabling rebroadcasts by default has bad effects for the wallet. @achow101, this PR does not disable rebroadcasts by default anymore. Just adds the possibility to switch them off. No changes in default behavior and no new config options. Would you reevaluate your NACK? I think the option to disable automatic wallet rebroadcasts (this PR) would click well with the possibility to manually rebroadcast desired transactions (https://github.com/bitcoin/bitcoin/pull/36481). https://github.com/bitcoin/bitcoin/pull/36398 is very much related to this, it disables the automatic wallet rebroadacast based on whether the wallet is sender or receiver. So we have: 1. Initial wallet broadcast (obviously, the wallet is the sender) 2. Subsequent automatic periodic rebroadcast if wallet is sender of the transaction 3. Subsequent automatic periodic rebroadcast if wallet is recipient of the transaction Right now `-walletbroadcast=0` disables all and `=1` enables all. This PR makes it possible to optionally disable 2 & 3, via `-walletbroadcast=initialonly` https://github.com/bitcoin/bitcoin/pull/36398 disables 3, unconditionally. @mzumsande what about making that configurable via e.g. `-walletbroadcast=senderonly`?
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!36380
No description provided.