Skip to content

Commit 7bb290f

Browse files
committed
Stop allowing new commitments without updates/revoke
1 parent 9606f94 commit 7bb290f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ln/channel.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,19 @@ impl Channel {
16211621
if (self.channel_state & (ChannelState::ChannelFunded as u32)) != (ChannelState::ChannelFunded as u32) {
16221622
return Err(HandleError{err: "Cannot create commitment tx until channel is fully established", msg: None});
16231623
}
1624+
if (self.channel_state & (ChannelState::AwaitingRemoteRevoke as u32)) == (ChannelState::AwaitingRemoteRevoke as u32) {
1625+
return Err(HandleError{err: "Cannot create commitment tx until remote revokes their previous commitment", msg: None});
1626+
}
1627+
let mut have_updates = false; // TODO initialize with "have we sent a fee update?"
1628+
for htlc in self.pending_htlcs.iter() {
1629+
if htlc.state == HTLCState::LocalAnnounced {
1630+
have_updates = true;
1631+
}
1632+
if have_updates { break; }
1633+
}
1634+
if !have_updates {
1635+
return Err(HandleError{err: "Cannot create commitment tx until we have some updates to send", msg: None});
1636+
}
16241637

16251638
let funding_script = self.get_funding_redeemscript();
16261639

0 commit comments

Comments
 (0)