mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
fix: Prevent failed keys fetch from disabling display of mnemonic
This commit is contained in:
parent
9c64ed6316
commit
c56038cadf
3 changed files with 26 additions and 115 deletions
|
@ -156,11 +156,13 @@ class _CNWalletKeysState extends State<CNWalletKeys> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Util.isDesktop ? 12 : 16,
|
height: Util.isDesktop ? 12 : 16,
|
||||||
),
|
),
|
||||||
QR(
|
if (_current(_currentDropDownValue) != "ERROR")
|
||||||
data: _current(_currentDropDownValue),
|
QR(
|
||||||
size:
|
data: _current(_currentDropDownValue),
|
||||||
Util.isDesktop ? 256 : MediaQuery.of(context).size.width / 1.5,
|
size: Util.isDesktop
|
||||||
),
|
? 256
|
||||||
|
: MediaQuery.of(context).size.width / 1.5,
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Util.isDesktop ? 12 : 16,
|
height: Util.isDesktop ? 12 : 16,
|
||||||
),
|
),
|
||||||
|
|
|
@ -313,108 +313,7 @@ class _UnlockWalletKeysDesktopState
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
label: "Continue",
|
label: "Continue",
|
||||||
enabled: continueEnabled,
|
enabled: continueEnabled,
|
||||||
onPressed: continueEnabled
|
onPressed: continueEnabled ? enterPassphrase : null,
|
||||||
? () async {
|
|
||||||
unawaited(
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => const Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
LoadingIndicator(
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await Future<void>.delayed(
|
|
||||||
const Duration(seconds: 1),
|
|
||||||
);
|
|
||||||
|
|
||||||
final verified = await ref
|
|
||||||
.read(storageCryptoHandlerProvider)
|
|
||||||
.verifyPassphrase(passwordController.text);
|
|
||||||
|
|
||||||
if (verified) {
|
|
||||||
if (context.mounted) {
|
|
||||||
Navigator.of(context, rootNavigator: true)
|
|
||||||
.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
({String keys, String config})? frostData;
|
|
||||||
List<String>? words;
|
|
||||||
|
|
||||||
final wallet =
|
|
||||||
ref.read(pWallets).getWallet(widget.walletId);
|
|
||||||
|
|
||||||
// TODO: [prio=low] handle wallets that don't have a mnemonic
|
|
||||||
// All wallets currently are mnemonic based
|
|
||||||
if (wallet is! MnemonicInterface) {
|
|
||||||
if (wallet is BitcoinFrostWallet) {
|
|
||||||
frostData = (
|
|
||||||
keys: (await wallet.getSerializedKeys())!,
|
|
||||||
config: (await wallet.getMultisigConfig())!,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw Exception("FIXME ~= see todo in code");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (wallet is ViewOnlyOptionInterface &&
|
|
||||||
(wallet as ViewOnlyOptionInterface)
|
|
||||||
.isViewOnly) {
|
|
||||||
// TODO: is something needed here?
|
|
||||||
} else {
|
|
||||||
words = await wallet.getMnemonicAsWords();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyDataInterface? keyData;
|
|
||||||
if (wallet is ViewOnlyOptionInterface &&
|
|
||||||
wallet.isViewOnly) {
|
|
||||||
keyData = await wallet.getViewOnlyWalletData();
|
|
||||||
} else if (wallet is ExtendedKeysInterface) {
|
|
||||||
keyData = await wallet.getXPrivs();
|
|
||||||
} else if (wallet is LibMoneroWallet) {
|
|
||||||
keyData = await wallet.getKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context.mounted) {
|
|
||||||
await Navigator.of(context)
|
|
||||||
.pushReplacementNamed(
|
|
||||||
WalletKeysDesktopPopup.routeName,
|
|
||||||
arguments: (
|
|
||||||
mnemonic: words ?? [],
|
|
||||||
walletId: widget.walletId,
|
|
||||||
frostData: frostData,
|
|
||||||
keyData: keyData,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (context.mounted) {
|
|
||||||
Navigator.of(context, rootNavigator: true)
|
|
||||||
.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
await Future<void>.delayed(
|
|
||||||
const Duration(milliseconds: 300),
|
|
||||||
);
|
|
||||||
if (context.mounted) {
|
|
||||||
unawaited(
|
|
||||||
showFloatingFlushBar(
|
|
||||||
type: FlushBarType.warning,
|
|
||||||
message: "Invalid passphrase!",
|
|
||||||
context: context,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -298,14 +298,24 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
||||||
if (base == null || (oldInfo != null && oldInfo.name != walletId)) {
|
if (base == null || (oldInfo != null && oldInfo.name != walletId)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
return CWKeyData(
|
return CWKeyData(
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
publicViewKey: base.getPublicViewKey(),
|
publicViewKey: base.getPublicViewKey(),
|
||||||
privateViewKey: base.getPrivateViewKey(),
|
privateViewKey: base.getPrivateViewKey(),
|
||||||
publicSpendKey: base.getPublicSpendKey(),
|
publicSpendKey: base.getPublicSpendKey(),
|
||||||
privateSpendKey: base.getPrivateSpendKey(),
|
privateSpendKey: base.getPrivateSpendKey(),
|
||||||
);
|
);
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log("getKeys failed: $e\n$s", level: LogLevel.Fatal);
|
||||||
|
return CWKeyData(
|
||||||
|
walletId: walletId,
|
||||||
|
publicViewKey: "ERROR",
|
||||||
|
privateViewKey: "ERROR",
|
||||||
|
publicSpendKey: "ERROR",
|
||||||
|
privateSpendKey: "ERROR",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<(String, String)>
|
Future<(String, String)>
|
||||||
|
|
Loading…
Reference in a new issue