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/keyboard_done_button.dart';
|
||||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.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/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:keyboard_actions/keyboard_actions.dart';
|
import 'package:keyboard_actions/keyboard_actions.dart';
|
||||||
|
@ -46,15 +47,19 @@ class WalletRestorePage extends BasePage {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSeedChange: (String seed) {
|
onSeedChange: (String seed) {
|
||||||
final hasHeight = walletRestoreFromSeedFormKey
|
if (walletRestoreViewModel.hasBlockchainHeightLanguageSelector) {
|
||||||
.currentState
|
final hasHeight = walletRestoreFromSeedFormKey
|
||||||
.blockchainHeightKey
|
.currentState
|
||||||
.currentState
|
.blockchainHeightKey
|
||||||
.restoreHeightController
|
.currentState
|
||||||
.text
|
.restoreHeightController
|
||||||
.isNotEmpty;
|
.text
|
||||||
if (hasHeight) {
|
.isNotEmpty;
|
||||||
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
|
if (hasHeight) {
|
||||||
|
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
walletRestoreViewModel.isButtonEnabled = _isValidSeed();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLanguageChange: (_) {
|
onLanguageChange: (_) {
|
||||||
|
@ -209,8 +214,16 @@ class WalletRestorePage extends BasePage {
|
||||||
.currentState
|
.currentState
|
||||||
.text
|
.text
|
||||||
.split(' ');
|
.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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||||
|
|
||||||
static const moneroSeedMnemonicLength = 25;
|
static const moneroSeedMnemonicLength = 25;
|
||||||
static const electrumSeedMnemonicLength = 24;
|
static const electrumSeedMnemonicLength = 24;
|
||||||
|
static const electrumShortSeedMnemonicLength = 12;
|
||||||
|
|
||||||
final List<WalletRestoreMode> availableModes;
|
final List<WalletRestoreMode> availableModes;
|
||||||
final bool hasSeedLanguageSelector;
|
final bool hasSeedLanguageSelector;
|
||||||
|
@ -49,12 +50,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
bool isButtonEnabled;
|
bool isButtonEnabled;
|
||||||
|
|
||||||
int get seedMnemonicLength =>
|
|
||||||
type == WalletType.monero
|
|
||||||
? moneroSeedMnemonicLength
|
|
||||||
: electrumSeedMnemonicLength;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
WalletCredentials getCredentials(dynamic options) {
|
WalletCredentials getCredentials(dynamic options) {
|
||||||
final password = generateWalletPassword(type);
|
final password = generateWalletPassword(type);
|
||||||
|
|
Loading…
Reference in a new issue