Fix bug, parse_cipher keeps a cipher we can't decrypt

This commit is contained in:
Sosthene 2024-10-12 22:39:40 +02:00
parent 8ca4023d21
commit 4b8d5c3611

View File

@ -1111,10 +1111,18 @@ pub fn parse_cipher(cipher_msg: String) -> ApiResult<ApiReturn> {
.map_err(|e| ApiError::new(format!("Failed to handle decrypted message: {}", e)));
}
// If both decryption attempts fail, return an error
Err(ApiError::new(
"Failed to decrypt cipher with any known method".to_owned(),
))
// If both decryption attempts fail, we keep it just in case we receive the transaction later
let mut return_msg = CachedMessage::new();
return_msg.cipher = vec![cipher_msg];
return_msg.status = CachedMessageStatus::CipherWaitingTx;
let mut messages_cache = lock_messages()?;
messages_cache.push(return_msg.clone());
Ok(ApiReturn {
updated_cached_msg: vec![return_msg],
..Default::default()
})
}
#[wasm_bindgen]