mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
use wownero.getHeightByDate
and save bufferedHeight upon Monero wallet creation
This commit is contained in:
parent
a54d9a561e
commit
357b93d6e8
4 changed files with 20 additions and 13 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 9267fd0f0442a8d54b899473d77fc92ddc6d2391
|
||||
Subproject commit e705ba2d5126685adae9367b62921b676d7126ed
|
|
@ -186,11 +186,9 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
|
||||
if (widget.coin == Coin.monero) {
|
||||
height = monero.getHeigthByDate(date: widget.restoreFromDate);
|
||||
} else if (widget.coin == Coin.wownero) {
|
||||
height = wownero.getHeightByDate(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) {
|
||||
|
|
|
@ -699,7 +699,7 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
name: name,
|
||||
type: WalletType.monero,
|
||||
isRecovery: false,
|
||||
restoreHeight: credentials.height ?? 0,
|
||||
restoreHeight: bufferedCreateHeight,
|
||||
date: DateTime.now(),
|
||||
path: path,
|
||||
dirPath: dirPath,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cw_core/get_height_by_date.dart';
|
||||
import 'package:cw_core/monero_transaction_priority.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_core/pending_transaction.dart';
|
||||
|
@ -685,10 +686,7 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
await pathForWalletDir(name: name, type: WalletType.wownero);
|
||||
final path = await pathForWallet(name: name, type: WalletType.wownero);
|
||||
credentials = wownero.createWowneroNewWalletCredentials(
|
||||
name: name,
|
||||
language: "English",
|
||||
seedWordsLength: seedWordsLength
|
||||
);
|
||||
name: name, language: "English", seedWordsLength: seedWordsLength);
|
||||
|
||||
walletInfo = WalletInfo.external(
|
||||
id: WalletBase.idFor(name, WalletType.wownero),
|
||||
|
@ -713,9 +711,12 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
// To restore from a seed
|
||||
final wallet = await _walletCreationService?.create(credentials);
|
||||
|
||||
// subtract a couple days to ensure we have a buffer for SWB
|
||||
final bufferedCreateHeight = (seedWordsLength == 14) ? getSeedHeightSync(wallet?.seed.trim() as String) : 0;
|
||||
// TODO use an alternative to wow_seed's get_seed_height instead of 0 above
|
||||
final bufferedCreateHeight = (seedWordsLength == 14)
|
||||
? getSeedHeightSync(wallet?.seed.trim() as String)
|
||||
: wownero.getHeightByDate(
|
||||
date: DateTime.now().subtract(const Duration(
|
||||
days:
|
||||
2))); // subtract a couple days to ensure we have a buffer for SWB
|
||||
|
||||
await DB.instance.put<dynamic>(
|
||||
boxName: walletId, key: "restoreHeight", value: bufferedCreateHeight);
|
||||
|
@ -979,6 +980,14 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
// extract seed height from 14 word seed
|
||||
if (seedLength == 14) {
|
||||
height = getSeedHeightSync(mnemonic.trim());
|
||||
} else {
|
||||
// 25 word seed. TODO validate
|
||||
if (height == 0) {
|
||||
height = wownero.getHeightByDate(
|
||||
date: DateTime.now().subtract(const Duration(
|
||||
days:
|
||||
2))); // subtract a couple days to ensure we have a buffer for SWB\
|
||||
}
|
||||
}
|
||||
|
||||
await DB.instance
|
||||
|
|
Loading…
Reference in a new issue