Skip to content

wallet: don't resubmit transactions under -privatebroadcast - #36330

Closed
instagibbs wants to merge 1 commit into
bitcoin:masterfrom
instagibbs:wallet-privbcast-no-reannounce
Closed

instagibbs wants to merge 1 commit into
bitcoin:masterfrom
instagibbs:wallet-privbcast-no-reannounce

Conversation

@instagibbs

@instagibbs instagibbs commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

This doesn't fix the general case of rebroadcasting potentially surprising users by divulging the originator IP trivially, but for users opting into private broadcast, it seems a bridge too far for them to expect the current behavior.

e.g. an incoming dust payment triggering your node to rebroadcast 24-36th later over clearnet

This can be removed if/when wallet drives through private broadcast.

see #3828 for running broader issue

@DrahtBot

DrahtBot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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 davidgumberg, andrewtoth, w0xlt
Concept NACK vasild, polespinasa
Concept ACK darosior

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:

  • #36482 (wallet: Only broadcast resubmitted transactions that were added to the mempool by achow101)
  • #36481 (wallet, rpc, gui: Allow users to manually rebroadcast a wallet transaction by achow101)
  • #36380 (wallet: extend -walletbroadcast to allow initial send only by vasild)

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.

@w0xlt w0xlt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b7ea578

@fanquake

Copy link
Copy Markdown
Member

cc @andrewtoth @vasild

@achow101

achow101 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

but for users opting into private broadcast, it seems a bridge too far for them to expect the current behavior.

Is it? The current behavior is that all transactions being sent via the wallet do not use private broadcast at all; CommitTransaction uses MEMPOOL_AND_BROADCAST_TO_ALL, and it follows that resubmit behaves in the same way.

See also: #34533 (comment)

@andrewtoth

Copy link
Copy Markdown
Contributor

The current behavior is that all transactions being sent via the wallet do not use private broadcast at all

This is true, but the case this change is protecting against is transactions sent by other means that also belong to the wallet.

So if a user is running with -privatebroadcast and is sending transactions via sendrawtransaction, if they have a watch only wallet or their addresses are dusted with low fee transactions, then the wallet will still rebroadcast these transactions. This could be unexpected if the user thinks they are protected by -privatebroadcast.

Comment thread src/wallet/wallet.cpp Resolved
@andrewtoth

andrewtoth commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Is this intended for backport?

I ask because if we were not going to backport, then we could instead fix this by having the wallet use private broadcast. But for a backport fix this would be sufficient for existing users, with the tradeoff of reducing reliability of wallet transactions confirming a little bit.

@instagibbs
instagibbs force-pushed the wallet-privbcast-no-reannounce branch from b7ea578 to 704238c Compare September 25, 2026 16:47
@instagibbs

Copy link
Copy Markdown
Member Author

@andrewtoth Given that wallet integration isn't close to done, I think we should remove footguns until we get there. This is easily reversed. I think backporting makes sense for the same reason.

@instagibbs instagibbs changed the title wallet: don't announce resubmitted transactions under -privatebroadcast wallet: don't resubmit transactions under -privatebroadcast Sep 25, 2026

@andrewtoth andrewtoth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 704238c

@DrahtBot
DrahtBot requested a review from w0xlt September 27, 2026 15:21

@darosior darosior left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

@instagibbs
instagibbs force-pushed the wallet-privbcast-no-reannounce branch 2 times, most recently from 8c4e257 to 6d54502 Compare September 28, 2026 15:00

self.log.info("The periodic resend does not re-add it")
# Resending needs a recent tip (the restart put node1 back in IBD) and a block seen since startup
self.generate(node1, 1, sync_fun=self.no_op)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

