Skip to content

Set anti-fee-sniping nLockTime in payjoin-cli#1678

Open
bc1cindy wants to merge 1 commit into
payjoin:masterfrom
bc1cindy:snipe
Open

Set anti-fee-sniping nLockTime in payjoin-cli#1678
bc1cindy wants to merge 1 commit into
payjoin:masterfrom
bc1cindy:snipe

Conversation

@bc1cindy

@bc1cindy bc1cindy commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

compute the anti-fee-sniping nLockTime in the cli (current tip, ~10% backdated up to 100, 0 on stale/IBD) and set it explicitly on wallet_create_funded_psbt, mirroring Core's DiscourageFeeSniping

payjoin-cli nLockTime then matches Core/Electrum anonymity set.

part of #1676 and #1597

@coveralls

coveralls commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 28193013536

Coverage increased (+0.04%) to 85.555%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (50 of 51 lines covered, 98.04%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
payjoin-cli/src/app/wallet.rs 51 50 98.04%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15175
Covered Lines: 12983
Line Coverage: 85.56%
Coverage Strength: 364.83 hits per line

💛 - Coveralls

@bc1cindy bc1cindy marked this pull request as ready for review June 24, 2026 19:56
@benalleng

benalleng commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

The cli uses bitcoind-async-client so the default will follow that instead.
https://github.com/alpenlabs/bitcoind-async-client/blob/5af72a9473105275af53c3c696d784988f0a74c2/src/client/v30.rs#L311

We either need to change this upstream in their library or re-implement this behavior to follow core ourselves.

@bc1cindy

bc1cindy commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

thanks everyone.

reworked to fund via Core's send RPC (add_to_wallet=false), which applies the native anti-fee-sniping nLockTime, with no re-implementation in the cli

depends on alpenlabs/bitcoind-async-client#126

I'll leave as a draft (CI red) until that releases, then I'll bump the dep.

@benalleng

benalleng commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

I would encourage you to just pin the bitcoind-async-client hash to your repo and commit bc1cindy/bitcoind-async-client@d7ff324

However, I do not think using send is going to work here as it is my understanding that this will create and broadcast the tx not leaving it open for us to modify in the payjoin I see you added the add_to_wallet flag so perhaps this could work though It does seem rather hacky still IMO

@benalleng

Copy link
Copy Markdown
Collaborator

The core issue I opened bitcoin/bitcoin#34987 received mixed feedback as other people seemed to believe that this was the desired behavior as to leave locktime default creation up to us when using wallet_create_funded_psbt and any non-final tx creation process

@bc1cindy

bc1cindy commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

thanks @benalleng

so, given the Core feedback, I lean to switch this to re-implement, since the caller should own the locktime for non-final tx creation (same as Liana)

compute the anti-fee-sniping locktime (current tip, ~10% backdated ≤100, 0 on stale/IBD) and set it explicitly on wallet_create_funded_psbt

sounds good?

@bc1cindy bc1cindy closed this Jun 25, 2026
@bc1cindy bc1cindy reopened this Jun 25, 2026
@bc1cindy bc1cindy changed the title payjoin-cli: let Core set nLockTime (anti-fee-sniping) Set anti-fee-sniping nLockTime in payjoin-cli Jun 25, 2026
@bc1cindy bc1cindy marked this pull request as ready for review June 25, 2026 19:06
InputPair::new(txin, psbtin, None).expect("Input pair should be valid")
}

/// nLockTime mirroring Core's `DiscourageFeeSniping`/`IsCurrentForAntiFeeSniping`: the tip,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@benalleng benalleng added this to the payjoin-cli-1.1 milestone Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants