mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02:00
update wallet restore page to be less confusing for nano users (#1186)
* update wallet restore page to be less confusing for nano users * update translations * only include private key if seed phrase is null * restore fixes * fix default derivation being wrong on restore * fix default nano derivationType & qr code parameters * update language on nano restore (hex form) * support hex seed from qr restore
This commit is contained in:
@@ -133,7 +133,7 @@ class WalletRestoreFromKeysFromState extends State<WalletRestoreFromKeysFrom> {
|
||||
widget.walletRestoreViewModel.type == WalletType.banano;
|
||||
return AddressTextField(
|
||||
controller: privateKeyController,
|
||||
placeholder: nanoBased ? S.of(context).seed_key : S.of(context).private_key,
|
||||
placeholder: nanoBased ? S.of(context).seed_hex_form : S.of(context).private_key,
|
||||
options: [AddressTextFieldOption.paste],
|
||||
buttonColor: Theme.of(context).hintColor,
|
||||
onPushPasteButton: (_) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class RestoredWallet {
|
||||
factory RestoredWallet.fromSeed(Map<String, dynamic> json) {
|
||||
final height = json['height'] as String?;
|
||||
final mnemonic_seed = json['mnemonic_seed'] as String?;
|
||||
final seed = json['seed'] as String?;
|
||||
final seed = json['seed'] as String? ?? json['hexSeed'] as String?;
|
||||
return RestoredWallet(
|
||||
restoreMode: json['mode'] as WalletRestoreMode,
|
||||
type: json['type'] as WalletType,
|
||||
|
||||
@@ -151,6 +151,14 @@ class WalletRestoreFromQRCode {
|
||||
return WalletRestoreMode.keys;
|
||||
}
|
||||
|
||||
if ((type == WalletType.nano || type == WalletType.banano) && credentials.containsKey('hexSeed')) {
|
||||
final hexSeed = credentials['hexSeed'] as String;
|
||||
if (hexSeed.isEmpty) {
|
||||
throw Exception('Unexpected restore mode: hexSeed');
|
||||
}
|
||||
return WalletRestoreMode.seed;
|
||||
}
|
||||
|
||||
throw Exception('Unexpected restore mode: restore params are invalid');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,19 +107,18 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
]);
|
||||
}
|
||||
|
||||
if (_appStore.wallet!.type == WalletType.nano || _appStore.wallet!.type == WalletType.banano) {
|
||||
bool nanoBased =
|
||||
_appStore.wallet!.type == WalletType.nano || _appStore.wallet!.type == WalletType.banano;
|
||||
|
||||
// we don't necessarily have the seed phrase for nano / banano:
|
||||
if (_appStore.wallet!.seed != null) {
|
||||
items.addAll([
|
||||
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||
]);
|
||||
}
|
||||
|
||||
// we always have the hex version of the seed:
|
||||
if (nanoBased) {
|
||||
// we always have the hex version of the seed and private key:
|
||||
items.addAll([
|
||||
if (_appStore.wallet!.seed != null)
|
||||
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||
if (_appStore.wallet!.hexSeed != null)
|
||||
StandartListItem(title: S.current.seed_hex_form, value: _appStore.wallet!.hexSeed!),
|
||||
if (_appStore.wallet!.privateKey != null)
|
||||
StandartListItem(title: S.current.spend_key_private, value: _appStore.wallet!.privateKey!),
|
||||
StandartListItem(title: S.current.private_key, value: _appStore.wallet!.privateKey!),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +171,10 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
final restoreHeightResult = await restoreHeight;
|
||||
return {
|
||||
if (_appStore.wallet!.seed != null) 'seed': _appStore.wallet!.seed!,
|
||||
if (_appStore.wallet!.privateKey != null) 'private_key': _appStore.wallet!.privateKey!,
|
||||
if (_appStore.wallet!.seed == null && _appStore.wallet!.hexSeed != null)
|
||||
'hexSeed': _appStore.wallet!.hexSeed!,
|
||||
if (_appStore.wallet!.seed == null && _appStore.wallet!.privateKey != null)
|
||||
'private_key': _appStore.wallet!.privateKey!,
|
||||
if (restoreHeightResult != null) ...{'height': restoreHeightResult}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user