From c97b859963d494ee88aa873709b860b236f65cdb Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Wed, 31 Aug 2022 12:27:06 +0200 Subject: [PATCH] Refactor QR functionality Based on the `ur-registry` upgrade I refactored the `CameraScanner` and `ShowQR` partials: Besides general code changes, the main change is that most of the configuration and result handling now happens on the outer view. Those partials and functions are now generalized and don't know about their purpose (like handling PSBTs): They can be instantiated with simple data (e.g. for displaying a plain QR code) or different modes (like showing a static and the UR version of a QR code) and the result handling is done via callback. The callbacks can now also distinguish between the different results (data as plain string vs. UR-type objects for wallet data or PSBT) and also handle the specific type of data. For instance: Before it wasn't possible to strip the leading derivation path from an xpub when scanning the QR code, because the scanner didn't know about the type of data it was handling. Now that the data is handled in the callback, we can implement that functionality for the scan view only. --- .../Views/Shared/CameraScanner.cshtml | 123 +++++------- BTCPayServer/Views/Shared/ShowQR.cshtml | 184 ++++++++---------- BTCPayServer/Views/UIManage/APIKeys.cshtml | 15 +- .../UIPullPayment/ViewPullPayment.cshtml | 18 +- .../ImportWallet/ConfirmAddresses.cshtml | 6 +- .../Views/UIStores/ImportWallet/Scan.cshtml | 19 +- .../Views/UIStores/WalletSettings.cshtml | 7 +- .../Views/UIWallets/WalletPSBT.cshtml | 29 ++- .../Views/UIWallets/WalletPSBTDecoded.cshtml | 40 +++- .../js/wallet/wallet-camera-scanner.js | 4 +- 10 files changed, 232 insertions(+), 213 deletions(-) diff --git a/BTCPayServer/Views/Shared/CameraScanner.cshtml b/BTCPayServer/Views/Shared/CameraScanner.cshtml index 5bc77585d..06725d814 100644 --- a/BTCPayServer/Views/Shared/CameraScanner.cshtml +++ b/BTCPayServer/Views/Shared/CameraScanner.cshtml @@ -10,8 +10,6 @@
-
Animated QR detected: {{workload.length}} / {{workload[0].total}} scanned
-
+
-
-
- -
-
-