lnwire: add missing record LocalNonce
This record was never added to the `DynCommit`, but it's inherited from the embedding msg `DynAck`.
This commit is contained in:
2 files changed
+23
-4
No files matched your search
+11
-2
@@ -45,9 +45,14 @@ func (dc *DynCommit) Encode(w *bytes.Buffer, _ uint32) error {
|
|||||||
if err := WriteSig(w, dc.Sig); err != nil {
|
if err := WriteSig(w, dc.Sig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
producers := dynProposeRecords(&dc.DynPropose)
|
||||||
|
dc.LocalNonce.WhenSome(
|
||||||
|
func(rec tlv.RecordT[tlv.TlvType14, Musig2Nonce]) {
|
||||||
|
producers = append(producers, &rec)
|
||||||
|
})
|
||||||
|
|
||||||
var extra ExtraOpaqueData
|
var extra ExtraOpaqueData
|
||||||
err := extra.PackRecords(dynProposeRecords(&dc.DynPropose)...)
|
err := extra.PackRecords(producers...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -82,10 +87,11 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
|||||||
csvDelay := dc.CsvDelay.Zero()
|
csvDelay := dc.CsvDelay.Zero()
|
||||||
maxHtlcs := dc.MaxAcceptedHTLCs.Zero()
|
maxHtlcs := dc.MaxAcceptedHTLCs.Zero()
|
||||||
chanType := dc.ChannelType.Zero()
|
chanType := dc.ChannelType.Zero()
|
||||||
|
nonce := dc.LocalNonce.Zero()
|
||||||
|
|
||||||
typeMap, err := tlvRecords.ExtractRecords(
|
typeMap, err := tlvRecords.ExtractRecords(
|
||||||
&dustLimit, &maxValue, &htlcMin, &reserve, &csvDelay, &maxHtlcs,
|
&dustLimit, &maxValue, &htlcMin, &reserve, &csvDelay, &maxHtlcs,
|
||||||
&chanType,
|
&chanType, &nonce,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -122,6 +128,9 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
|||||||
if val, ok := typeMap[dc.ChannelType.TlvType()]; ok && val == nil {
|
if val, ok := typeMap[dc.ChannelType.TlvType()]; ok && val == nil {
|
||||||
dc.ChannelType = tlv.SomeRecordT(chanType)
|
dc.ChannelType = tlv.SomeRecordT(chanType)
|
||||||
}
|
}
|
||||||
|
if val, ok := typeMap[dc.LocalNonce.TlvType()]; ok && val == nil {
|
||||||
|
dc.LocalNonce = tlv.SomeRecordT(nonce)
|
||||||
|
}
|
||||||
|
|
||||||
if len(tlvRecords) != 0 {
|
if len(tlvRecords) != 0 {
|
||||||
dc.ExtraData = tlvRecords
|
dc.ExtraData = tlvRecords
|
||||||
|
|||||||
+12
-2
@@ -1004,11 +1004,21 @@ func (dc *DynCommit) RandTestMessage(t *rapid.T) Message {
|
|||||||
dp.ChannelType = tlv.SomeRecordT(chanType)
|
dp.ChannelType = tlv.SomeRecordT(chanType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
includeLocalNonce := rapid.Bool().Draw(t, "includeLocalNonce")
|
||||||
|
if includeLocalNonce {
|
||||||
|
nonce := RandMusig2Nonce(t)
|
||||||
|
rec := tlv.NewRecordT[tlv.TlvType14](nonce)
|
||||||
|
da.LocalNonce = tlv.SomeRecordT(rec)
|
||||||
|
}
|
||||||
|
|
||||||
// Create a tlv type lists to hold all known records which will be
|
// Create a tlv type lists to hold all known records which will be
|
||||||
// ignored when creating ExtraData records.
|
// ignored when creating ExtraData records.
|
||||||
ignoreRecords := fn.NewSet[uint64]()
|
ignoreRecords := fn.NewSet[uint64]()
|
||||||
for i := range uint64(13) {
|
for i := range uint64(15) {
|
||||||
ignoreRecords.Add(i)
|
// Ignore known records.
|
||||||
|
if i%2 == 0 {
|
||||||
|
ignoreRecords.Add(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg := &DynCommit{
|
msg := &DynCommit{
|
||||||
DynPropose: *dp,
|
DynPropose: *dp,
|
||||||
|
|||||||
Reference in new issue
Block a user