mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
Fixes for validation of bitcoin seed mnemonic text.
This commit is contained in:
parent
bd2e2ce258
commit
bc07f9d69b
2 changed files with 25 additions and 16 deletions
|
@ -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,6 +47,7 @@ class WalletRestorePage extends BasePage {
|
|||
}
|
||||
},
|
||||
onSeedChange: (String seed) {
|
||||
if (walletRestoreViewModel.hasBlockchainHeightLanguageSelector) {
|
||||
final hasHeight = walletRestoreFromSeedFormKey
|
||||
.currentState
|
||||
.blockchainHeightKey
|
||||
|
@ -56,6 +58,9 @@ class WalletRestorePage extends BasePage {
|
|||
if (hasHeight) {
|
||||
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
|
||||
}
|
||||
} else {
|
||||
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
|
||||
}
|
||||
},
|
||||
onLanguageChange: (_) {
|
||||
if (walletRestoreViewModel.hasBlockchainHeightLanguageSelector) {
|
||||
|
@ -210,7 +215,15 @@ class WalletRestorePage extends BasePage {
|
|||
.text
|
||||
.split(' ');
|
||||
|
||||
if (seedWords.length != walletRestoreViewModel.seedMnemonicLength) {
|
||||
if (walletRestoreViewModel.type == WalletType.monero &&
|
||||
seedWords.length != WalletRestoreViewModelBase.moneroSeedMnemonicLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -50,11 +51,6 @@ 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…
Reference in a new issue