WIP: wownero 25 word seed option ui

This commit is contained in:
julian 2022-11-08 12:00:10 -06:00
parent a8c3d5f104
commit e41f8088b0
4 changed files with 45 additions and 12 deletions

View file

@ -252,7 +252,11 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
SizedBox(
height: isDesktop ? 40 : 24,
),
if (coin == Coin.monero || coin == Coin.epicCash)
if (coin == Coin.monero ||
coin == Coin.epicCash ||
(coin == Coin.wownero &&
ref.watch(mnemonicWordCountStateProvider.state).state ==
25))
Text(
"Choose start date",
style: isDesktop
@ -264,11 +268,19 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
: STextStyles.smallMed12(context),
textAlign: TextAlign.left,
),
if (coin == Coin.monero || coin == Coin.epicCash)
if (coin == Coin.monero ||
coin == Coin.epicCash ||
(coin == Coin.wownero &&
ref.watch(mnemonicWordCountStateProvider.state).state ==
25))
SizedBox(
height: isDesktop ? 16 : 8,
),
if (coin == Coin.monero || coin == Coin.epicCash)
if (coin == Coin.monero ||
coin == Coin.epicCash ||
(coin == Coin.wownero &&
ref.watch(mnemonicWordCountStateProvider.state).state ==
25))
// if (!isDesktop)
RestoreFromDatePicker(
@ -278,11 +290,19 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
// if (isDesktop)
// // TODO desktop date picker
if (coin == Coin.monero || coin == Coin.epicCash)
if (coin == Coin.monero ||
coin == Coin.epicCash ||
(coin == Coin.wownero &&
ref.watch(mnemonicWordCountStateProvider.state).state ==
25))
const SizedBox(
height: 8,
),
if (coin == Coin.monero || coin == Coin.epicCash)
if (coin == Coin.monero ||
coin == Coin.epicCash ||
(coin == Coin.wownero &&
ref.watch(mnemonicWordCountStateProvider.state).state ==
25))
RoundedWhiteContainer(
child: Center(
child: Text(
@ -299,7 +319,11 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
),
),
),
if (coin == Coin.monero || coin == Coin.epicCash)
if (coin == Coin.monero ||
coin == Coin.epicCash ||
(coin == Coin.wownero &&
ref.watch(mnemonicWordCountStateProvider.state).state ==
25))
SizedBox(
height: isDesktop ? 24 : 16,
),

View file

@ -149,6 +149,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
super.dispose();
}
// TODO: check for wownero wordlist?
bool _isValidMnemonicWord(String word) {
// TODO: get the actual language
if (widget.coin == Coin.monero) {
@ -181,6 +182,10 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
if (widget.coin == Coin.monero) {
height = monero.getHeigthByDate(date: widget.restoreFromDate);
}
// todo: wait until this implemented
// else if (widget.coin == Coin.wownero) {
// height = wownero.getHeightByDate(date: widget.restoreFromDate);
// }
// TODO: make more robust estimate of date maybe using https://explorer.epic.tech/api-index
if (widget.coin == Coin.epicCash) {

View file

@ -942,6 +942,11 @@ class WowneroWallet extends CoinServiceAPI {
required int maxNumberOfIndexesToCheck,
required int height,
}) async {
final int seedLength = mnemonic.trim().split(" ").length;
if (!(seedLength == 14 || seedLength == 25)) {
throw Exception("Invalid wownero mnemonic length found: $seedLength");
}
await _prefs.init();
longMutex = true;
final start = DateTime.now();
@ -969,7 +974,10 @@ class WowneroWallet extends CoinServiceAPI {
await _secureStore.write(
key: '${_walletId}_mnemonic', value: mnemonic.trim());
// extract seed height from 14 word seed
if (seedLength == 14) {
height = getSeedHeightSync(mnemonic.trim());
}
await DB.instance
.put<dynamic>(boxName: walletId, key: "restoreHeight", value: height);

View file

@ -35,10 +35,6 @@ abstract class Constants {
static const int pinLength = 4;
// enable testnet
// TODO: currently unused
static const bool allowTestnets = true;
// Enable Logger.print statements
static const bool disableLogger = false;
@ -66,7 +62,7 @@ abstract class Constants {
values.addAll([25]);
break;
case Coin.wownero:
values.addAll([14]);
values.addAll([14, 25]);
break;
}
return values;