Skip to content

fix(send): apply taproot tweak only to P2TR inputs in XprivSilentPaymentSender::send_to - #78

Merged
nymius merged 1 commit into
bitcoindevkit:masterfrom
MusabYK:fix-xpriv-sender-taproot-tweak
Sep 22, 2026
Merged

nymius merged 1 commit into
bitcoindevkit:masterfrom
MusabYK:fix-xpriv-sender-taproot-tweak

Conversation

@MusabYK

@MusabYK MusabYK commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Description

XprivSilentPaymentSender::send_to currently applies the BIP-341 Taproot key-path tweak to every input, regardless of the input's script type.

As a result, using XprivSilentPaymentSender::send_to with a non-Taproot input can produce an incorrect Silent Payment partial secret and therefore incorrect output keys. The call does not necessarily fail, the recipient may simply be unable to discover the payment.

The problem is that create_silentpayment_partial_secret in silentpayments/src/send/mode.rs is script-type aware. It only performs the Taproot parity handling for P2TR inputs and uses the supplied private key directly for the other eligible input types.

This PR branches on spk's actual type before deciding whether to apply the tap tweak, matching what create_silentpayment_partial_secret already expects

All Submissions:

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

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.

Can you add a test verifying this doesn't change the scanned outputs on the other end?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi. I've added a around-trip regression test (send_output_is_found_by_scan_with_mixed_input_types) to verify that the generated output is correctly identified by the receiver.

@MusabYK
MusabYK force-pushed the fix-xpriv-sender-taproot-tweak branch from 6f1e231 to e1fbf8d Compare September 22, 2026 05:22
@MusabYK
MusabYK force-pushed the fix-xpriv-sender-taproot-tweak branch from e1fbf8d to 830af5a Compare September 22, 2026 05:34

@nymius nymius left a comment

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.

ACK 830af5a

@nymius
nymius merged commit b8dfa1f into bitcoindevkit:master Sep 22, 2026
5 checks passed
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.

2 participants