Skip to content

Commit 326f3d7

Browse files
committed
lnwire: simplify dyn decode methods
Remove the unnecessary convertions as suggested by Gemini.
1 parent a4467a6 commit 326f3d7

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

docs/release-notes/release-notes-0.20.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
announcement remains unchanged until the new one is fully signed and
2727
validated.
2828

29+
- [Fixed](https://github.com/lightningnetwork/lnd/pull/10027) data being encoded
30+
into the `ExtraData` field found in the dynamic commitment message set.
31+
2932
# New Features
3033

3134
## Functional Enhancements

lnwire/dyn_commit.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,16 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
107107
// Check the results of the TLV Stream decoding and appropriately set
108108
// message fields.
109109
if _, ok := knownRecords[dc.DustLimit.TlvType()]; ok {
110-
var rec tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
111-
rec.Val = dustLimit.Val
112-
dc.DustLimit = tlv.SomeRecordT(rec)
110+
dc.DustLimit = tlv.SomeRecordT(dustLimit)
113111
}
114112
if _, ok := knownRecords[dc.MaxValueInFlight.TlvType()]; ok {
115-
var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
116-
rec.Val = maxValue.Val
117-
dc.MaxValueInFlight = tlv.SomeRecordT(rec)
113+
dc.MaxValueInFlight = tlv.SomeRecordT(maxValue)
118114
}
119115
if _, ok := knownRecords[dc.HtlcMinimum.TlvType()]; ok {
120-
var rec tlv.RecordT[tlv.TlvType4, MilliSatoshi]
121-
rec.Val = htlcMin.Val
122-
dc.HtlcMinimum = tlv.SomeRecordT(rec)
116+
dc.HtlcMinimum = tlv.SomeRecordT(htlcMin)
123117
}
124118
if _, ok := knownRecords[dc.ChannelReserve.TlvType()]; ok {
125-
var rec tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
126-
rec.Val = reserve.Val
127-
dc.ChannelReserve = tlv.SomeRecordT(rec)
119+
dc.ChannelReserve = tlv.SomeRecordT(reserve)
128120
}
129121
if _, ok := knownRecords[dc.CsvDelay.TlvType()]; ok {
130122
dc.CsvDelay = tlv.SomeRecordT(csvDelay)

lnwire/dyn_propose.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,19 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
129129
// Check the results of the TLV Stream decoding and appropriately set
130130
// message fields.
131131
if _, ok := knownRecords[dp.DustLimit.TlvType()]; ok {
132-
var rec tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
133-
rec.Val = dustLimit.Val
134-
dp.DustLimit = tlv.SomeRecordT(rec)
132+
dp.DustLimit = tlv.SomeRecordT(dustLimit)
135133
}
136134

137135
if _, ok := knownRecords[dp.MaxValueInFlight.TlvType()]; ok {
138-
var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
139-
rec.Val = maxValue.Val
140-
dp.MaxValueInFlight = tlv.SomeRecordT(rec)
136+
dp.MaxValueInFlight = tlv.SomeRecordT(maxValue)
141137
}
142138

143139
if _, ok := knownRecords[dp.HtlcMinimum.TlvType()]; ok {
144-
var rec tlv.RecordT[tlv.TlvType4, MilliSatoshi]
145-
rec.Val = htlcMin.Val
146-
dp.HtlcMinimum = tlv.SomeRecordT(rec)
140+
dp.HtlcMinimum = tlv.SomeRecordT(htlcMin)
147141
}
148142

149143
if _, ok := knownRecords[dp.ChannelReserve.TlvType()]; ok {
150-
var rec tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
151-
rec.Val = reserve.Val
152-
dp.ChannelReserve = tlv.SomeRecordT(rec)
144+
dp.ChannelReserve = tlv.SomeRecordT(reserve)
153145
}
154146

155147
if _, ok := knownRecords[dp.CsvDelay.TlvType()]; ok {

0 commit comments

Comments
 (0)