This second test that tx's are not readded at the resubmit timer is dependent on the test above, e.g. consider this diff:

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 93851a8736..8d15b02f37 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1917,7 +1917,7 @@ void CWallet::ResubmitWalletTransactions(node::TxBroadcast broadcast_method, boo
     // Don't attempt to resubmit if the wallet is configured to not broadcast,
     // even if forcing.
     if (!fBroadcastTransactions) return;
-    if (m_private_broadcast) return;
+    // if (m_private_broadcast) return;
 
     int submitted_tx_count = 0;
 
diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py
index e4afad1d42..8f1da010e3 100755
--- a/test/functional/wallet_resendwallettransactions.py
+++ b/test/functional/wallet_resendwallettransactions.py
@@ -161,7 +161,8 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
         node1.replace_in_config([("connect=0\n", "")])  # -privatebroadcast refuses -connect
         privbcast_args = ["-privatebroadcast", "-onion=127.0.0.1:9", "-persistmempool=0"]  # the proxy is never used here
         self.restart_node(1, extra_args=privbcast_args + [f"-mocktime={node1.mocktime}"])
-        assert recv_txid not in node1.getrawmempool()  # loading the wallet did not re-add it
+        # [first test disabled]
+        # assert recv_txid not in node1.getrawmempool()  # loading the wallet did not re-add it
 
         self.log.info("The periodic resend does not re-add it")
         # Resending needs a recent tip (the restart put node1 back in IBD) and a block seen since startup

Then this second check passes (since the generate line included the tx in a block), maybe add a (redundant) check here, e.g.:

Suggested change
self.generate(node1, 1, sync_fun=self.no_op)
assert recv_txid not in node1.getrawmempool()
self.generate(node1, 1, sync_fun=self.no_op)

maybe spurious [why would somebody delete or move one of the tests], but IMO these long winded functional tests where each of the checks are not scoped and there's stateful stuff are hard enough to read and even though it's obvious to us reviewing this now, to my grug brain at least it would not be obvious that the properties this claims to test are only there if the test above also passes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it mine an empty block, then did the assertion it's not in mempool. that help grug? (I agree these should all be subtests split off, easy cleanup task)

@mzumsande mzumsande left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ask because if we were not going to backport, then we could instead fix this by having the wallet use private broadcast.

I think that promoting private broadcast into an essential feature (and with it, connectivity to privacy networks) that is required for basic functionality such as rebroadcasting is a major change that needs to be very well discussed, to say the least.

As of now I view it as an optional feature.

But as such, I could see users starting with -privatebroadcast just to send out some transactions, and then restarting back to regular mode without private broadcast with a wallet that rebroadcasts them. This could reveal the origin of their transactions after the fact, so there is only so much this PR can achieve.

@davidgumberg

Copy link
Copy Markdown
Contributor

crACK 6d54502

It is unfortunate that restarting subjects a user to potentially losing privacy if a TX is not confirmed. I would personally be in favor of dropping wallet rebroadcasting completely, it is a massive privacy footgun for non-privatebroadcast users as well, for little benefit. At least, for little benefit that couldn't be provided with other solutions that are less harmful.

@andrewtoth

Copy link
Copy Markdown
Contributor

I think that promoting private broadcast into an essential feature (and with it, connectivity to privacy networks) that is required for basic functionality such as rebroadcasting is a major change that needs to be very well discussed

I was merely suggesting to have the wallet rebroadcast via private broadcast if -privatebroadcast was set, not fix the entire unexpected rebroadcasting issue by requiring -privatebroadcast. (Although I might have shared that idea in another channel, I am not advocating we do that here.)

@vasild

vasild commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Improving privacy is good, but I think this has taken an odd approach:

  • It adds a relationship between wallet behavior and -privatebroadcast. It is documented that -privatebroadcast does not affect the wallet.

  • It makes it impossible to have -privatebroadcast=1 and wallet rebroadcast. Wallet rebroadcast indeed looks bad wrt privacy, but it is so even without considering -privatebroadcast. There may be setups where the wallet rebroadcasts are not so bad (e.g. if the node is not directly connected to clearnet) and are desired. Wallet rebroadcasts shouldn't really be tied to the value of -privatebroadcast.

I think it is better to make wallet rebroadcasts separately controllable, independently of -privatebroadcast. Opened #36380 to explore that.

@instagibbs

Copy link
Copy Markdown
Member Author

@vasild I don't think adding more knobs is the right direction, we already have -walletbroadcast which arguably could the a soft default with private broadcast on. Users could over-ride that and retain old behavior. But of course, users may turn the feature on, then turn it back off, rebroadcasting anyways.

It is documented that -privatebroadcast does not affect the wallet.

We can change documentation if we change behavior. Only matters if the change is correct/good/etc.

@davidgumberg yeah, I am quite skeptical of the wallet rebroadcast feature, it's built around corner cases and is a massive leak. Would be willing to discuss alternatives in an issue regardless of how this PR goes.

…dcast

The wallet re-adds its unconfirmed transactions to the mempool periodically
and whenever a wallet is loaded or its transactions are imported. A
transaction that the rest of the network has dropped is then held by this
node alone, and served to any peer that asks for it, which marks it as the
node's own. Not announcing the re-added transaction does not hide this: any
relay peer can fetch anything in the mempool once the next inv round has
passed.

With -privatebroadcast, skip the resubmission entirely. Transactions sent
through the wallet are still submitted and announced as before, since those
never went through private broadcast in the first place.
@instagibbs
instagibbs force-pushed the wallet-privbcast-no-reannounce branch from 6d54502 to 3544df2 Compare September 29, 2026 13:12
@andrewtoth

andrewtoth commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Would be willing to discuss alternatives in an issue

One such alternative has an issue open #30471.

@vasild

vasild commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@vasild I don't think adding more knobs is the right direction

Right, I am not convinced either. Maybe the existent option can be extended, see at the bottom of #36380 (comment)

we already have -walletbroadcast which arguably could the a soft default with private broadcast on. Users could over-ride that and retain old behavior. But of course, users may turn the feature on, then turn it back off, rebroadcasting anyways.

I just don't like those parameter interactions - in general, they could be hard to reason about. So to have -privatebroadcast=1 soft set -walletbroadcast=0? To stop also the initial wallet broadcast, given that -privatebroadcast is not used by the wallet... sounds odd to me.

It is documented that -privatebroadcast does not affect the wallet.

We can change documentation if we change behavior. Only matters if the change is correct/good/etc.

Right. And it would be nice to have the wallet use the private broadcast for its transactions even if currently it is documented that it does not :)

