mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-29 04:49:51 +00:00
fix node QR Code URI parsing (#1916)
* fix:node QR Code URI parsing * optionally include user data * fix for qr scaner
This commit is contained in:
parent
c88809133f
commit
4fe2be3c92
3 changed files with 19 additions and 16 deletions
|
@ -23,7 +23,7 @@ Future<String> presentQRScanner(BuildContext context) async {
|
|||
),
|
||||
);
|
||||
isQrScannerShown = false;
|
||||
return result??'';
|
||||
return result!;
|
||||
} catch (e) {
|
||||
isQrScannerShown = false;
|
||||
rethrow;
|
||||
|
@ -95,9 +95,7 @@ class _BarcodeScannerSimpleState extends State<BarcodeScannerSimple> {
|
|||
setState(() {
|
||||
popped = true;
|
||||
});
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
Navigator.of(context).pop(_barcode?.rawValue ?? "");
|
||||
});
|
||||
Navigator.of(context).pop(_barcode!.rawValue ?? _barcode!.rawBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,12 @@ class NodeForm extends StatelessWidget {
|
|||
}
|
||||
});
|
||||
|
||||
reaction((_) => nodeViewModel.path, (String path) {
|
||||
if (path != _pathController.text) {
|
||||
_pathController.text = path;
|
||||
}
|
||||
});
|
||||
|
||||
_addressController.addListener(() => nodeViewModel.address = _addressController.text);
|
||||
_pathController.addListener(() => nodeViewModel.path = _pathController.text);
|
||||
_portController.addListener(() => nodeViewModel.port = _portController.text);
|
||||
|
|
|
@ -219,23 +219,22 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
|||
throw Exception('Unexpected scan QR code value: value is empty');
|
||||
}
|
||||
|
||||
if (!code.contains('://')) code = 'tcp://$code';
|
||||
|
||||
final uri = Uri.tryParse(code);
|
||||
|
||||
if (uri == null) {
|
||||
throw Exception('Unexpected scan QR code value: Value is invalid');
|
||||
if (uri == null || uri.host.isEmpty) {
|
||||
throw Exception('Invalid QR code: Unable to parse or missing host.');
|
||||
}
|
||||
|
||||
final userInfo = uri.userInfo.split(':');
|
||||
|
||||
if (userInfo.length < 2) {
|
||||
throw Exception('Unexpected scan QR code value: Value is invalid');
|
||||
}
|
||||
|
||||
final rpcUser = userInfo[0];
|
||||
final rpcPassword = userInfo[1];
|
||||
final userInfo = uri.userInfo;
|
||||
final ipAddress = uri.host;
|
||||
final port = uri.port.toString();
|
||||
final port = uri.hasPort ? uri.port.toString() : '';
|
||||
final path = uri.path;
|
||||
final queryParams = uri.queryParameters; // Currently not used
|
||||
final rpcUser = userInfo.split(':').first;
|
||||
final rpcPassword = userInfo.split(':').length > 1 ? userInfo.split(':')[1] : '';
|
||||
|
||||
await Future.delayed(Duration(milliseconds: 345));
|
||||
|
||||
setAddress(ipAddress);
|
||||
setPath(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue