Updated on 2026-08-14
This commit is contained in:
parent
52a607c1f5
commit
9944036c4d
29 changed files with 874 additions and 60 deletions
|
|
@ -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?>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue