+
+ {{successMessage}}
+
+
{{qrData}}
-
+
+
BC UR: {{decoder.expectedPartCount()}} parts, {{decoder.getProgress() * 100}}% completed
+
+
+
-
-
+
+
@@ -63,7 +65,7 @@ function initCameraScanningApp(title, onDataSubmit, modalId, submitOnScan = fals
const isModal = !!modalId;
Vue.component('scanner-wrap', {
- props: ["modalId", "title", "workload", "decoder"],
+ props: ["modalId", "title", "decoder"],
template: "#camera-qr-scanner-wrap",
methods: {
close() {
@@ -82,12 +84,12 @@ function initCameraScanningApp(title, onDataSubmit, modalId, submitOnScan = fals
modalId: modalId,
noStreamApiSupport: false,
qrData: null,
+ decoder: null,
errorMessage: null,
- workload: [],
+ successMessage: null,
camera: 0,
cameraOff: true,
cameras: ["auto"],
- decoder: null,
submitOnScan
}
},
@@ -103,22 +105,23 @@ function initCameraScanningApp(title, onDataSubmit, modalId, submitOnScan = fals
},
computed: {
requestInput() {
- return !this.cameraOff && this.errorMessage === null;
+ return !this.cameraOff && !this.errorMessage && !this.successMessage && !this.qrData;
}
},
methods: {
- nextCamera: function (){
+ nextCamera() {
if (this.camera === 0){
this.camera++;
- } else if (this.camera == this.cameras.length -1) {
+ } else if (this.camera === this.cameras.length - 1) {
this.camera = 0;
} else {
this.camera++;
}
},
- setQrData (qrData) {
+ setQrData(qrData) {
this.qrData = qrData;
this.cameraOff = !!qrData;
+
if (this.qrData && this.submitOnScan) {
this.submitData();
}
@@ -129,8 +132,8 @@ function initCameraScanningApp(title, onDataSubmit, modalId, submitOnScan = fals
},
reset() {
this.setQrData(null);
+ this.successMessage = null;
this.errorMessage = null;
- this.workload = [];
this.decoder = null;
},
close() {
@@ -142,53 +145,37 @@ function initCameraScanningApp(title, onDataSubmit, modalId, submitOnScan = fals
},
onDecode(content) {
if (this.qrData) return;
-
- if (!content.toLowerCase().startsWith("ur:")) {
- this.setQrData(content);
- this.workload = [];
- } else {
- if (this.workload.length == 0){
- const d = this.decoder || new window.URlib.URRegistryDecoder();
- if (d.receivePart(content)){
- this.decoder = d;
- if (d.isComplete()){
- if (!this.decoder.isSuccess()){
- this.errorMessage = this.decoder.resultError();
- }else{
- this.setQrData(this.decoder.resultRegistryType().toString());
+ const isUR = content.toLowerCase().startsWith("ur:");
+ console.debug(1, content);
+
+ try {
+ if (!isUR) {
+ this.setQrData(content);
+ } else {
+ this.decoder = this.decoder || new window.URlib.URRegistryDecoder();
+ if (this.decoder.receivePart(content)) {
+ if (this.decoder.isComplete()) {
+ if (this.decoder.isSuccess()) {
+ const ur = this.decoder.resultUR();
+ this.setQrData(ur);
+ this.successMessage = `UR ${ur.type} decoded`;
+ } else if (this.decoder.isError()) {
+ this.errorMessage = this.decoder.resultError();
}
}
}
- if (this.decoder != null){
- return;
- }
- }
- const [index, total] = window.bcur.extractSingleWorkload(content);
- if (this.workload.length > 0) {
- const currentTotal = this.workload[0].total;
- if (total !== currentTotal) {
- this.workload = [];
- }
- }
- if (!this.workload.find(i => i.index === index)) {
- this.workload.push({
- index,
- total,
- data: content,
- });
- if (this.workload.length === total) {
- const decoded = window.bcur.decodeUR(this.workload.map(i => i.data));
- this.setQrData(decoded);
- }
- }
- }
+ }
+ } catch (error) {
+ console.error(error);
+ this.errorMessage = error.message;
+ }
},
submitData() {
- if (onDataSubmit) {
- onDataSubmit(this.qrData);
- }
- this.close();
- },
+ if (onDataSubmit) {
+ onDataSubmit(this.qrData);
+ }
+ this.close();
+ },
logErrors(promise) {
promise.catch(console.error)
},
@@ -208,12 +195,10 @@ function initCameraScanningApp(title, onDataSubmit, modalId, submitOnScan = fals
},
onInit(promise) {
promise.then(() => {
- this.errorMessage = null;
- if (app.cameras.length === 1)
- {
- navigator.mediaDevices.enumerateDevices().then(function (devices) {
+ if (app.cameras.length === 1) {
+ navigator.mediaDevices.enumerateDevices().then(devices => {
for (const device of devices) {
- if (device.kind == "videoinput"){
+ if (device.kind === "videoinput"){
app.cameras.push( device.deviceId)
}
}
diff --git a/BTCPayServer/Views/Shared/ShowQR.cshtml b/BTCPayServer/Views/Shared/ShowQR.cshtml
index a96072ed9..d39b45869 100644
--- a/BTCPayServer/Views/Shared/ShowQR.cshtml
+++ b/BTCPayServer/Views/Shared/ShowQR.cshtml
@@ -3,134 +3,112 @@
-
diff --git a/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml b/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml
index 0bbef23bf..72ef64b79 100644
--- a/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml
+++ b/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml
@@ -244,21 +244,13 @@
-
-
}
diff --git a/BTCPayServer/Views/UIStores/ImportWallet/ConfirmAddresses.cshtml b/BTCPayServer/Views/UIStores/ImportWallet/ConfirmAddresses.cshtml
index a65d740bf..a2dc389d4 100644
--- a/BTCPayServer/Views/UIStores/ImportWallet/ConfirmAddresses.cshtml
+++ b/BTCPayServer/Views/UIStores/ImportWallet/ConfirmAddresses.cshtml
@@ -22,7 +22,7 @@
-