the wallet rebroadcast feature ... is a massive leak

💯

@achow101

achow101 commented Oct 1, 2026

Copy link
Copy Markdown
Member

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

@instagibbs
instagibbs marked this pull request as draft October 2, 2026 15:19
@instagibbs instagibbs changed the title wallet: don't resubmit transactions under -privatebroadcast [NO MERGE] wallet: don't resubmit transactions under -privatebroadcast Oct 2, 2026
@instagibbs

Copy link
Copy Markdown
Member Author

moving to draft due to lack of consensus

@davidgumberg

davidgumberg commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

reACK 3544df2

I think this is a simple and good enough fix that can be backported into 32.x and 31.x

Also see discussion in #36403.

@instagibbs
instagibbs marked this pull request as ready for review October 8, 2026 11:45
@instagibbs instagibbs changed the title [NO MERGE] wallet: don't resubmit transactions under -privatebroadcast wallet: don't resubmit transactions under -privatebroadcast Oct 8, 2026

@andrewtoth andrewtoth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK 3544df2

@w0xlt w0xlt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reACK 3544df2

@vasild

vasild commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
  • The wallet transactions are initially sent to all peers and periodically rebroadcast. This has not changed in 10 years and was not changed by the introduction of private broadcast. The wallet does not use private broadcast.

  • The wallet rebroadcast is and has always been bad for privacy, but it has its use cases. This PR would cripple the wallet due to an unrelated feature being enabled.

  • I see the idea here is to try to protect users that create transactions in the wallet, but do not broadcast them via the wallet and use sendrawtransaction RPC instead with private broadcast. For these users, that do not use the wallet initial send either, -walletbroadcast=0 fits very well. I think this should be resolved via some communication channel to advise people of that.

Concept NACK

@instagibbs

Copy link
Copy Markdown
Member Author

This has not changed in 10 years and was not changed by the introduction of private broadcast

Interactions between features exist and should not be ignored. It's a wallet issue, for sure, but for a wallet + pb user, it would be extremely surprising.

I think this should be resolved via some communication channel to advise people of that.

I don't think handing users footguns and hoping they read the docs is the right approach. Ideally we'd remove / replace rebroadcasts entirely, then this particular coupling can disappear safely. #36403 (comment) for some discussion for those following at home.

@polespinasa

Copy link
Copy Markdown
Member

I tend to concept NACK this although I cannot come with a better proposal that 100% fixes this right now.

I don't think disallowing re-broadcast is the right solution (I know this is proposed as a temporal fix). Although it is not perfect, I prefer something like #36482 which I consider a good half-patch that limits this issue to a really specific case were a transaction disappears from node's mempool and is when we should consider rebroadcast necessary (in its current implementation).

I don't think the incoming dust privacy attack is an argument for pushing this PR forward. That attack affects both, private and standard broadcast, and as I understand private broadcast, it improves your privacy when you send a transaction, not when you receive one. It helps hiding you are the origin of a transaction, but that doesn't mean that it makes impossible to know that you are the origin of a transaction.
In other words, I think the dust-resubmit attack is worth fixing and we should fix it, but it is worth fixing for all cases, not only private broadcast. I don't feel disabling a useful feature such as rebroadcast is the right step here. We also shouldn't assume and say that private broadcast makes impossible to know the origin of a transaction, it does improve privacy and makes it more difficult and expensive to know.

@sedited

sedited commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Should this be closed/drafted for now given the nacks?

@instagibbs
instagibbs marked this pull request as draft November 4, 2026 14:34
@instagibbs

Copy link
Copy Markdown
Member Author

dont know what the direction is on this, closing

@instagibbs instagibbs closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.