mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
lnwire: remove kickoff feerate from propose/commit
This commit is contained in:
committed by
yyforyongyu
parent
36f53d74ab
commit
cbca5b1152
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
)
|
||||
|
||||
@@ -101,14 +100,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...)
|
||||
@@ -179,15 +170,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)
|
||||
|
||||
@@ -225,11 +211,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
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
)
|
||||
|
||||
@@ -39,10 +38,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
|
||||
@@ -80,11 +75,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.
|
||||
@@ -164,14 +154,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...)
|
||||
@@ -244,15 +226,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)
|
||||
|
||||
@@ -291,11 +268,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
|
||||
@@ -379,14 +351,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...)
|
||||
|
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
"github.com/stretchr/testify/require"
|
||||
"pgregory.net/rapid"
|
||||
@@ -832,7 +831,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
|
||||
)
|
||||
includeFundingKey := rapid.Bool().Draw(t, "includeFundingKey")
|
||||
includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
|
||||
includeKickoffFeerate := rapid.Bool().Draw(t, "includeKickoffFeerate")
|
||||
|
||||
// Generate random values for each included field
|
||||
if includeDustLimit {
|
||||
@@ -868,13 +866,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
|
||||
msg.ChannelType = fn.Some(*RandChannelType(t))
|
||||
}
|
||||
|
||||
if includeKickoffFeerate {
|
||||
kf := chainfee.SatPerKWeight(rapid.Uint32().Draw(
|
||||
t, "kickoffFeerate"),
|
||||
)
|
||||
msg.KickoffFeerate = fn.Some(kf)
|
||||
}
|
||||
|
||||
return msg
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user