lnwallet: allow DLP trigger transition in ProcessChanSyncMsg if chan restored
In this commit, we modify an existing case in `ProcessChanSyncMsg` to enter the DLP workflow if we detect that this is a restored channel.
This commit is contained in:
parent
d9c9d6ed73
commit
90d8a46ec6
@ -856,12 +856,16 @@ func (lc *LightningChannel) diskCommitToMemCommit(isLocal bool,
|
|||||||
// haven't yet received a responding commitment from the remote party.
|
// haven't yet received a responding commitment from the remote party.
|
||||||
var localCommitKeys, remoteCommitKeys *CommitmentKeyRing
|
var localCommitKeys, remoteCommitKeys *CommitmentKeyRing
|
||||||
if localCommitPoint != nil {
|
if localCommitPoint != nil {
|
||||||
localCommitKeys = deriveCommitmentKeys(localCommitPoint, true,
|
localCommitKeys = deriveCommitmentKeys(
|
||||||
lc.localChanCfg, lc.remoteChanCfg)
|
localCommitPoint, true, lc.localChanCfg,
|
||||||
|
lc.remoteChanCfg,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if remoteCommitPoint != nil {
|
if remoteCommitPoint != nil {
|
||||||
remoteCommitKeys = deriveCommitmentKeys(remoteCommitPoint, false,
|
remoteCommitKeys = deriveCommitmentKeys(
|
||||||
lc.localChanCfg, lc.remoteChanCfg)
|
remoteCommitPoint, false, lc.localChanCfg,
|
||||||
|
lc.remoteChanCfg,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// With the key rings re-created, we'll now convert all the on-disk
|
// With the key rings re-created, we'll now convert all the on-disk
|
||||||
@ -1408,8 +1412,7 @@ func NewLightningChannel(signer input.Signer, pCache PreimageCache,
|
|||||||
// Create the sign descriptor which we'll be using very frequently to
|
// Create the sign descriptor which we'll be using very frequently to
|
||||||
// request a signature for the 2-of-2 multi-sig from the signer in
|
// request a signature for the 2-of-2 multi-sig from the signer in
|
||||||
// order to complete channel state transitions.
|
// order to complete channel state transitions.
|
||||||
err = lc.createSignDesc()
|
if err := lc.createSignDesc(); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1701,7 +1704,8 @@ func (lc *LightningChannel) restoreCommitState(
|
|||||||
// Finally, with the commitment states restored, we'll now restore the
|
// Finally, with the commitment states restored, we'll now restore the
|
||||||
// state logs based on the current local+remote commit, and any pending
|
// state logs based on the current local+remote commit, and any pending
|
||||||
// remote commit that exists.
|
// remote commit that exists.
|
||||||
err = lc.restoreStateLogs(localCommit, remoteCommit, pendingRemoteCommit,
|
err = lc.restoreStateLogs(
|
||||||
|
localCommit, remoteCommit, pendingRemoteCommit,
|
||||||
pendingRemoteCommitDiff, pendingRemoteKeyChain,
|
pendingRemoteCommitDiff, pendingRemoteKeyChain,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -3248,6 +3252,13 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we detect that this is is a restored channel, then we can skip a
|
||||||
|
// portion of the verification, as we already know that we're unable to
|
||||||
|
// proceed with any updates.
|
||||||
|
isRestoredChan := lc.channelState.HasChanStatus(
|
||||||
|
channeldb.ChanStatusRestored,
|
||||||
|
)
|
||||||
|
|
||||||
// Take note of our current commit chain heights before we begin adding
|
// Take note of our current commit chain heights before we begin adding
|
||||||
// more to them.
|
// more to them.
|
||||||
var (
|
var (
|
||||||
@ -3265,12 +3276,17 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
|
|||||||
|
|
||||||
// If their reported height for our local chain tail is ahead of our
|
// If their reported height for our local chain tail is ahead of our
|
||||||
// view, then we're behind!
|
// view, then we're behind!
|
||||||
case msg.RemoteCommitTailHeight > localTailHeight:
|
case msg.RemoteCommitTailHeight > localTailHeight || isRestoredChan:
|
||||||
walletLog.Errorf("ChannelPoint(%v), sync failed with local "+
|
walletLog.Errorf("ChannelPoint(%v), sync failed with local "+
|
||||||
"data loss: remote believes our tail height is %v, "+
|
"data loss: remote believes our tail height is %v, "+
|
||||||
"while we have %v!", lc.channelState.FundingOutpoint,
|
"while we have %v!", lc.channelState.FundingOutpoint,
|
||||||
msg.RemoteCommitTailHeight, localTailHeight)
|
msg.RemoteCommitTailHeight, localTailHeight)
|
||||||
|
|
||||||
|
if isRestoredChan {
|
||||||
|
walletLog.Warnf("ChannelPoint(%v): detected restored " +
|
||||||
|
"triggering DLP")
|
||||||
|
}
|
||||||
|
|
||||||
// We must check that we had recovery options to ensure the
|
// We must check that we had recovery options to ensure the
|
||||||
// commitment secret matched up, and the remote is just not
|
// commitment secret matched up, and the remote is just not
|
||||||
// lying about its height.
|
// lying about its height.
|
||||||
|
Loading…
Reference in New Issue
Block a user