FIX: incorrect error handling when scanning invalid BC-UR data

This commit is contained in:
overtorment 2023-06-28 22:59:36 +01:00
parent 6c87d23d05
commit 9a26be1c80

View file

@ -156,7 +156,10 @@ const ScanQRCode = () => {
} catch (error) { } catch (error) {
console.warn(error); console.warn(error);
setIsLoading(true); setIsLoading(true);
Alert.alert(loc.send.scan_error, loc._.invalid_animated_qr_code_fragment, [ Alert.alert(
loc.send.scan_error,
loc._.invalid_animated_qr_code_fragment,
[
{ {
text: loc._.ok, text: loc._.ok,
onPress: () => { onPress: () => {
@ -164,8 +167,9 @@ const ScanQRCode = () => {
}, },
style: 'default', style: 'default',
}, },
],
{ cancelabe: false }, { cancelabe: false },
]); );
} }
}; };
@ -200,7 +204,10 @@ const ScanQRCode = () => {
} catch (error) { } catch (error) {
console.warn(error); console.warn(error);
setIsLoading(true); setIsLoading(true);
Alert.alert(loc.send.scan_error, loc._.invalid_animated_qr_code_fragment, [ Alert.alert(
loc.send.scan_error,
loc._.invalid_animated_qr_code_fragment,
[
{ {
text: loc._.ok, text: loc._.ok,
onPress: () => { onPress: () => {
@ -208,8 +215,9 @@ const ScanQRCode = () => {
}, },
style: 'default', style: 'default',
}, },
],
{ cancelabe: false }, { cancelabe: false },
]); );
} }
}; };
@ -229,6 +237,10 @@ const ScanQRCode = () => {
return _onReadUniformResourceV2(ret.data); return _onReadUniformResourceV2(ret.data);
} }
if (ret.data.toUpperCase().startsWith('UR:CRYPTO-OUTPUT')) {
return _onReadUniformResourceV2(ret.data);
}
if (ret.data.toUpperCase().startsWith('UR:BYTES')) { if (ret.data.toUpperCase().startsWith('UR:BYTES')) {
const splitted = ret.data.split('/'); const splitted = ret.data.split('/');
if (splitted.length === 3 && splitted[1].includes('-')) { if (splitted.length === 3 && splitted[1].includes('-')) {