mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
lnwire: add observance of optional data loss fields to ChannelReestablish
In this commit, we add support within lnwire for the optional dataloss fields in ChannelReestablish. With these fields, it’s possible to: verify that the remote node really knows of the state of our prior local commitment, and also that they’ve sent us the current commitment point for their current state. In the event of dataloss, it’s possible for the party which lost data to claim their commitment output in the remote party’s commitment if they broadcast their current commitment transaction.
This commit is contained in:
@@ -451,6 +451,31 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
v[0] = reflect.ValueOf(req)
|
||||
},
|
||||
MsgChannelReestablish: func(v []reflect.Value, r *rand.Rand) {
|
||||
req := ChannelReestablish{
|
||||
NextLocalCommitHeight: uint64(r.Int63()),
|
||||
RemoteCommitTailHeight: uint64(r.Int63()),
|
||||
}
|
||||
|
||||
// With a 50/50 probability, we'll include the
|
||||
// additional fields so we can test our ability to
|
||||
// properly parse, and write out the optional fields.
|
||||
if r.Int()%2 == 0 {
|
||||
_, err := r.Read(req.LastRemoteCommitSecret[:])
|
||||
if err != nil {
|
||||
t.Fatalf("unable to read commit secret: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
req.LocalUnrevokedCommitPoint, err = randPubKey()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
v[0] = reflect.ValueOf(req)
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user