Skip to content

Commit

Permalink
lnwire: remove kickoff feerate from propose/commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ProofOfKeags committed Oct 8, 2024
1 parent bb3b1a7 commit bd77255
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 77 deletions.
27 changes: 1 addition & 26 deletions lnwire/dyn_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv"
)

Expand Down Expand Up @@ -51,11 +50,6 @@ type DynCommit struct {
// parameter.
ChannelType fn.Option[ChannelType]

// KickoffFeerate proposes the fee rate in satoshis per kw that it
// is offering for a ChannelType conversion that requires a kickoff
// transaction.
KickoffFeerate fn.Option[chainfee.SatPerKWeight]

// ExtraData is the set of data that was appended to this message to
// fill out the full maximum transport message size. These fields can
// be used to specify optional data such as custom TLV fields.
Expand Down Expand Up @@ -135,14 +129,6 @@ func (dc *DynCommit) Encode(w *bytes.Buffer, _ uint32) error {
),
)
})
dc.KickoffFeerate.WhenSome(func(kickoffFeerate chainfee.SatPerKWeight) {
protoSats := uint32(kickoffFeerate)
tlvRecords = append(
tlvRecords, tlv.MakePrimitiveRecord(
DPKickoffFeerate, &protoSats,
),
)
})
tlv.SortRecords(tlvRecords)

tlvStream, err := tlv.NewStream(tlvRecords...)
Expand Down Expand Up @@ -212,15 +198,10 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
channelTypeEncoder, channelTypeDecoder,
)

var kickoffFeerateScratch uint32
kickoffFeerate := tlv.MakePrimitiveRecord(
DPKickoffFeerate, &kickoffFeerateScratch,
)

// Create set of Records to read TLV bytestream into.
records := []tlv.Record{
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
chanType, kickoffFeerate,
chanType,
}
tlv.SortRecords(records)

Expand Down Expand Up @@ -258,11 +239,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
if val, ok := typeMap[DPChannelType]; ok && val == nil {
dc.ChannelType = fn.Some(chanTypeScratch)
}
if val, ok := typeMap[DPKickoffFeerate]; ok && val == nil {
dc.KickoffFeerate = fn.Some(
chainfee.SatPerKWeight(kickoffFeerateScratch),
)
}

if len(tlvRecords) != 0 {
dc.ExtraData = tlvRecords
Expand Down Expand Up @@ -292,6 +268,5 @@ func NegotiateDynCommit(propose DynPropose, ack DynAck) DynCommit {
MaxAcceptedHTLCs: propose.MaxAcceptedHTLCs,
FundingKey: propose.FundingKey,
ChannelType: propose.ChannelType,
KickoffFeerate: propose.KickoffFeerate,
}
}
38 changes: 1 addition & 37 deletions lnwire/dyn_propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv"
)

Expand Down Expand Up @@ -40,10 +39,6 @@ const (
// DPChannelType is the TLV type number that identifies the record for
// DynPropose.ChannelType.
DPChannelType tlv.Type = 6

// DPKickoffFeerate is the TLV type number that identifies the record
// for DynPropose.KickoffFeerate.
DPKickoffFeerate tlv.Type = 7
)

// DynPropose is a message that is sent during a dynamic commitments negotiation
Expand Down Expand Up @@ -81,11 +76,6 @@ type DynPropose struct {
// parameter.
ChannelType fn.Option[ChannelType]

// KickoffFeerate proposes the fee rate in satoshis per kw that it
// is offering for a ChannelType conversion that requires a kickoff
// transaction.
KickoffFeerate fn.Option[chainfee.SatPerKWeight]

// ExtraData is the set of data that was appended to this message to
// fill out the full maximum transport message size. These fields can
// be used to specify optional data such as custom TLV fields.
Expand Down Expand Up @@ -161,14 +151,6 @@ func (dp *DynPropose) Encode(w *bytes.Buffer, _ uint32) error {
),
)
})
dp.KickoffFeerate.WhenSome(func(kickoffFeerate chainfee.SatPerKWeight) {
protoSats := uint32(kickoffFeerate)
tlvRecords = append(
tlvRecords, tlv.MakePrimitiveRecord(
DPKickoffFeerate, &protoSats,
),
)
})
tlv.SortRecords(tlvRecords)

tlvStream, err := tlv.NewStream(tlvRecords...)
Expand Down Expand Up @@ -241,15 +223,10 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
channelTypeEncoder, channelTypeDecoder,
)

var kickoffFeerateScratch uint32
kickoffFeerate := tlv.MakePrimitiveRecord(
DPKickoffFeerate, &kickoffFeerateScratch,
)

// Create set of Records to read TLV bytestream into.
records := []tlv.Record{
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
chanType, kickoffFeerate,
chanType,
}
tlv.SortRecords(records)

Expand Down Expand Up @@ -288,11 +265,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
if val, ok := typeMap[DPChannelType]; ok && val == nil {
dp.ChannelType = fn.Some(chanTypeScratch)
}
if val, ok := typeMap[DPKickoffFeerate]; ok && val == nil {
dp.KickoffFeerate = fn.Some(
chainfee.SatPerKWeight(kickoffFeerateScratch),
)
}

if len(tlvRecords) != 0 {
dp.ExtraData = tlvRecords
Expand Down Expand Up @@ -369,14 +341,6 @@ func (dp *DynPropose) SerializeTlvData() ([]byte, error) {
),
)
})
dp.KickoffFeerate.WhenSome(func(kickoffFeerate chainfee.SatPerKWeight) {
protoSats := uint32(kickoffFeerate)
tlvRecords = append(
tlvRecords, tlv.MakePrimitiveRecord(
DPKickoffFeerate, &protoSats,
),
)
})
tlv.SortRecords(tlvRecords)

tlvStream, err := tlv.NewStream(tlvRecords...)
Expand Down
14 changes: 0 additions & 14 deletions lnwire/lnwire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv"
"github.com/lightningnetwork/lnd/tor"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -862,11 +861,6 @@ func TestLightningWireProtocol(t *testing.T) {
dp.ChannelType = fn.Some(v)
}

if rand.Uint32()%2 == 0 {
v := chainfee.SatPerKWeight(rand.Uint32())
dp.KickoffFeerate = fn.Some(v)
}

v[0] = reflect.ValueOf(dp)
},
MsgDynReject: func(v []reflect.Value, r *rand.Rand) {
Expand Down Expand Up @@ -906,9 +900,6 @@ func TestLightningWireProtocol(t *testing.T) {
features.Set(FeatureBit(DPChannelType))
}

if rand.Uint32()%2 == 0 {
features.Set(FeatureBit(DPKickoffFeerate))
}
dr.UpdateRejections = *features

v[0] = reflect.ValueOf(dr)
Expand Down Expand Up @@ -965,11 +956,6 @@ func TestLightningWireProtocol(t *testing.T) {
dc.ChannelType = fn.Some(v)
}

if rand.Uint32()%2 == 0 {
v := chainfee.SatPerKWeight(rand.Uint32())
dc.KickoffFeerate = fn.Some(v)
}

v[0] = reflect.ValueOf(dc)
},
MsgKickoffSig: func(v []reflect.Value, r *rand.Rand) {
Expand Down

0 comments on commit bd77255

Please sign in to comment.