Skip to content

Hand DFX sells to the send scene - #6347

Draft
TaprootFreakAI wants to merge 13 commits into
EdgeApp:developfrom
TaprootFreakAI:dfx-sell-send-scene
Draft

TaprootFreakAI wants to merge 13 commits into
EdgeApp:developfrom
TaprootFreakAI:dfx-sell-send-scene

Conversation

@TaprootFreakAI

@TaprootFreakAI TaprootFreakAI commented Nov 24, 2026 •

Copy link
Copy Markdown

Description

A DFX sell currently ends on DFX's page with a deposit address that the user has to copy and pay by hand. DFX's app hands the order back to the wallet instead when the launch URL carries a redirect-uri (DFX docs, "Closing"). This PR uses that, so a DFX sell ends in Edge's send scene with the deposit address and amount filled in and locked, the way the Moonpay, Paybis and Banxa sells do.

How it works:

  • A logged-in sell opens DFX in the guiPluginWebView scene with redirect-uri set to makePaymentReturnUrl('dfx', asset), and uses makeSellPaymentRedirect to catch the redirect.
  • When the user confirms the sell, DFX redirects to <redirect-uri>sell?routeId=…&amount=…&asset=…&blockchain=…&isComplete=false. The redirect does not carry the deposit address, since a deep link can be forged. Edge fetches it from GET /v1/sell/{routeId} with the session token of its DFX login and opens send2 with address, amount and wallet locked.
  • The redirect is checked before anything is fetched: numeric route id, plain positive decimal amount (exponent form is refused), and the blockchain and asset of the selling wallet. The route must have a deposit address that accepts the wallet's blockchain. The amount is rounded down to the asset's smallest unit.
  • The sale is recorded in the fiat the route pays out (currency.name of the route), with DFX's estimate of the fiat amount, so the transaction details are right when the user picked another payout currency on DFX's page.
  • The send-scene guards against a second send follow the Moonpay sell.
  • A sell without a session (the DFX login failed) opens in the plugin scene as before, where DFX shows the address for a manual transfer. Buys do not change.

Commits:

  1. redactUrl hides session. The WebView scene logs navigation URLs through redactUrl, and the DFX URL carries the login token in session; the plugin scene DFX used before cuts the whole query from its logs for the same reason. It also checks the raw query text, since the parser skips a pair it cannot decode and matches names by exact case. The scene gets an onError handler that logs a failed page load through redactUrl, because the WebView otherwise logs the whole event, query included.
  2. An optional launchQuote hook in createExternalRampPlugin, next to resolveDeepQuery. Plugins without it behave as before.
  3. The DFX sell itself, with tests.

Two differences from the plugin scene that a sell now leaves behind: the WebView scene has no in-page back history, and it does not run the light-account backup check. Both match the other sells that use this scene. The permissions the DFX GUI plugin declares (the camera, for DFX's identity check) are requested before the page opens, the way the plugin scene requests them.

Testing: tsc, ESLint on the changed files and the ramp, redactUrl and WebView scene Jest suites pass locally. Tested on an Android emulator with a real sale: a Bitcoin wallet sold to EUR through DFX, the send scene opened with DFX's deposit address and the amount locked, and the transaction was sent and confirmed on chain. Not tested on iOS.

The fixup! and amend! commits fold into the three commits above with an autosquash.

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none. #6346 touches the same lines of dfxRampPlugin.ts (it removes DFX_CHAINS), so whichever of the two merges second needs a one-line rebase.

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

The WebView scene logs each navigation through redactUrl, and release
builds write that log to the file users export or send to Edge. A
provider page opened with a login token in its `session` query
parameter would put the token there.

Add `session` to the secret parameters. Also check the raw query text
after the parsed one: the parser skips a pair it cannot decode and
matches names by exact case, so a secret could pass in the clear.
An external ramp plugin always opened the plugin scene, which cannot
catch a redirect back to Edge. A sell that Edge pays from the send
scene needs the WebView scene with its redirect handlers instead.

Add an optional launchQuote hook to the direction support data. It
gets the request and the deep query, and returns false to open the
plugin scene after all. Plugins without the hook behave as before.
DFX's sell page ended by showing a deposit address for the user to
copy and pay by hand. DFX hands the order back instead when the launch
URL carries a redirect URI.

Open a logged-in sell with that redirect. On the payment redirect,
fetch the deposit address from DFX's API with the user's session, so a
forged redirect cannot name the address, and open the send scene with
the address and amount locked. A sell without a session opens as
before.
Hide login sessions in redacted URLs

The WebView scene logs each navigation through redactUrl, and release
builds write that log to the file users export or send to Edge. A
provider page opened with a login token in its `session` query
parameter would put the token there.

Add `session` to the secret parameters. Also check the raw query text
after the parsed one: the parser skips a pair it cannot decode and
matches names by exact case, so a secret could pass in the clear.

The WebView logs a failed page load with its whole event, query
included, when the scene sets no `onError`. Add one that logs the URL
through redactUrl, with the error code and description.
@TaprootFreakAI

Copy link
Copy Markdown
Author

This is ready for review from our side.

We tested the flow several times on Android, including two real Bitcoin sales through DFX: Edge opens the send scene with DFX's deposit address and the amount locked, and both transactions went out to that address. We also reviewed the code in several rounds; tsc, ESLint and the Jest suites pass, and CI is green. Not tested on iOS.

The fixup! and amend! commits fold into the three commits with an autosquash. #6346 touches the same lines of dfxRampPlugin.ts, so whichever of the two merges second needs a one-line rebase, which we will do right away.

Please review, and merge if it looks good to you.

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.

1 participant