Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-08 14:09:57 +03:00
parent 52a607c1f5
commit 9944036c4d
29 changed files with 874 additions and 60 deletions

View file

@ -2,6 +2,7 @@ package com.tangem.data.wallets.derivations
import arrow.core.getOrElse
import com.tangem.common.extensions.ByteArrayKey
import com.tangem.common.extensions.toMapKey
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.wallets.UserWalletsListRepository
import com.tangem.domain.common.wallets.getSyncStrict
@ -76,6 +77,23 @@ internal class DefaultDerivationsRepository @Inject constructor(
}
}
override suspend fun getExistingDerivedKeys(
userWalletId: UserWalletId,
seedKey: ByteArrayKey,
): ExtendedPublicKeysMap {
val userWallet = userWalletsListRepository.getSyncStrict(userWalletId)
return userWallet.getExistingDerivedKeys()[seedKey] ?: ExtendedPublicKeysMap(emptyMap())
}
private fun UserWallet.getExistingDerivedKeys(): Map<ByteArrayKey, ExtendedPublicKeysMap> {
return when (this) {
is UserWallet.Cold -> scanResponse.derivedKeys
is UserWallet.Hot -> wallets
?.associate { it.publicKey.toMapKey() to ExtendedPublicKeysMap(it.derivedKeys) }
.orEmpty()
}
}
override suspend fun hasMissedDerivations(
userWalletId: UserWalletId,
networksWithDerivationPath: Map<BackendId, String?>,