Repository navigation
Hand DFX sells to the send scene - #6347
Draft
TaprootFreakAI wants to merge 13 commits into
Draft
TaprootFreakAI wants to merge 13 commits into
TaprootFreakAI wants to merge 13 commits into
Conversation
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.
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; The Please review, and merge if it looks good to you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
guiPluginWebViewscene withredirect-uriset tomakePaymentReturnUrl('dfx', asset), and usesmakeSellPaymentRedirectto catch the redirect.<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 fromGET /v1/sell/{routeId}with the session token of its DFX login and openssend2with address, amount and wallet locked.currency.nameof 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.Commits:
redactUrlhidessession. The WebView scene logs navigation URLs throughredactUrl, and the DFX URL carries the login token insession; 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 anonErrorhandler that logs a failed page load throughredactUrl, because the WebView otherwise logs the whole event, query included.launchQuotehook increateExternalRampPlugin, next toresolveDeepQuery. Plugins without it behave as before.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,redactUrland 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!andamend!commits fold into the three commits above with an autosquash.CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none. #6346 touches the same lines of
dfxRampPlugin.ts(it removesDFX_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: