Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Jul 7, 2025

If the user does not specify locktime for send, sendall and walletcreatefundedpsbt, enable anti-fee-sniping. Previously we would set nLockTime to 0.

This behavior matches the sendtoaddress RPC and the GUI wallet.

Because sendall doesn't use CreateTransactionInternal this PR refactors (and renames) DiscourageFeeSniping so that it checks input nSequence values and nLockTime by itself, and brings its own FastRandomContext. A subsequent commit then calls this from the sendall RPC.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 7, 2025

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32892.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #32896 (wallet, rpc: add v3 transaction creation and wallet support by ishaanam)
  • #32857 (wallet: allow skipping script paths by Sjors)
  • #31936 (rpc: Support v3 raw transactions creation by Bue-von-hon)
  • #28944 (wallet, rpc: add anti-fee-sniping to send and sendall by ishaanam)
  • #21283 (Implement BIP 370 PSBTv2 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.

Sjors added 5 commits July 7, 2025 18:38
If the user does not specify 'locktime' for send and
walletcreatefundedpsbt, enable anti-fee-sniping. This matches
sendtoaddress RPC behavior and the GUI wallet.
Rename and refactor DiscourageFeeSniping such that it can determine
by itself whether to apply anti fee sniping. This makes it easier
to use outside of CreateTransactionInternal.
@Sjors Sjors force-pushed the 2025/07/locktime branch from b19ce64 to 113ba10 Compare July 7, 2025 16:56
@Sjors
Copy link
Member Author

Sjors commented Jul 7, 2025

Expanded the existing test_anti_fee_sniping case in wallet_create_tx.py to cover send sendall. Making sendall actually work required an additional refactor.

@Sjors Sjors changed the title rpc: use anti-fee-sniping by default rpc: use anti-fee-sniping in send, sendall and walletcreatefundedpsbt Jul 7, 2025
@glozow
Copy link
Member

glozow commented Jul 7, 2025

Any chance this is a duplicate of #28944?

@Sjors
Copy link
Member Author

Sjors commented Jul 8, 2025

@glozow thanks, I hadn't seen that one. Will take a look.

@Sjors
Copy link
Member Author

Sjors commented Jul 9, 2025

Ok, so #28944 uses a completely different approach. It already has a lot of review, so I'll add mine there.

@Sjors Sjors closed this Jul 9, 2025
Evoneem

This comment was marked as off-topic.

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jul 17, 2025
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jul 17, 2025
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.

4 participants