diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt index 3c8ddfdd1..e42110c51 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt @@ -188,6 +188,9 @@ internal class JoinKeysignViewModel @Inject constructor( private var tempKeysignMessageProto: KeysignMessageProto? = null private val keysignPayload: KeysignPayload? get() = _keysignPayload + + private val deepLinkHelper = MutableStateFlow(null) + val keysignViewModel: KeysignViewModel get() = KeysignViewModel( vault = _currentVault, @@ -233,8 +236,8 @@ internal class JoinKeysignViewModel @Inject constructor( try { val content = Base64.UrlSafe.decode(qrBase64.toByteArray()) .decodeToString() - val deepLink = DeepLinkHelper(content) - val qrCodeContent = deepLink.getJsonData() + deepLinkHelper.value = DeepLinkHelper(content) + val qrCodeContent = requireNotNull(deepLinkHelper.value).getJsonData() qrCodeContent ?: run { throw Exception("Invalid QR code content") } @@ -242,13 +245,6 @@ internal class JoinKeysignViewModel @Inject constructor( val payloadProto = protoBuf.decodeFromByteArray(rawJson) Timber.d("Decoded KeysignMessageProto: $payloadProto") - if (deepLink.hasResharePrefix()) { - if (_currentVault.resharePrefix != deepLink.getResharePrefix()) { - currentState.value = - JoinKeysignState.Error(JoinKeysignError.WrongReShare) - return@launch - } - } this@JoinKeysignViewModel._sessionID = payloadProto.sessionId this@JoinKeysignViewModel._serviceName = payloadProto.serviceName this@JoinKeysignViewModel._useVultisigRelay = payloadProto.useVultisigRelay @@ -316,6 +312,14 @@ internal class JoinKeysignViewModel @Inject constructor( return false } + if (deepLinkHelper.value?.hasResharePrefix() == true) { + if (_currentVault.resharePrefix != requireNotNull(deepLinkHelper.value).getResharePrefix()) { + currentState.value = + JoinKeysignState.Error(JoinKeysignError.WrongReShare) + return false + } + } + val ksPayload = payload.payload this@JoinKeysignViewModel._keysignPayload = ksPayload