mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +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/biometrics.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/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
|
@ -80,19 +82,47 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
|
|||
if (widget.popOnSuccess) {
|
||||
Navigator.of(context).pop(widget.routeOnSuccessArguments);
|
||||
} else {
|
||||
unawaited(Navigator.of(context).pushReplacementNamed(
|
||||
widget.routeOnSuccess,
|
||||
arguments: widget.routeOnSuccessArguments,
|
||||
));
|
||||
if (widget.routeOnSuccess == HomeView.routeName &&
|
||||
widget.routeOnSuccessArguments is String) {
|
||||
final loadIntoWallet = widget.routeOnSuccess == HomeView.routeName &&
|
||||
widget.routeOnSuccessArguments is String;
|
||||
|
||||
if (loadIntoWallet) {
|
||||
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,
|
||||
ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManagerProvider(walletId))));
|
||||
.getManagerProvider(walletId),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_splash/cli_commands.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
|
||||
class AddressTag extends StatelessWidget {
|
||||
|
@ -16,10 +17,12 @@ class AddressTag extends StatelessWidget {
|
|||
vertical: 5,
|
||||
horizontal: 7,
|
||||
),
|
||||
color: Colors.black,
|
||||
color: Theme.of(context).extension<StackColors>()!.buttonBackPrimary,
|
||||
child: Text(
|
||||
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 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 {
|
||||
final formData = ref.read(nodeFormDataProvider);
|
||||
|
||||
|
@ -86,41 +124,19 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
|||
case Coin.monero:
|
||||
case Coin.wownero:
|
||||
try {
|
||||
final uri = Uri.parse(formData.host!);
|
||||
if (uri.scheme.startsWith("http")) {
|
||||
final String path = uri.path.isEmpty ? "/json_rpc" : uri.path;
|
||||
final url = formData.host!;
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri != null) {
|
||||
if (!uri.hasScheme) {
|
||||
// try https first
|
||||
testPassed = await _xmrHelper("https://$url", formData.port);
|
||||
|
||||
String uriString =
|
||||
"${uri.scheme}://${uri.host}:${formData.port ?? 0}$path";
|
||||
|
||||
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;
|
||||
}
|
||||
if (testPassed == false) {
|
||||
// try http
|
||||
testPassed = await _xmrHelper("http://$url", formData.port);
|
||||
}
|
||||
} else {
|
||||
testPassed = response.success;
|
||||
testPassed = await _xmrHelper(url, formData.port);
|
||||
}
|
||||
}
|
||||
} catch (e, s) {
|
||||
|
@ -158,7 +174,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
|||
break;
|
||||
}
|
||||
|
||||
if (showFlushBar) {
|
||||
if (showFlushBar && mounted) {
|
||||
if (testPassed) {
|
||||
unawaited(showFloatingFlushBar(
|
||||
type: FlushBarType.success,
|
||||
|
@ -182,7 +198,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
|||
|
||||
bool? shouldSave;
|
||||
|
||||
if (!canConnect) {
|
||||
if (!canConnect && mounted) {
|
||||
await showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
|
@ -975,7 +991,6 @@ class _NodeFormState extends ConsumerState<NodeForm> {
|
|||
controller: _usernameController,
|
||||
readOnly: shouldBeReadOnly,
|
||||
enabled: enableField(_usernameController),
|
||||
keyboardType: TextInputType.number,
|
||||
focusNode: _usernameFocusNode,
|
||||
style: STextStyles.field(context),
|
||||
decoration: standardInputDecoration(
|
||||
|
@ -1024,7 +1039,7 @@ class _NodeFormState extends ConsumerState<NodeForm> {
|
|||
controller: _passwordController,
|
||||
readOnly: shouldBeReadOnly,
|
||||
enabled: enableField(_passwordController),
|
||||
keyboardType: TextInputType.number,
|
||||
obscureText: true,
|
||||
focusNode: _passwordFocusNode,
|
||||
style: STextStyles.field(context),
|
||||
decoration: standardInputDecoration(
|
||||
|
|
|
@ -10,6 +10,7 @@ Future<T> showLoading<T>({
|
|||
required String message,
|
||||
String? subMessage,
|
||||
bool isDesktop = false,
|
||||
bool opaqueBG = false,
|
||||
}) async {
|
||||
unawaited(
|
||||
showDialog<void>(
|
||||
|
@ -21,7 +22,7 @@ Future<T> showLoading<T>({
|
|||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.overlay
|
||||
.withOpacity(0.6),
|
||||
.withOpacity(opaqueBG ? 1.0 : 0.6),
|
||||
child: CustomLoadingOverlay(
|
||||
message: message,
|
||||
subMessage: subMessage,
|
||||
|
|
Loading…
Reference in a new issue