Fixes for validation of bitcoin seed mnemonic text.

wownero
M 2 years ago
parent bd2e2ce258
commit bc07f9d69b

@ -1,5 +1,6 @@
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
@ -46,15 +47,19 @@ class WalletRestorePage extends BasePage {
}
},
onSeedChange: (String seed) {
final hasHeight = walletRestoreFromSeedFormKey
.currentState
.blockchainHeightKey
.currentState
.restoreHeightController
.text
.isNotEmpty;
if (hasHeight) {
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
if (walletRestoreViewModel.hasBlockchainHeightLanguageSelector) {
final hasHeight = walletRestoreFromSeedFormKey
.currentState
.blockchainHeightKey
.currentState
.restoreHeightController
.text
.isNotEmpty;
if (hasHeight) {
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
}
} else {
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
}
},
onLanguageChange: (_) {
@ -209,8 +214,16 @@ class WalletRestorePage extends BasePage {
.currentState
.text
.split(' ');
if (walletRestoreViewModel.type == WalletType.monero &&
seedWords.length != WalletRestoreViewModelBase.moneroSeedMnemonicLength) {
return false;
}
if (seedWords.length != walletRestoreViewModel.seedMnemonicLength) {
if ((walletRestoreViewModel.type == WalletType.bitcoin ||
walletRestoreViewModel.type == WalletType.litecoin) &&
(seedWords.length != WalletRestoreViewModelBase.electrumSeedMnemonicLength &&
seedWords.length != WalletRestoreViewModelBase.electrumShortSeedMnemonicLength)) {
return false;
}

@ -38,6 +38,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
static const moneroSeedMnemonicLength = 25;
static const electrumSeedMnemonicLength = 24;
static const electrumShortSeedMnemonicLength = 12;
final List<WalletRestoreMode> availableModes;
final bool hasSeedLanguageSelector;
@ -49,12 +50,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
@observable
bool isButtonEnabled;
int get seedMnemonicLength =>
type == WalletType.monero
? moneroSeedMnemonicLength
: electrumSeedMnemonicLength;
@override
WalletCredentials getCredentials(dynamic options) {
final password = generateWalletPassword(type);

Loading…
Cancel
Save