From 3920ae164a1d38bfbe0e8d0a884d29bc5ed075be Mon Sep 17 00:00:00 2001 From: YI Date: Thu, 13 Jun 2024 17:16:15 +0800 Subject: [PATCH] Clarify why we can't update tlc while awaiting RevokeAndAck --- src/ckb/channel.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ckb/channel.rs b/src/ckb/channel.rs index f17eb555..8fde4198 100644 --- a/src/ckb/channel.rs +++ b/src/ckb/channel.rs @@ -1778,7 +1778,18 @@ impl ChannelActorState { pub fn check_state_for_tlc_update(&self) -> ProcessingChannelResult { match self.state { - ChannelState::ChannelReady(flags) if flags.is_empty() => Ok(()), + ChannelState::ChannelReady(flags) => { + // TODO: Even if we are awaiting remote revoke, we should still stash these tlc updates, + // and perform corresponding actions after we receive the revoke_and_ack message. + if flags.contains(ChannelReadyFlags::AWAITING_REMOTE_REVOKE) { + Err(ProcessingChannelError::InvalidState( + "Trying to update tlc while channel is awaiting remote revocation" + .to_string(), + )) + } else { + Ok(()) + } + } ChannelState::ShuttingDown(_) => Ok(()), _ => Err(ProcessingChannelError::InvalidState(format!( "Invalid state {:?} for adding tlc",