clear out isar blockchain data per wallet when doing full rescan

This commit is contained in:
julian 2023-01-13 15:47:56 -06:00
parent 061658f2e9
commit 8a7236b46d
9 changed files with 75 additions and 3 deletions

View file

@ -2801,9 +2801,11 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
// clear blockchain info
await isar.writeTxn(() async {
await isar.addresses.clear();
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
try {

View file

@ -2435,6 +2435,15 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// back up data
// await _rescanBackup();
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
await _recoverWalletFromBIP32SeedPhrase(

View file

@ -904,6 +904,15 @@ class EpicCashWallet extends CoinServiceAPI
),
);
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
await epicUpdateLastScannedBlock(await getRestoreHeight());
if (!await startScans()) {

View file

@ -3596,6 +3596,15 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
// back up data
// await _rescanBackup();
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
await _recoverWalletFromBIP32SeedPhrase(mnemonic!, maxUnusedAddressGap);

View file

@ -2823,6 +2823,15 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// back up data
// await _rescanBackup();
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
await _recoverWalletFromBIP32SeedPhrase(

View file

@ -215,6 +215,15 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
int maxUnusedAddressGap,
int maxNumberOfIndexesToCheck,
) async {
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
var restoreHeight = walletBase?.walletInfo.restoreHeight;
highestPercentCached = 0;
await walletBase?.rescan(height: restoreHeight);

View file

@ -2812,6 +2812,15 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// back up data
// await _rescanBackup();
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
await _recoverWalletFromBIP32SeedPhrase(

View file

@ -1992,8 +1992,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
coin: coin,
);
// Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}");
// TODO fix this for sent to self transactions?
if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) {
tx["address"] = await isar.addresses
.filter()
@ -2898,6 +2896,15 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
// back up data
// await _rescanBackup();
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
await _recoverWalletFromBIP32SeedPhrase(

View file

@ -238,6 +238,15 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
int maxUnusedAddressGap,
int maxNumberOfIndexesToCheck,
) async {
// clear blockchain info
await isar.writeTxn(() async {
await isar.transactions.clear();
await isar.inputs.clear();
await isar.outputs.clear();
await isar.utxos.clear();
await isar.addresses.clear();
});
var restoreHeight = walletBase?.walletInfo.restoreHeight;
highestPercentCached = 0;
await walletBase?.rescan(height: restoreHeight);