Skip to content

Commit cbca5b1

Browse files
ProofOfKeagsyyforyongyu
authored andcommitted
lnwire: remove kickoff feerate from propose/commit
1 parent 36f53d7 commit cbca5b1

File tree

3 files changed

+2
-66
lines changed

3 files changed

+2
-66
lines changed

lnwire/dyn_commit.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/btcsuite/btcd/btcec/v2"
88
"github.com/btcsuite/btcd/btcutil"
99
"github.com/lightningnetwork/lnd/fn/v2"
10-
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1110
"github.com/lightningnetwork/lnd/tlv"
1211
)
1312

@@ -101,14 +100,6 @@ func (dc *DynCommit) Encode(w *bytes.Buffer, _ uint32) error {
101100
),
102101
)
103102
})
104-
dc.KickoffFeerate.WhenSome(func(kickoffFeerate chainfee.SatPerKWeight) {
105-
protoSats := uint32(kickoffFeerate)
106-
tlvRecords = append(
107-
tlvRecords, tlv.MakePrimitiveRecord(
108-
DPKickoffFeerate, &protoSats,
109-
),
110-
)
111-
})
112103
tlv.SortRecords(tlvRecords)
113104

114105
tlvStream, err := tlv.NewStream(tlvRecords...)
@@ -179,15 +170,10 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
179170
channelTypeEncoder, channelTypeDecoder,
180171
)
181172

182-
var kickoffFeerateScratch uint32
183-
kickoffFeerate := tlv.MakePrimitiveRecord(
184-
DPKickoffFeerate, &kickoffFeerateScratch,
185-
)
186-
187173
// Create set of Records to read TLV bytestream into.
188174
records := []tlv.Record{
189175
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
190-
chanType, kickoffFeerate,
176+
chanType,
191177
}
192178
tlv.SortRecords(records)
193179

@@ -225,11 +211,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
225211
if val, ok := typeMap[DPChannelType]; ok && val == nil {
226212
dc.ChannelType = fn.Some(chanTypeScratch)
227213
}
228-
if val, ok := typeMap[DPKickoffFeerate]; ok && val == nil {
229-
dc.KickoffFeerate = fn.Some(
230-
chainfee.SatPerKWeight(kickoffFeerateScratch),
231-
)
232-
}
233214

234215
if len(tlvRecords) != 0 {
235216
dc.ExtraData = tlvRecords

lnwire/dyn_propose.go

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/btcsuite/btcd/btcec/v2"
88
"github.com/btcsuite/btcd/btcutil"
99
"github.com/lightningnetwork/lnd/fn/v2"
10-
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1110
"github.com/lightningnetwork/lnd/tlv"
1211
)
1312

@@ -39,10 +38,6 @@ const (
3938
// DPChannelType is the TLV type number that identifies the record for
4039
// DynPropose.ChannelType.
4140
DPChannelType tlv.Type = 6
42-
43-
// DPKickoffFeerate is the TLV type number that identifies the record
44-
// for DynPropose.KickoffFeerate.
45-
DPKickoffFeerate tlv.Type = 7
4641
)
4742

4843
// DynPropose is a message that is sent during a dynamic commitments negotiation
@@ -80,11 +75,6 @@ type DynPropose struct {
8075
// parameter.
8176
ChannelType fn.Option[ChannelType]
8277

83-
// KickoffFeerate proposes the fee rate in satoshis per kw that it
84-
// is offering for a ChannelType conversion that requires a kickoff
85-
// transaction.
86-
KickoffFeerate fn.Option[chainfee.SatPerKWeight]
87-
8878
// ExtraData is the set of data that was appended to this message to
8979
// fill out the full maximum transport message size. These fields can
9080
// be used to specify optional data such as custom TLV fields.
@@ -164,14 +154,6 @@ func (dp *DynPropose) Encode(w *bytes.Buffer, _ uint32) error {
164154
),
165155
)
166156
})
167-
dp.KickoffFeerate.WhenSome(func(kickoffFeerate chainfee.SatPerKWeight) {
168-
protoSats := uint32(kickoffFeerate)
169-
tlvRecords = append(
170-
tlvRecords, tlv.MakePrimitiveRecord(
171-
DPKickoffFeerate, &protoSats,
172-
),
173-
)
174-
})
175157
tlv.SortRecords(tlvRecords)
176158

177159
tlvStream, err := tlv.NewStream(tlvRecords...)
@@ -244,15 +226,10 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
244226
channelTypeEncoder, channelTypeDecoder,
245227
)
246228

247-
var kickoffFeerateScratch uint32
248-
kickoffFeerate := tlv.MakePrimitiveRecord(
249-
DPKickoffFeerate, &kickoffFeerateScratch,
250-
)
251-
252229
// Create set of Records to read TLV bytestream into.
253230
records := []tlv.Record{
254231
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
255-
chanType, kickoffFeerate,
232+
chanType,
256233
}
257234
tlv.SortRecords(records)
258235

@@ -291,11 +268,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
291268
if val, ok := typeMap[DPChannelType]; ok && val == nil {
292269
dp.ChannelType = fn.Some(chanTypeScratch)
293270
}
294-
if val, ok := typeMap[DPKickoffFeerate]; ok && val == nil {
295-
dp.KickoffFeerate = fn.Some(
296-
chainfee.SatPerKWeight(kickoffFeerateScratch),
297-
)
298-
}
299271

300272
if len(tlvRecords) != 0 {
301273
dp.ExtraData = tlvRecords
@@ -379,14 +351,6 @@ func (dp *DynPropose) SerializeTlvData() ([]byte, error) {
379351
),
380352
)
381353
})
382-
dp.KickoffFeerate.WhenSome(func(kickoffFeerate chainfee.SatPerKWeight) {
383-
protoSats := uint32(kickoffFeerate)
384-
tlvRecords = append(
385-
tlvRecords, tlv.MakePrimitiveRecord(
386-
DPKickoffFeerate, &protoSats,
387-
),
388-
)
389-
})
390354
tlv.SortRecords(tlvRecords)
391355

392356
tlvStream, err := tlv.NewStream(tlvRecords...)

lnwire/test_message.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/btcsuite/btcd/btcutil"
1111
"github.com/btcsuite/btcd/chaincfg/chainhash"
1212
"github.com/lightningnetwork/lnd/fn/v2"
13-
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1413
"github.com/lightningnetwork/lnd/tlv"
1514
"github.com/stretchr/testify/require"
1615
"pgregory.net/rapid"
@@ -832,7 +831,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
832831
)
833832
includeFundingKey := rapid.Bool().Draw(t, "includeFundingKey")
834833
includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
835-
includeKickoffFeerate := rapid.Bool().Draw(t, "includeKickoffFeerate")
836834

837835
// Generate random values for each included field
838836
if includeDustLimit {
@@ -868,13 +866,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
868866
msg.ChannelType = fn.Some(*RandChannelType(t))
869867
}
870868

871-
if includeKickoffFeerate {
872-
kf := chainfee.SatPerKWeight(rapid.Uint32().Draw(
873-
t, "kickoffFeerate"),
874-
)
875-
msg.KickoffFeerate = fn.Some(kf)
876-
}
877-
878869
return msg
879870
}
880871

0 commit comments

Comments
 (0)