mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-11 14:48:14 +01:00
lnwallet/channel: make ErrCommitSyncLocalDataLoss type
This commit converts the ErrCommitSyncLocalDataLoss error into a struct, that also holds the received last unrevoked commit point from the remote party.
This commit is contained in:
@@ -81,16 +81,6 @@ var (
|
||||
ErrInvalidLocalUnrevokedCommitPoint = fmt.Errorf("unrevoked commit " +
|
||||
"point is invalid")
|
||||
|
||||
// ErrCommitSyncLocalDataLoss is returned in the case that we receive a
|
||||
// valid commit secret within the ChannelReestablish message from the
|
||||
// remote node AND they advertise a RemoteCommitTailHeight higher than
|
||||
// our current known height. This means we have lost some critical
|
||||
// data, and must fail the channel and MUST NOT force close it. Instead
|
||||
// we should wait for the remote to force close it, such that we can
|
||||
// attempt to sweep our funds.
|
||||
ErrCommitSyncLocalDataLoss = fmt.Errorf("possible local commitment " +
|
||||
"state data loss")
|
||||
|
||||
// ErrCommitSyncRemoteDataLoss is returned in the case that we receive
|
||||
// a ChannelReestablish message from the remote that advertises a
|
||||
// NextLocalCommitHeight that is lower than what they have already
|
||||
@@ -101,6 +91,30 @@ var (
|
||||
"state data loss")
|
||||
)
|
||||
|
||||
// ErrCommitSyncLocalDataLoss is returned in the case that we receive a valid
|
||||
// commit secret within the ChannelReestablish message from the remote node AND
|
||||
// they advertise a RemoteCommitTailHeight higher than our current known
|
||||
// height. This means we have lost some critical data, and must fail the
|
||||
// channel and MUST NOT force close it. Instead we should wait for the remote
|
||||
// to force close it, such that we can attempt to sweep our funds. The
|
||||
// commitment point needed to sweep the remote's force close is encapsuled.
|
||||
type ErrCommitSyncLocalDataLoss struct {
|
||||
// ChannelPoint is the identifier for the channel that experienced data
|
||||
// loss.
|
||||
ChannelPoint wire.OutPoint
|
||||
|
||||
// CommitPoint is the last unrevoked commit point, sent to us by the
|
||||
// remote when we determined we had lost state.
|
||||
CommitPoint *btcec.PublicKey
|
||||
}
|
||||
|
||||
// Error returns a string representation of the local data loss error.
|
||||
func (e *ErrCommitSyncLocalDataLoss) Error() string {
|
||||
return fmt.Sprintf("ChannelPoint(%v) with CommitPoint(%x) had "+
|
||||
"possible local commitment state data loss", e.ChannelPoint,
|
||||
e.CommitPoint.SerializeCompressed())
|
||||
}
|
||||
|
||||
// channelState is an enum like type which represents the current state of a
|
||||
// particular channel.
|
||||
// TODO(roasbeef): actually update state
|
||||
@@ -3313,7 +3327,11 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
return nil, nil, nil, ErrCommitSyncLocalDataLoss
|
||||
|
||||
return nil, nil, nil, &ErrCommitSyncLocalDataLoss{
|
||||
ChannelPoint: lc.channelState.FundingOutpoint,
|
||||
CommitPoint: msg.LocalUnrevokedCommitPoint,
|
||||
}
|
||||
|
||||
// If the height of our commitment chain reported by the remote party
|
||||
// is behind our view of the chain, then they probably lost some state,
|
||||
|
||||
Reference in New Issue
Block a user