Skip to content

Commit 9206ae7

Browse files
committed
Fix EnforcingChannelKeys panic when our counterparty burns their $.
If our counterparty burns their funds by revoking their current commitment transaction before we've sent them a new one, we'll step forward the remote commitment number. This would be otherwise fine (and may even encourage them to broadcast their revoked state(s) on chain), except that our new EnforcingChannelKeys expects us to not jump forward in time. Since it isn't too important that we punish our counterparty in such a corner-case, we opt to just close the channel in such a case and move on.
1 parent a252f81 commit 9206ae7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lightning/src/ln/channel.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,17 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
19931993
self.channel_monitor.provide_secret(self.cur_remote_commitment_transaction_number + 1, msg.per_commitment_secret)
19941994
.map_err(|e| ChannelError::Close(e.0))?;
19951995

1996+
if self.channel_state & ChannelState::AwaitingRemoteRevoke as u32 == 0 {
1997+
// Our counterparty seems to have burned their coins to us (by revoking a state when we
1998+
// haven't given them a new commitment transaction to broadcast). We should probably
1999+
// take advantage of this by updating our channel monitor, sending them an error, and
2000+
// waiting for them to broadcast their latest (now-revoked claim). But, that would be a
2001+
// lot of work, and there's some chance this is all a misunderstanding anyway.
2002+
// We have to do *something*, though, since our signer may get mad at us for otherwise
2003+
// jumping a remote commitment number, so best to just force-close and move on.
2004+
return Err(ChannelError::Close("Got a revoke when we weren't expecting one"));
2005+
}
2006+
19962007
// Update state now that we've passed all the can-fail calls...
19972008
// (note that we may still fail to generate the new commitment_signed message, but that's
19982009
// OK, we step the channel here and *then* if the new generation fails we can fail the

0 commit comments

Comments
 (0)