mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-02 03:54:26 +02:00
lnwire: remove FundingKey from DynPropose and DynCommit
This commit is contained in:
committed by
yyforyongyu
parent
cbca5b1152
commit
f40530e4f4
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
@@ -83,14 +82,6 @@ func (dc *DynCommit) Encode(w *bytes.Buffer, _ uint32) error {
|
||||
),
|
||||
)
|
||||
})
|
||||
dc.FundingKey.WhenSome(func(key btcec.PublicKey) {
|
||||
keyScratch := &key
|
||||
tlvRecords = append(
|
||||
tlvRecords, tlv.MakePrimitiveRecord(
|
||||
DPFundingPubkey, &keyScratch,
|
||||
),
|
||||
)
|
||||
})
|
||||
dc.ChannelType.WhenSome(func(ty ChannelType) {
|
||||
tlvRecords = append(
|
||||
tlvRecords, tlv.MakeDynamicRecord(
|
||||
@@ -159,11 +150,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
||||
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
|
||||
)
|
||||
|
||||
var fundingKeyScratch *btcec.PublicKey
|
||||
fundingKey := tlv.MakePrimitiveRecord(
|
||||
DPFundingPubkey, &fundingKeyScratch,
|
||||
)
|
||||
|
||||
var chanTypeScratch ChannelType
|
||||
chanType := tlv.MakeDynamicRecord(
|
||||
DPChannelType, &chanTypeScratch, chanTypeScratch.featureBitLen,
|
||||
@@ -172,8 +158,7 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
||||
|
||||
// Create set of Records to read TLV bytestream into.
|
||||
records := []tlv.Record{
|
||||
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
|
||||
chanType,
|
||||
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, chanType,
|
||||
}
|
||||
tlv.SortRecords(records)
|
||||
|
||||
@@ -205,9 +190,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
||||
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
|
||||
dc.MaxAcceptedHTLCs = fn.Some(maxHtlcsScratch)
|
||||
}
|
||||
if val, ok := typeMap[DPFundingPubkey]; ok && val == nil {
|
||||
dc.FundingKey = fn.Some(*fundingKeyScratch)
|
||||
}
|
||||
if val, ok := typeMap[DPChannelType]; ok && val == nil {
|
||||
dc.ChannelType = fn.Some(chanTypeScratch)
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
@@ -31,10 +30,6 @@ const (
|
||||
// for DynPropose.MaxAcceptedHTLCs.
|
||||
DPMaxAcceptedHtlcs tlv.Type = 4
|
||||
|
||||
// DPFundingPubkey is the TLV type number that identifies the record for
|
||||
// DynPropose.FundingKey.
|
||||
DPFundingPubkey tlv.Type = 5
|
||||
|
||||
// DPChannelType is the TLV type number that identifies the record for
|
||||
// DynPropose.ChannelType.
|
||||
DPChannelType tlv.Type = 6
|
||||
@@ -67,10 +62,6 @@ type DynPropose struct {
|
||||
// max_accepted_htlcs limit of the sender.
|
||||
MaxAcceptedHTLCs fn.Option[uint16]
|
||||
|
||||
// FundingKey, if not nil, proposes a change to the funding_pubkey
|
||||
// parameter of the sender.
|
||||
FundingKey fn.Option[btcec.PublicKey]
|
||||
|
||||
// ChannelType, if not nil, proposes a change to the channel_type
|
||||
// parameter.
|
||||
ChannelType fn.Option[ChannelType]
|
||||
@@ -137,14 +128,6 @@ func (dp *DynPropose) Encode(w *bytes.Buffer, _ uint32) error {
|
||||
),
|
||||
)
|
||||
})
|
||||
dp.FundingKey.WhenSome(func(key btcec.PublicKey) {
|
||||
keyScratch := &key
|
||||
tlvRecords = append(
|
||||
tlvRecords, tlv.MakePrimitiveRecord(
|
||||
DPFundingPubkey, &keyScratch,
|
||||
),
|
||||
)
|
||||
})
|
||||
dp.ChannelType.WhenSome(func(ty ChannelType) {
|
||||
tlvRecords = append(
|
||||
tlvRecords, tlv.MakeDynamicRecord(
|
||||
@@ -215,11 +198,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
|
||||
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
|
||||
)
|
||||
|
||||
var fundingKeyScratch *btcec.PublicKey
|
||||
fundingKey := tlv.MakePrimitiveRecord(
|
||||
DPFundingPubkey, &fundingKeyScratch,
|
||||
)
|
||||
|
||||
var chanTypeScratch ChannelType
|
||||
chanType := tlv.MakeDynamicRecord(
|
||||
DPChannelType, &chanTypeScratch, chanTypeScratch.featureBitLen,
|
||||
@@ -228,8 +206,7 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
|
||||
|
||||
// Create set of Records to read TLV bytestream into.
|
||||
records := []tlv.Record{
|
||||
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
|
||||
chanType,
|
||||
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, chanType,
|
||||
}
|
||||
tlv.SortRecords(records)
|
||||
|
||||
@@ -262,9 +239,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
|
||||
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
|
||||
dp.MaxAcceptedHTLCs = fn.Some(maxHtlcsScratch)
|
||||
}
|
||||
if val, ok := typeMap[DPFundingPubkey]; ok && val == nil {
|
||||
dp.FundingKey = fn.Some(*fundingKeyScratch)
|
||||
}
|
||||
if val, ok := typeMap[DPChannelType]; ok && val == nil {
|
||||
dp.ChannelType = fn.Some(chanTypeScratch)
|
||||
}
|
||||
@@ -334,14 +308,6 @@ func (dp *DynPropose) SerializeTlvData() ([]byte, error) {
|
||||
),
|
||||
)
|
||||
})
|
||||
dp.FundingKey.WhenSome(func(key btcec.PublicKey) {
|
||||
keyScratch := &key
|
||||
tlvRecords = append(
|
||||
tlvRecords, tlv.MakePrimitiveRecord(
|
||||
DPFundingPubkey, &keyScratch,
|
||||
),
|
||||
)
|
||||
})
|
||||
dp.ChannelType.WhenSome(func(ty ChannelType) {
|
||||
tlvRecords = append(
|
||||
tlvRecords, tlv.MakeDynamicRecord(
|
||||
|
@@ -829,7 +829,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
|
||||
includeMaxAcceptedHTLCs := rapid.Bool().Draw(
|
||||
t, "includeMaxAcceptedHTLCs",
|
||||
)
|
||||
includeFundingKey := rapid.Bool().Draw(t, "includeFundingKey")
|
||||
includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
|
||||
|
||||
// Generate random values for each included field
|
||||
@@ -858,10 +857,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
|
||||
msg.MaxAcceptedHTLCs = fn.Some(mah)
|
||||
}
|
||||
|
||||
if includeFundingKey {
|
||||
msg.FundingKey = fn.Some(*RandPubKey(t))
|
||||
}
|
||||
|
||||
if includeChannelType {
|
||||
msg.ChannelType = fn.Some(*RandChannelType(t))
|
||||
}
|
||||
|
Reference in New Issue
Block a user