delete old derivations when doing full rescan

This commit is contained in:
julian 2023-01-17 08:19:30 -06:00
parent b348761bbe
commit 38453ceafb
7 changed files with 81 additions and 0 deletions

View file

@ -2740,6 +2740,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// await _rescanBackup(); // await _rescanBackup();
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -2892,6 +2893,20 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Logging.instance.log("rescan backup complete", level: LogLevel.Info); // Logging.instance.log("rescan backup complete", level: LogLevel.Info);
// } // }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH");
// P2SH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH");
// P2WPKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH");
}
bool isActive = false; bool isActive = false;
@override @override

View file

@ -2812,6 +2812,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
// clear blockchain info // clear blockchain info
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -2846,6 +2847,16 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
} }
} }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH");
// P2SH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH");
}
@override @override
set isFavorite(bool markFavorite) { set isFavorite(bool markFavorite) {
_isFavorite = markFavorite; _isFavorite = markFavorite;

View file

@ -2439,6 +2439,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// clear blockchain info // clear blockchain info
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -2476,6 +2477,12 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
} }
} }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH");
}
// Future<void> _rescanRestore() async { // Future<void> _rescanRestore() async {
// Logging.instance.log("starting rescan restore", level: LogLevel.Info); // Logging.instance.log("starting rescan restore", level: LogLevel.Info);
// //

View file

@ -3616,6 +3616,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
// clear blockchain info // clear blockchain info
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -3649,6 +3650,12 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
} }
} }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivations");
await _secureStore.delete(key: "${walletId}_changeDerivations");
}
// Future<void> _rescanBackup() async { // Future<void> _rescanBackup() async {
// Logging.instance.log("starting rescan backup", level: LogLevel.Info); // Logging.instance.log("starting rescan backup", level: LogLevel.Info);
// //

View file

@ -2828,6 +2828,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// clear blockchain info // clear blockchain info
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -2865,6 +2866,20 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
} }
} }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH");
// P2SH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH");
// P2WPKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH");
}
// Future<void> _rescanRestore() async { // Future<void> _rescanRestore() async {
// Logging.instance.log("starting rescan restore", level: LogLevel.Info); // Logging.instance.log("starting rescan restore", level: LogLevel.Info);
// //

View file

@ -2817,6 +2817,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
// clear blockchain info // clear blockchain info
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -2854,6 +2855,20 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
} }
} }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH");
// P2SH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH");
// P2WPKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH");
}
// Future<void> _rescanRestore() async { // Future<void> _rescanRestore() async {
// Logging.instance.log("starting rescan restore", level: LogLevel.Info); // Logging.instance.log("starting rescan restore", level: LogLevel.Info);
// //

View file

@ -2904,6 +2904,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
// await _rescanBackup(); // await _rescanBackup();
await db.deleteWalletBlockchainData(walletId); await db.deleteWalletBlockchainData(walletId);
await _deleteDerivations();
try { try {
final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic');
@ -2941,6 +2942,16 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
} }
} }
Future<void> _deleteDerivations() async {
// P2PKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH");
// P2WPKH derivations
await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH");
await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH");
}
// Future<void> _rescanRestore() async { // Future<void> _rescanRestore() async {
// Logging.instance.log("starting rescan restore", level: LogLevel.Info); // Logging.instance.log("starting rescan restore", level: LogLevel.Info);
// //