Skip to content

Use Silent Payment address for DFX buy flow#3090

Open
TaprootFreak wants to merge 1 commit intocake-tech:devfrom
TaprootFreak:feature/dfx-silent-payment
Open

Use Silent Payment address for DFX buy flow#3090
TaprootFreak wants to merge 1 commit intocake-tech:devfrom
TaprootFreak:feature/dfx-silent-payment

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

  • Add addressForPrivateBuy property to WalletAddresses base class (default: addressForBuy)
  • Override in BitcoinWalletAddresses to return Silent Payment (sp1) address when available, fallback to P2WPKH
  • signMessage() uses b_spend key when signing for an sp1 address
  • DFX provider uses addressForPrivateBuy for Bitcoin buy actions — other providers (MoonPay, Robinhood, Onramper) unaffected
  • Hardware wallets: no silentAddress available → automatic fallback to P2WPKH

Context

Companion PR to DFXswiss/api#3426 which adds sp1 address recognition and signature verification on the DFX API side. Together they enable privacy-preserving Bitcoin payouts via BIP-352 Silent Payments.

Changed files

  • cw_core/lib/wallet_addresses.dart — new addressForPrivateBuy getter
  • cw_bitcoin/lib/bitcoin_wallet_addresses.dart — SP override
  • cw_bitcoin/lib/electrum_wallet.dartsignMessage() SP path
  • lib/buy/dfx/dfx_buy_provider.dart — use addressForPrivateBuy for buy

Test plan

  • Cross-verified SP address derivation: same seed produces same sp1 address in Cake Wallet and DFX API
  • Signature from b_spend key verified by DFX API verification logic
  • Manual: buy flow with DFX, verify SP address in auth request
  • CI build passes

Enable privacy-preserving Bitcoin payouts via BIP-352 Silent Payments
when buying through DFX.

Wallet layer:
- Add addressForPrivateBuy getter to WalletAddresses (default: addressForBuy)
- Override in BitcoinWalletAddressesBase to return sp1 address when available
- Extract shared signing logic into _signWithPrivateKey() helper
- signMessage() signs with b_spend key when address is sp1

Provider layer:
- DFX buy action uses addressForPrivateBuy for Bitcoin wallets
- Sell and non-Bitcoin flows remain unchanged
- Other providers (MoonPay, Robinhood, etc.) are unaffected

Hardware wallets automatically fall back to P2WPKH (no silentAddress).
@TaprootFreak TaprootFreak force-pushed the feature/dfx-silent-payment branch from e67c3ce to 1e2a2c1 Compare March 14, 2026 16:12
@TaprootFreak TaprootFreak marked this pull request as ready for review March 14, 2026 16:13
Copy link
Copy Markdown
Contributor

@OmarHatem28 OmarHatem28 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for making the necessary changes.

But I would argue about making SP the default, since silentAddress will have a value regardless of whether the user enabled SP scanning or not, so technically, all users who have a bitcoin wallet, have their SP address already generated, but they might not be using SP or even know what it is, and having the buy flow use that, would result in users not finding their funds, and reach out to support, and support tell them to scan using SP, and explain what is SP, and so on.

so, I would rather it be a good privacy option for people who knows what they are doing, but not the default.

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