Skip to content

Commit a5c0bc0

Browse files
committed
feat: clear cached vss store id on wipe
1 parent 7f6b7b3 commit a5c0bc0

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

app/src/main/java/to/bitkit/data/backup/VssStoreIdProvider.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@ class VssStoreIdProvider @Inject constructor(
2828
passphrase = passphrase,
2929
)
3030

31-
Logger.info("VSS store id: '$storeId' for walletIndex: $walletIndex", context = TAG)
3231
cachedStoreIds[walletIndex] = storeId
32+
Logger.info("VSS store id setup for wallet[$walletIndex]: '$storeId'", context = TAG)
3333
return storeId
3434
}
3535
}
3636

37-
fun clearCache() {
38-
cachedStoreIds.clear()
39-
}
40-
41-
fun clearCache(walletIndex: Int) {
37+
fun clearCache(walletIndex: Int = 0) {
4238
cachedStoreIds.remove(walletIndex)
4339
}
4440

app/src/main/java/to/bitkit/repositories/WalletRepo.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.lightningdevkit.ldknode.Event
1818
import to.bitkit.data.AppDb
1919
import to.bitkit.data.CacheStore
2020
import to.bitkit.data.SettingsStore
21+
import to.bitkit.data.backup.VssStoreIdProvider
2122
import to.bitkit.data.entities.TagMetadataEntity
2223
import to.bitkit.data.keychain.Keychain
2324
import to.bitkit.di.BgDispatcher
@@ -50,6 +51,7 @@ class WalletRepo @Inject constructor(
5051
private val lightningRepo: LightningRepo,
5152
private val cacheStore: CacheStore,
5253
private val deriveBalanceStateUseCase: DeriveBalanceStateUseCase,
54+
private val vssStoreIdProvider: VssStoreIdProvider,
5355
) {
5456
private val repoScope = CoroutineScope(bgDispatcher + SupervisorJob())
5557

@@ -210,6 +212,7 @@ class WalletRepo @Inject constructor(
210212
suspend fun wipeWallet(walletIndex: Int = 0): Result<Unit> = withContext(bgDispatcher) {
211213
try {
212214
keychain.wipe()
215+
vssStoreIdProvider.clearCache(walletIndex)
213216
db.clearAllTables()
214217
settingsStore.reset()
215218
cacheStore.reset()

0 commit comments

Comments
 (0)