Simplify CachedMessage

This commit is contained in:
Sosthene 2024-10-03 16:19:43 +02:00
parent d91a4a67eb
commit bb82a0b760

View File

@ -135,7 +135,6 @@ pub enum CachedMessageStatus {
NoStatus,
CipherWaitingTx,
TxWaitingPrd,
Opened, // Can receive more messages
}
/// Unique struct for both 4nk messages and notification/key exchange, both rust and ts
@ -148,12 +147,8 @@ pub struct CachedMessage {
pub transaction: Option<String>,
pub commitment: Option<String>, // content of the op_return
pub sender: Option<Member>, // Never None when message sent
pub recipient: Option<Member>, // Never None when message sent
pub shared_secrets: Vec<String>, // Max 2 secrets in case we send to both address of the recipient
pub cipher: Vec<String>, // Max 2 ciphers in case we send to both address of the recipient
pub prd: Option<String>, // Never None when message sent
pub pcd: Option<Value>, // Value is here an alias for impl Pcd
pub confirmed_by: Option<OutPoint>, // If this None, Sender keeps sending
pub timestamp: u64,
}
@ -176,7 +171,7 @@ impl CachedMessage {
serde_json::to_string(self).unwrap()
}
pub fn try_decrypt_message(&self, cipher: Vec<u8>) -> Result<Vec<u8>> {
pub fn try_decrypt_message(&self, cipher: &[u8]) -> Result<Vec<u8>> {
if self.shared_secrets.is_empty() {
return Err(Error::msg(
"Can't try decrypt this message, there's no shared secret",