mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 15:02:20 +01:00
Stop allowing new commitments without updates/revoke
This commit is contained in:
parent
9606f94caf
commit
7bb290fe3a
1 changed files with 13 additions and 0 deletions
|
@ -1621,6 +1621,19 @@ impl Channel {
|
|||
if (self.channel_state & (ChannelState::ChannelFunded as u32)) != (ChannelState::ChannelFunded as u32) {
|
||||
return Err(HandleError{err: "Cannot create commitment tx until channel is fully established", msg: None});
|
||||
}
|
||||
if (self.channel_state & (ChannelState::AwaitingRemoteRevoke as u32)) == (ChannelState::AwaitingRemoteRevoke as u32) {
|
||||
return Err(HandleError{err: "Cannot create commitment tx until remote revokes their previous commitment", msg: None});
|
||||
}
|
||||
let mut have_updates = false; // TODO initialize with "have we sent a fee update?"
|
||||
for htlc in self.pending_htlcs.iter() {
|
||||
if htlc.state == HTLCState::LocalAnnounced {
|
||||
have_updates = true;
|
||||
}
|
||||
if have_updates { break; }
|
||||
}
|
||||
if !have_updates {
|
||||
return Err(HandleError{err: "Cannot create commitment tx until we have some updates to send", msg: None});
|
||||
}
|
||||
|
||||
let funding_script = self.get_funding_redeemscript();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue