Skip to content

Commit f40530e

Browse files
ProofOfKeagsyyforyongyu
authored andcommitted
lnwire: remove FundingKey from DynPropose and DynCommit
1 parent cbca5b1 commit f40530e

File tree

3 files changed

+2
-59
lines changed

3 files changed

+2
-59
lines changed

lnwire/dyn_commit.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"io"
66

7-
"github.com/btcsuite/btcd/btcec/v2"
87
"github.com/btcsuite/btcd/btcutil"
98
"github.com/lightningnetwork/lnd/fn/v2"
109
"github.com/lightningnetwork/lnd/tlv"
@@ -83,14 +82,6 @@ func (dc *DynCommit) Encode(w *bytes.Buffer, _ uint32) error {
8382
),
8483
)
8584
})
86-
dc.FundingKey.WhenSome(func(key btcec.PublicKey) {
87-
keyScratch := &key
88-
tlvRecords = append(
89-
tlvRecords, tlv.MakePrimitiveRecord(
90-
DPFundingPubkey, &keyScratch,
91-
),
92-
)
93-
})
9485
dc.ChannelType.WhenSome(func(ty ChannelType) {
9586
tlvRecords = append(
9687
tlvRecords, tlv.MakeDynamicRecord(
@@ -159,11 +150,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
159150
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
160151
)
161152

162-
var fundingKeyScratch *btcec.PublicKey
163-
fundingKey := tlv.MakePrimitiveRecord(
164-
DPFundingPubkey, &fundingKeyScratch,
165-
)
166-
167153
var chanTypeScratch ChannelType
168154
chanType := tlv.MakeDynamicRecord(
169155
DPChannelType, &chanTypeScratch, chanTypeScratch.featureBitLen,
@@ -172,8 +158,7 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
172158

173159
// Create set of Records to read TLV bytestream into.
174160
records := []tlv.Record{
175-
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
176-
chanType,
161+
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, chanType,
177162
}
178163
tlv.SortRecords(records)
179164

@@ -205,9 +190,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
205190
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
206191
dc.MaxAcceptedHTLCs = fn.Some(maxHtlcsScratch)
207192
}
208-
if val, ok := typeMap[DPFundingPubkey]; ok && val == nil {
209-
dc.FundingKey = fn.Some(*fundingKeyScratch)
210-
}
211193
if val, ok := typeMap[DPChannelType]; ok && val == nil {
212194
dc.ChannelType = fn.Some(chanTypeScratch)
213195
}

lnwire/dyn_propose.go

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"io"
66

7-
"github.com/btcsuite/btcd/btcec/v2"
87
"github.com/btcsuite/btcd/btcutil"
98
"github.com/lightningnetwork/lnd/fn/v2"
109
"github.com/lightningnetwork/lnd/tlv"
@@ -31,10 +30,6 @@ const (
3130
// for DynPropose.MaxAcceptedHTLCs.
3231
DPMaxAcceptedHtlcs tlv.Type = 4
3332

34-
// DPFundingPubkey is the TLV type number that identifies the record for
35-
// DynPropose.FundingKey.
36-
DPFundingPubkey tlv.Type = 5
37-
3833
// DPChannelType is the TLV type number that identifies the record for
3934
// DynPropose.ChannelType.
4035
DPChannelType tlv.Type = 6
@@ -67,10 +62,6 @@ type DynPropose struct {
6762
// max_accepted_htlcs limit of the sender.
6863
MaxAcceptedHTLCs fn.Option[uint16]
6964

70-
// FundingKey, if not nil, proposes a change to the funding_pubkey
71-
// parameter of the sender.
72-
FundingKey fn.Option[btcec.PublicKey]
73-
7465
// ChannelType, if not nil, proposes a change to the channel_type
7566
// parameter.
7667
ChannelType fn.Option[ChannelType]
@@ -137,14 +128,6 @@ func (dp *DynPropose) Encode(w *bytes.Buffer, _ uint32) error {
137128
),
138129
)
139130
})
140-
dp.FundingKey.WhenSome(func(key btcec.PublicKey) {
141-
keyScratch := &key
142-
tlvRecords = append(
143-
tlvRecords, tlv.MakePrimitiveRecord(
144-
DPFundingPubkey, &keyScratch,
145-
),
146-
)
147-
})
148131
dp.ChannelType.WhenSome(func(ty ChannelType) {
149132
tlvRecords = append(
150133
tlvRecords, tlv.MakeDynamicRecord(
@@ -215,11 +198,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
215198
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
216199
)
217200

218-
var fundingKeyScratch *btcec.PublicKey
219-
fundingKey := tlv.MakePrimitiveRecord(
220-
DPFundingPubkey, &fundingKeyScratch,
221-
)
222-
223201
var chanTypeScratch ChannelType
224202
chanType := tlv.MakeDynamicRecord(
225203
DPChannelType, &chanTypeScratch, chanTypeScratch.featureBitLen,
@@ -228,8 +206,7 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
228206

229207
// Create set of Records to read TLV bytestream into.
230208
records := []tlv.Record{
231-
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
232-
chanType,
209+
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, chanType,
233210
}
234211
tlv.SortRecords(records)
235212

@@ -262,9 +239,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
262239
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
263240
dp.MaxAcceptedHTLCs = fn.Some(maxHtlcsScratch)
264241
}
265-
if val, ok := typeMap[DPFundingPubkey]; ok && val == nil {
266-
dp.FundingKey = fn.Some(*fundingKeyScratch)
267-
}
268242
if val, ok := typeMap[DPChannelType]; ok && val == nil {
269243
dp.ChannelType = fn.Some(chanTypeScratch)
270244
}
@@ -334,14 +308,6 @@ func (dp *DynPropose) SerializeTlvData() ([]byte, error) {
334308
),
335309
)
336310
})
337-
dp.FundingKey.WhenSome(func(key btcec.PublicKey) {
338-
keyScratch := &key
339-
tlvRecords = append(
340-
tlvRecords, tlv.MakePrimitiveRecord(
341-
DPFundingPubkey, &keyScratch,
342-
),
343-
)
344-
})
345311
dp.ChannelType.WhenSome(func(ty ChannelType) {
346312
tlvRecords = append(
347313
tlvRecords, tlv.MakeDynamicRecord(

lnwire/test_message.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
829829
includeMaxAcceptedHTLCs := rapid.Bool().Draw(
830830
t, "includeMaxAcceptedHTLCs",
831831
)
832-
includeFundingKey := rapid.Bool().Draw(t, "includeFundingKey")
833832
includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
834833

835834
// Generate random values for each included field
@@ -858,10 +857,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
858857
msg.MaxAcceptedHTLCs = fn.Some(mah)
859858
}
860859

861-
if includeFundingKey {
862-
msg.FundingKey = fn.Some(*RandPubKey(t))
863-
}
864-
865860
if includeChannelType {
866861
msg.ChannelType = fn.Some(*RandChannelType(t))
867862
}

0 commit comments

Comments
 (0)