From 62da377f78a65477593aa5ae942a387ae0993e33 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 11 Dec 2017 15:32:24 -0800 Subject: [PATCH] lnwallet: properly reject new commitment if next revocation point isn't known --- lnwallet/channel.go | 5 ++--- lnwallet/channel_test.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index fd209a8b..44974507 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -2935,8 +2935,8 @@ func (lc *LightningChannel) SignNextCommitment() (*btcec.Signature, []*btcec.Sig // don't yet have the initial next revocation point of the remote // party, then we're unable to create new states. Each time we create a // new state, we consume a prior revocation point. - if lc.remoteCommitChain.hasUnackedCommitment() || - lc.channelState.RemoteCurrentRevocation == nil { + commitPoint := lc.channelState.RemoteNextRevocation + if lc.remoteCommitChain.hasUnackedCommitment() || commitPoint == nil { return nil, nil, ErrNoWindow } @@ -2958,7 +2958,6 @@ func (lc *LightningChannel) SignNextCommitment() (*btcec.Signature, []*btcec.Sig // Grab the next commitment point for the remote party. This will be // used within fetchCommitmentView to derive all the keys necessary to // construct the commitment state. - commitPoint := lc.channelState.RemoteNextRevocation keyRing := deriveCommitmentKeys(commitPoint, false, lc.localChanCfg, lc.remoteChanCfg) diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index db1948ff..5b2a1421 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -3859,7 +3859,7 @@ func TestSignCommitmentFailNotLockedIn(t *testing.T) { // Next, we'll modify Alice's internal state to omit knowledge of Bob's // next revocation point. - aliceChannel.channelState.RemoteCurrentRevocation = nil + aliceChannel.channelState.RemoteNextRevocation = nil // If we now try to initiate a state update, then it should fail as // Alice is unable to actually create a new state.