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( SizedBox(
height: isDesktop ? 40 : 24, 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( Text(
"Choose start date", "Choose start date",
style: isDesktop style: isDesktop
@ -264,11 +268,19 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
: STextStyles.smallMed12(context), : STextStyles.smallMed12(context),
textAlign: TextAlign.left, 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( SizedBox(
height: isDesktop ? 16 : 8, 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) // if (!isDesktop)
RestoreFromDatePicker( RestoreFromDatePicker(
@ -278,11 +290,19 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
// if (isDesktop) // if (isDesktop)
// // TODO desktop date picker // // 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( const SizedBox(
height: 8, 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( RoundedWhiteContainer(
child: Center( child: Center(
child: Text( 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( SizedBox(
height: isDesktop ? 24 : 16, height: isDesktop ? 24 : 16,
), ),

View file

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

View file

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

View file

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