mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
fixes for restoring
This commit is contained in:
parent
0e8647b2f5
commit
a6a4e88a94
2 changed files with 11 additions and 4 deletions
|
@ -51,7 +51,11 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
|
||||||
WalletCredentials getCredentialsFromRestoredWallet(
|
WalletCredentials getCredentialsFromRestoredWallet(
|
||||||
dynamic options, RestoredWallet restoreWallet) {
|
dynamic options, RestoredWallet restoreWallet) {
|
||||||
final password = generateWalletPassword();
|
final password = generateWalletPassword();
|
||||||
DerivationInfo? derivationInfo = options["derivationInfo"] as DerivationInfo?;
|
DerivationInfo? derivationInfo;
|
||||||
|
if (options != null) {
|
||||||
|
derivationInfo = options["derivationInfo"] as DerivationInfo?;
|
||||||
|
}
|
||||||
|
derivationInfo ??= getDefaultDerivation();
|
||||||
|
|
||||||
switch (restoreWallet.restoreMode) {
|
switch (restoreWallet.restoreMode) {
|
||||||
case WalletRestoreMode.keys:
|
case WalletRestoreMode.keys:
|
||||||
|
@ -89,7 +93,7 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
|
||||||
name: name,
|
name: name,
|
||||||
mnemonic: restoreWallet.mnemonicSeed ?? '',
|
mnemonic: restoreWallet.mnemonicSeed ?? '',
|
||||||
password: password,
|
password: password,
|
||||||
derivationType: derivationInfo!.derivationType!,
|
derivationType: derivationInfo.derivationType!,
|
||||||
derivationPath: derivationInfo.derivationPath!,
|
derivationPath: derivationInfo.derivationPath!,
|
||||||
);
|
);
|
||||||
case WalletType.bitcoinCash:
|
case WalletType.bitcoinCash:
|
||||||
|
@ -100,7 +104,10 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
|
||||||
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password);
|
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password);
|
||||||
case WalletType.nano:
|
case WalletType.nano:
|
||||||
return nano!.createNanoRestoreWalletFromSeedCredentials(
|
return nano!.createNanoRestoreWalletFromSeedCredentials(
|
||||||
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password, derivationType: DerivationType.def);
|
name: name,
|
||||||
|
mnemonic: restoreWallet.mnemonicSeed ?? '',
|
||||||
|
password: password,
|
||||||
|
derivationType: derivationInfo.derivationType!);
|
||||||
default:
|
default:
|
||||||
throw Exception('Unexpected type: ${type.toString()}');
|
throw Exception('Unexpected type: ${type.toString()}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ abstract class WalletKeysViewModelBase with Store {
|
||||||
final restoreHeightResult = await restoreHeight;
|
final restoreHeightResult = await restoreHeight;
|
||||||
return {
|
return {
|
||||||
if (_appStore.wallet!.seed != null) 'seed': _appStore.wallet!.seed!,
|
if (_appStore.wallet!.seed != null) 'seed': _appStore.wallet!.seed!,
|
||||||
if (_appStore.wallet!.privateKey != null) 'private_key': _appStore.wallet!.privateKey!,
|
if (_appStore.wallet!.privateKey != null && _appStore.wallet!.seed == null) 'private_key': _appStore.wallet!.privateKey!,
|
||||||
if (restoreHeightResult != null) ...{'height': restoreHeightResult}
|
if (restoreHeightResult != null) ...{'height': restoreHeightResult}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue