mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
Merge pull request #439 from cypherstack/xmr_bugs
startup => specific wallet => xmr/wow syncing/loading fix
This commit is contained in:
commit
a4755121c8
4 changed files with 97 additions and 48 deletions
|
@ -14,7 +14,9 @@ import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/biometrics.dart';
|
import 'package:stackwallet/utilities/biometrics.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||||
|
import 'package:stackwallet/utilities/show_loading.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
|
@ -80,19 +82,47 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
|
||||||
if (widget.popOnSuccess) {
|
if (widget.popOnSuccess) {
|
||||||
Navigator.of(context).pop(widget.routeOnSuccessArguments);
|
Navigator.of(context).pop(widget.routeOnSuccessArguments);
|
||||||
} else {
|
} else {
|
||||||
unawaited(Navigator.of(context).pushReplacementNamed(
|
final loadIntoWallet = widget.routeOnSuccess == HomeView.routeName &&
|
||||||
widget.routeOnSuccess,
|
widget.routeOnSuccessArguments is String;
|
||||||
arguments: widget.routeOnSuccessArguments,
|
|
||||||
));
|
if (loadIntoWallet) {
|
||||||
if (widget.routeOnSuccess == HomeView.routeName &&
|
|
||||||
widget.routeOnSuccessArguments is String) {
|
|
||||||
final walletId = widget.routeOnSuccessArguments as String;
|
final walletId = widget.routeOnSuccessArguments as String;
|
||||||
unawaited(Navigator.of(context).pushNamed(WalletView.routeName,
|
|
||||||
arguments: Tuple2(
|
final manager =
|
||||||
|
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||||
|
if (manager.coin == Coin.monero || manager.coin == Coin.wownero) {
|
||||||
|
await showLoading(
|
||||||
|
opaqueBG: true,
|
||||||
|
whileFuture: manager.initializeExisting(),
|
||||||
|
context: context,
|
||||||
|
message: "Loading ${manager.coin.prettyName} wallet...",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
unawaited(
|
||||||
|
Navigator.of(context).pushReplacementNamed(
|
||||||
|
widget.routeOnSuccess,
|
||||||
|
arguments: widget.routeOnSuccessArguments,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (loadIntoWallet) {
|
||||||
|
final walletId = widget.routeOnSuccessArguments as String;
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
WalletView.routeName,
|
||||||
|
arguments: Tuple2(
|
||||||
walletId,
|
walletId,
|
||||||
ref
|
ref
|
||||||
.read(walletsChangeNotifierProvider)
|
.read(walletsChangeNotifierProvider)
|
||||||
.getManagerProvider(walletId))));
|
.getManagerProvider(walletId),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_native_splash/cli_commands.dart';
|
import 'package:flutter_native_splash/cli_commands.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
|
|
||||||
class AddressTag extends StatelessWidget {
|
class AddressTag extends StatelessWidget {
|
||||||
|
@ -16,10 +17,12 @@ class AddressTag extends StatelessWidget {
|
||||||
vertical: 5,
|
vertical: 5,
|
||||||
horizontal: 7,
|
horizontal: 7,
|
||||||
),
|
),
|
||||||
color: Colors.black,
|
color: Theme.of(context).extension<StackColors>()!.buttonBackPrimary,
|
||||||
child: Text(
|
child: Text(
|
||||||
tag.capitalize(),
|
tag.capitalize(),
|
||||||
style: STextStyles.w500_14(context),
|
style: STextStyles.w500_14(context).copyWith(
|
||||||
|
color: Theme.of(context).extension<StackColors>()!.buttonTextPrimary,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,44 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
late bool saveEnabled;
|
late bool saveEnabled;
|
||||||
late bool testConnectionEnabled;
|
late bool testConnectionEnabled;
|
||||||
|
|
||||||
|
Future<bool> _xmrHelper(String url, int? port) async {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
|
||||||
|
final String path = uri.path.isEmpty ? "/json_rpc" : uri.path;
|
||||||
|
|
||||||
|
final uriString = "${uri.scheme}://${uri.host}:${port ?? 0}$path";
|
||||||
|
|
||||||
|
ref.read(nodeFormDataProvider).useSSL = true;
|
||||||
|
|
||||||
|
final response = await testMoneroNodeConnection(
|
||||||
|
Uri.parse(uriString),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.cert != null) {
|
||||||
|
if (mounted) {
|
||||||
|
final shouldAllowBadCert = await showBadX509CertificateDialog(
|
||||||
|
response.cert!,
|
||||||
|
response.url!,
|
||||||
|
response.port!,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (shouldAllowBadCert) {
|
||||||
|
final response =
|
||||||
|
await testMoneroNodeConnection(Uri.parse(uriString), true);
|
||||||
|
ref.read(nodeFormDataProvider).host = url;
|
||||||
|
return response.success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ref.read(nodeFormDataProvider).host = url;
|
||||||
|
return response.success;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> _testConnection({bool showFlushBar = true}) async {
|
Future<bool> _testConnection({bool showFlushBar = true}) async {
|
||||||
final formData = ref.read(nodeFormDataProvider);
|
final formData = ref.read(nodeFormDataProvider);
|
||||||
|
|
||||||
|
@ -86,41 +124,19 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
case Coin.monero:
|
case Coin.monero:
|
||||||
case Coin.wownero:
|
case Coin.wownero:
|
||||||
try {
|
try {
|
||||||
final uri = Uri.parse(formData.host!);
|
final url = formData.host!;
|
||||||
if (uri.scheme.startsWith("http")) {
|
final uri = Uri.tryParse(url);
|
||||||
final String path = uri.path.isEmpty ? "/json_rpc" : uri.path;
|
if (uri != null) {
|
||||||
|
if (!uri.hasScheme) {
|
||||||
|
// try https first
|
||||||
|
testPassed = await _xmrHelper("https://$url", formData.port);
|
||||||
|
|
||||||
String uriString =
|
if (testPassed == false) {
|
||||||
"${uri.scheme}://${uri.host}:${formData.port ?? 0}$path";
|
// try http
|
||||||
|
testPassed = await _xmrHelper("http://$url", formData.port);
|
||||||
if (uri.host == "https") {
|
|
||||||
ref.read(nodeFormDataProvider).useSSL = true;
|
|
||||||
} else {
|
|
||||||
ref.read(nodeFormDataProvider).useSSL = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final response = await testMoneroNodeConnection(
|
|
||||||
Uri.parse(uriString),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.cert != null) {
|
|
||||||
if (mounted) {
|
|
||||||
final shouldAllowBadCert = await showBadX509CertificateDialog(
|
|
||||||
response.cert!,
|
|
||||||
response.url!,
|
|
||||||
response.port!,
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (shouldAllowBadCert) {
|
|
||||||
final response = await testMoneroNodeConnection(
|
|
||||||
Uri.parse(uriString), true);
|
|
||||||
testPassed = response.success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
testPassed = response.success;
|
testPassed = await _xmrHelper(url, formData.port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
|
@ -158,7 +174,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showFlushBar) {
|
if (showFlushBar && mounted) {
|
||||||
if (testPassed) {
|
if (testPassed) {
|
||||||
unawaited(showFloatingFlushBar(
|
unawaited(showFloatingFlushBar(
|
||||||
type: FlushBarType.success,
|
type: FlushBarType.success,
|
||||||
|
@ -182,7 +198,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
|
|
||||||
bool? shouldSave;
|
bool? shouldSave;
|
||||||
|
|
||||||
if (!canConnect) {
|
if (!canConnect && mounted) {
|
||||||
await showDialog<dynamic>(
|
await showDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
|
@ -975,7 +991,6 @@ class _NodeFormState extends ConsumerState<NodeForm> {
|
||||||
controller: _usernameController,
|
controller: _usernameController,
|
||||||
readOnly: shouldBeReadOnly,
|
readOnly: shouldBeReadOnly,
|
||||||
enabled: enableField(_usernameController),
|
enabled: enableField(_usernameController),
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
focusNode: _usernameFocusNode,
|
focusNode: _usernameFocusNode,
|
||||||
style: STextStyles.field(context),
|
style: STextStyles.field(context),
|
||||||
decoration: standardInputDecoration(
|
decoration: standardInputDecoration(
|
||||||
|
@ -1024,7 +1039,7 @@ class _NodeFormState extends ConsumerState<NodeForm> {
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
readOnly: shouldBeReadOnly,
|
readOnly: shouldBeReadOnly,
|
||||||
enabled: enableField(_passwordController),
|
enabled: enableField(_passwordController),
|
||||||
keyboardType: TextInputType.number,
|
obscureText: true,
|
||||||
focusNode: _passwordFocusNode,
|
focusNode: _passwordFocusNode,
|
||||||
style: STextStyles.field(context),
|
style: STextStyles.field(context),
|
||||||
decoration: standardInputDecoration(
|
decoration: standardInputDecoration(
|
||||||
|
|
|
@ -10,6 +10,7 @@ Future<T> showLoading<T>({
|
||||||
required String message,
|
required String message,
|
||||||
String? subMessage,
|
String? subMessage,
|
||||||
bool isDesktop = false,
|
bool isDesktop = false,
|
||||||
|
bool opaqueBG = false,
|
||||||
}) async {
|
}) async {
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
|
@ -21,7 +22,7 @@ Future<T> showLoading<T>({
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.overlay
|
.overlay
|
||||||
.withOpacity(0.6),
|
.withOpacity(opaqueBG ? 1.0 : 0.6),
|
||||||
child: CustomLoadingOverlay(
|
child: CustomLoadingOverlay(
|
||||||
message: message,
|
message: message,
|
||||||
subMessage: subMessage,
|
subMessage: subMessage,
|
||||||
|
|
Loading…
Reference in a new issue