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 {
|
||||
return err
|
||||
}
|
||||
producers := dynProposeRecords(&dc.DynPropose)
|
||||
dc.LocalNonce.WhenSome(
|
||||
func(rec tlv.RecordT[tlv.TlvType14, Musig2Nonce]) {
|
||||
producers = append(producers, &rec)
|
||||
})
|
||||
|
||||
var extra ExtraOpaqueData
|
||||
err := extra.PackRecords(dynProposeRecords(&dc.DynPropose)...)
|
||||
err := extra.PackRecords(producers...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -82,10 +87,11 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
||||
csvDelay := dc.CsvDelay.Zero()
|
||||
maxHtlcs := dc.MaxAcceptedHTLCs.Zero()
|
||||
chanType := dc.ChannelType.Zero()
|
||||
nonce := dc.LocalNonce.Zero()
|
||||
|
||||
typeMap, err := tlvRecords.ExtractRecords(
|
||||
&dustLimit, &maxValue, &htlcMin, &reserve, &csvDelay, &maxHtlcs,
|
||||
&chanType,
|
||||
&chanType, &nonce,
|
||||
)
|
||||
if err != nil {
|
||||
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 {
|
||||
dc.ChannelType = tlv.SomeRecordT(chanType)
|
||||
}
|
||||
if val, ok := typeMap[dc.LocalNonce.TlvType()]; ok && val == nil {
|
||||
dc.LocalNonce = tlv.SomeRecordT(nonce)
|
||||
}
|
||||
|
||||
if len(tlvRecords) != 0 {
|
||||
dc.ExtraData = tlvRecords
|
||||
|
||||
+12
-2
@@ -1004,11 +1004,21 @@ func (dc *DynCommit) RandTestMessage(t *rapid.T) Message {
|
||||
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
|
||||
// ignored when creating ExtraData records.
|
||||
ignoreRecords := fn.NewSet[uint64]()
|
||||
for i := range uint64(13) {
|
||||
ignoreRecords.Add(i)
|
||||
for i := range uint64(15) {
|
||||
// Ignore known records.
|
||||
if i%2 == 0 {
|
||||
ignoreRecords.Add(i)
|
||||
}
|
||||
}
|
||||
msg := &DynCommit{
|
||||
DynPropose: *dp,
|
||||
|
||||
Reference in new issue
Block a user