lnwire: remove FundingKey from DynPropose and DynCommit
This commit is contained in:
1 parent
cbca5b1152
commit
f40530e4f4
3 files changed
+2
-59
No files matched your search
+1
-19
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/fn/v2"
|
"github.com/lightningnetwork/lnd/fn/v2"
|
||||||
"github.com/lightningnetwork/lnd/tlv"
|
"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) {
|
dc.ChannelType.WhenSome(func(ty ChannelType) {
|
||||||
tlvRecords = append(
|
tlvRecords = append(
|
||||||
tlvRecords, tlv.MakeDynamicRecord(
|
tlvRecords, tlv.MakeDynamicRecord(
|
||||||
@@ -159,11 +150,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
|||||||
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
|
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
|
||||||
)
|
)
|
||||||
|
|
||||||
var fundingKeyScratch *btcec.PublicKey
|
|
||||||
fundingKey := tlv.MakePrimitiveRecord(
|
|
||||||
DPFundingPubkey, &fundingKeyScratch,
|
|
||||||
)
|
|
||||||
|
|
||||||
var chanTypeScratch ChannelType
|
var chanTypeScratch ChannelType
|
||||||
chanType := tlv.MakeDynamicRecord(
|
chanType := tlv.MakeDynamicRecord(
|
||||||
DPChannelType, &chanTypeScratch, chanTypeScratch.featureBitLen,
|
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.
|
// Create set of Records to read TLV bytestream into.
|
||||||
records := []tlv.Record{
|
records := []tlv.Record{
|
||||||
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
|
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, chanType,
|
||||||
chanType,
|
|
||||||
}
|
}
|
||||||
tlv.SortRecords(records)
|
tlv.SortRecords(records)
|
||||||
|
|
||||||
@@ -205,9 +190,6 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
|
|||||||
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
|
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
|
||||||
dc.MaxAcceptedHTLCs = fn.Some(maxHtlcsScratch)
|
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 {
|
if val, ok := typeMap[DPChannelType]; ok && val == nil {
|
||||||
dc.ChannelType = fn.Some(chanTypeScratch)
|
dc.ChannelType = fn.Some(chanTypeScratch)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-35
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/fn/v2"
|
"github.com/lightningnetwork/lnd/fn/v2"
|
||||||
"github.com/lightningnetwork/lnd/tlv"
|
"github.com/lightningnetwork/lnd/tlv"
|
||||||
@@ -31,10 +30,6 @@ const (
|
|||||||
// for DynPropose.MaxAcceptedHTLCs.
|
// for DynPropose.MaxAcceptedHTLCs.
|
||||||
DPMaxAcceptedHtlcs tlv.Type = 4
|
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
|
// DPChannelType is the TLV type number that identifies the record for
|
||||||
// DynPropose.ChannelType.
|
// DynPropose.ChannelType.
|
||||||
DPChannelType tlv.Type = 6
|
DPChannelType tlv.Type = 6
|
||||||
@@ -67,10 +62,6 @@ type DynPropose struct {
|
|||||||
// max_accepted_htlcs limit of the sender.
|
// max_accepted_htlcs limit of the sender.
|
||||||
MaxAcceptedHTLCs fn.Option[uint16]
|
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
|
// ChannelType, if not nil, proposes a change to the channel_type
|
||||||
// parameter.
|
// parameter.
|
||||||
ChannelType fn.Option[ChannelType]
|
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) {
|
dp.ChannelType.WhenSome(func(ty ChannelType) {
|
||||||
tlvRecords = append(
|
tlvRecords = append(
|
||||||
tlvRecords, tlv.MakeDynamicRecord(
|
tlvRecords, tlv.MakeDynamicRecord(
|
||||||
@@ -215,11 +198,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
|
|||||||
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
|
DPMaxAcceptedHtlcs, &maxHtlcsScratch,
|
||||||
)
|
)
|
||||||
|
|
||||||
var fundingKeyScratch *btcec.PublicKey
|
|
||||||
fundingKey := tlv.MakePrimitiveRecord(
|
|
||||||
DPFundingPubkey, &fundingKeyScratch,
|
|
||||||
)
|
|
||||||
|
|
||||||
var chanTypeScratch ChannelType
|
var chanTypeScratch ChannelType
|
||||||
chanType := tlv.MakeDynamicRecord(
|
chanType := tlv.MakeDynamicRecord(
|
||||||
DPChannelType, &chanTypeScratch, chanTypeScratch.featureBitLen,
|
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.
|
// Create set of Records to read TLV bytestream into.
|
||||||
records := []tlv.Record{
|
records := []tlv.Record{
|
||||||
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, fundingKey,
|
dustLimit, maxValue, reserve, csvDelay, maxHtlcs, chanType,
|
||||||
chanType,
|
|
||||||
}
|
}
|
||||||
tlv.SortRecords(records)
|
tlv.SortRecords(records)
|
||||||
|
|
||||||
@@ -262,9 +239,6 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
|
|||||||
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
|
if val, ok := typeMap[DPMaxAcceptedHtlcs]; ok && val == nil {
|
||||||
dp.MaxAcceptedHTLCs = fn.Some(maxHtlcsScratch)
|
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 {
|
if val, ok := typeMap[DPChannelType]; ok && val == nil {
|
||||||
dp.ChannelType = fn.Some(chanTypeScratch)
|
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) {
|
dp.ChannelType.WhenSome(func(ty ChannelType) {
|
||||||
tlvRecords = append(
|
tlvRecords = append(
|
||||||
tlvRecords, tlv.MakeDynamicRecord(
|
tlvRecords, tlv.MakeDynamicRecord(
|
||||||
|
|||||||
@@ -829,7 +829,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
|
|||||||
includeMaxAcceptedHTLCs := rapid.Bool().Draw(
|
includeMaxAcceptedHTLCs := rapid.Bool().Draw(
|
||||||
t, "includeMaxAcceptedHTLCs",
|
t, "includeMaxAcceptedHTLCs",
|
||||||
)
|
)
|
||||||
includeFundingKey := rapid.Bool().Draw(t, "includeFundingKey")
|
|
||||||
includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
|
includeChannelType := rapid.Bool().Draw(t, "includeChannelType")
|
||||||
|
|
||||||
// Generate random values for each included field
|
// Generate random values for each included field
|
||||||
@@ -858,10 +857,6 @@ func (dp *DynPropose) RandTestMessage(t *rapid.T) Message {
|
|||||||
msg.MaxAcceptedHTLCs = fn.Some(mah)
|
msg.MaxAcceptedHTLCs = fn.Some(mah)
|
||||||
}
|
}
|
||||||
|
|
||||||
if includeFundingKey {
|
|
||||||
msg.FundingKey = fn.Some(*RandPubKey(t))
|
|
||||||
}
|
|
||||||
|
|
||||||
if includeChannelType {
|
if includeChannelType {
|
||||||
msg.ChannelType = fn.Some(*RandChannelType(t))
|
msg.ChannelType = fn.Some(*RandChannelType(t))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user