recover

open suspend fun recover(cipherText: String? = null, backupMethod: BackupMethods = BackupMethods.Gdrive, progress: (status: MpcStatus) -> Unit = {}): String

Recovers the MPC shares for the user's wallet.

This function retrieves and decrypts the user's encrypted MPC shares from the specified backup method, then reconstructs and stores them in the keychain. It also updates the share pair status on the server.

Return

The EIP155 address of the recovered wallet.

Parameters

cipherText

Optional. The client's cipher text. If null and backupWithPortalEnabled is true, the function will attempt to retrieve the cipher text from the Portal API. If null and backupWithPortalEnabled is false it will throw an error

backupMethod

The method used for backing up the shares (e.g., Google Drive). Defaults to BackupMethods.Gdrive.

progress

A callback function that provides updates on the recovery process. It receives an MpcStatus object as a parameter, indicating the current status and whether the operation is completed.

Throws

if:

  • The MPC version is not "v6".

  • A wallet modification operation is already in progress.

  • The client information cannot be retrieved from storage.

  • No backup share is found for the specified backup method.

  • No client cipher text is found for the specified backup method.

  • The key cannot be read from storage.

  • The SECP256K1 share cannot be read from storage.

  • There is an issue during Keychain operations.

  • There is an issue recovering one of the shares.

  • The EIP155 address cannot be read from storage after recovery.

  • Any other error occurs during the recovery process.