mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
multi: make tlv onion compulsory
This commit is contained in:
parent
9afe1b72dc
commit
239103c2b3
9 changed files with 29 additions and 26 deletions
|
@ -24,7 +24,7 @@ var (
|
||||||
emptyFeatures = lnwire.NewFeatureVector(nil, lnwire.Features)
|
emptyFeatures = lnwire.NewFeatureVector(nil, lnwire.Features)
|
||||||
ampFeatures = lnwire.NewFeatureVector(
|
ampFeatures = lnwire.NewFeatureVector(
|
||||||
lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
lnwire.AMPRequired,
|
lnwire.AMPRequired,
|
||||||
),
|
),
|
||||||
|
@ -3158,7 +3158,7 @@ func TestAddInvoiceInvalidFeatureDeps(t *testing.T) {
|
||||||
|
|
||||||
invoice.Terms.Features = lnwire.NewFeatureVector(
|
invoice.Terms.Features = lnwire.NewFeatureVector(
|
||||||
lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.MPPOptional,
|
lnwire.MPPOptional,
|
||||||
),
|
),
|
||||||
lnwire.Features,
|
lnwire.Features,
|
||||||
|
|
|
@ -18,7 +18,7 @@ var defaultSetDesc = setDesc{
|
||||||
SetInit: {}, // I
|
SetInit: {}, // I
|
||||||
SetNodeAnn: {}, // N
|
SetNodeAnn: {}, // N
|
||||||
},
|
},
|
||||||
lnwire.TLVOnionPayloadOptional: {
|
lnwire.TLVOnionPayloadRequired: {
|
||||||
SetInit: {}, // I
|
SetInit: {}, // I
|
||||||
SetNodeAnn: {}, // N
|
SetNodeAnn: {}, // N
|
||||||
SetInvoice: {}, // 9
|
SetInvoice: {}, // 9
|
||||||
|
|
|
@ -33,7 +33,7 @@ var depTests = []depTest{
|
||||||
{
|
{
|
||||||
name: "one dep optional",
|
name: "one dep optional",
|
||||||
raw: lnwire.NewRawFeatureVector(
|
raw: lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@ var depTests = []depTest{
|
||||||
{
|
{
|
||||||
name: "two dep optional",
|
name: "two dep optional",
|
||||||
raw: lnwire.NewRawFeatureVector(
|
raw: lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
lnwire.MPPOptional,
|
lnwire.MPPOptional,
|
||||||
),
|
),
|
||||||
|
@ -93,7 +93,7 @@ var depTests = []depTest{
|
||||||
{
|
{
|
||||||
name: "two dep first missing optional",
|
name: "two dep first missing optional",
|
||||||
raw: lnwire.NewRawFeatureVector(
|
raw: lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.MPPOptional,
|
lnwire.MPPOptional,
|
||||||
),
|
),
|
||||||
expErr: ErrMissingFeatureDep{lnwire.PaymentAddrOptional},
|
expErr: ErrMissingFeatureDep{lnwire.PaymentAddrOptional},
|
||||||
|
@ -110,7 +110,7 @@ var depTests = []depTest{
|
||||||
name: "forest optional",
|
name: "forest optional",
|
||||||
raw: lnwire.NewRawFeatureVector(
|
raw: lnwire.NewRawFeatureVector(
|
||||||
lnwire.GossipQueriesOptional,
|
lnwire.GossipQueriesOptional,
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
lnwire.MPPOptional,
|
lnwire.MPPOptional,
|
||||||
),
|
),
|
||||||
|
@ -128,7 +128,7 @@ var depTests = []depTest{
|
||||||
name: "broken forest optional",
|
name: "broken forest optional",
|
||||||
raw: lnwire.NewRawFeatureVector(
|
raw: lnwire.NewRawFeatureVector(
|
||||||
lnwire.GossipQueriesOptional,
|
lnwire.GossipQueriesOptional,
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.MPPOptional,
|
lnwire.MPPOptional,
|
||||||
),
|
),
|
||||||
expErr: ErrMissingFeatureDep{lnwire.PaymentAddrOptional},
|
expErr: ErrMissingFeatureDep{lnwire.PaymentAddrOptional},
|
||||||
|
|
|
@ -19,7 +19,7 @@ var testSetDesc = setDesc{
|
||||||
lnwire.DataLossProtectRequired: {
|
lnwire.DataLossProtectRequired: {
|
||||||
SetNodeAnn: {}, // I
|
SetNodeAnn: {}, // I
|
||||||
},
|
},
|
||||||
lnwire.TLVOnionPayloadOptional: {
|
lnwire.TLVOnionPayloadRequired: {
|
||||||
SetInit: {}, // I
|
SetInit: {}, // I
|
||||||
SetNodeAnn: {}, // N
|
SetNodeAnn: {}, // N
|
||||||
},
|
},
|
||||||
|
@ -104,6 +104,7 @@ func testManager(t *testing.T, test managerTest) {
|
||||||
// Assert that the manager properly unset the configured feature
|
// Assert that the manager properly unset the configured feature
|
||||||
// bits from all sets.
|
// bits from all sets.
|
||||||
if test.cfg.NoTLVOnion {
|
if test.cfg.NoTLVOnion {
|
||||||
|
assertUnset(lnwire.TLVOnionPayloadRequired)
|
||||||
assertUnset(lnwire.TLVOnionPayloadOptional)
|
assertUnset(lnwire.TLVOnionPayloadOptional)
|
||||||
}
|
}
|
||||||
if test.cfg.NoStaticRemoteKey {
|
if test.cfg.NoStaticRemoteKey {
|
||||||
|
|
|
@ -756,10 +756,10 @@ func (i *InvoiceRegistry) processKeySend(ctx invoiceUpdateCtx) error {
|
||||||
// Create an invoice for the htlc amount.
|
// Create an invoice for the htlc amount.
|
||||||
amt := ctx.amtPaid
|
amt := ctx.amtPaid
|
||||||
|
|
||||||
// Set tlv optional feature vector on the invoice. Otherwise we wouldn't
|
// Set tlv required feature vector on the invoice. Otherwise we wouldn't
|
||||||
// be able to pay to it with keysend.
|
// be able to pay to it with keysend.
|
||||||
rawFeatures := lnwire.NewRawFeatureVector(
|
rawFeatures := lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
)
|
)
|
||||||
features := lnwire.NewFeatureVector(rawFeatures, lnwire.Features)
|
features := lnwire.NewFeatureVector(rawFeatures, lnwire.Features)
|
||||||
|
|
||||||
|
@ -820,11 +820,11 @@ func (i *InvoiceRegistry) processAMP(ctx invoiceUpdateCtx) error {
|
||||||
// record.
|
// record.
|
||||||
amt := ctx.mpp.TotalMsat()
|
amt := ctx.mpp.TotalMsat()
|
||||||
|
|
||||||
// Set the TLV and MPP optional features on the invoice. We'll also make
|
// Set the TLV required and MPP optional features on the invoice. We'll
|
||||||
// the AMP features required so that it can't be paid by legacy or MPP
|
// also make the AMP features required so that it can't be paid by
|
||||||
// htlcs.
|
// legacy or MPP htlcs.
|
||||||
rawFeatures := lnwire.NewRawFeatureVector(
|
rawFeatures := lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
lnwire.AMPRequired,
|
lnwire.AMPRequired,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1460,7 +1460,7 @@ func TestSettleInvoicePaymentAddrRequired(t *testing.T) {
|
||||||
Expiry: time.Hour,
|
Expiry: time.Hour,
|
||||||
Features: lnwire.NewFeatureVector(
|
Features: lnwire.NewFeatureVector(
|
||||||
lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrRequired,
|
lnwire.PaymentAddrRequired,
|
||||||
),
|
),
|
||||||
lnwire.Features,
|
lnwire.Features,
|
||||||
|
@ -1549,7 +1549,7 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
|
||||||
Expiry: time.Hour,
|
Expiry: time.Hour,
|
||||||
Features: lnwire.NewFeatureVector(
|
Features: lnwire.NewFeatureVector(
|
||||||
lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
),
|
),
|
||||||
lnwire.Features,
|
lnwire.Features,
|
||||||
|
|
|
@ -181,11 +181,13 @@ func (c *integratedRoutingContext) testPayment(maxParts uint32,
|
||||||
FeeLimit: lnwire.MaxMilliSatoshi,
|
FeeLimit: lnwire.MaxMilliSatoshi,
|
||||||
Target: c.target.pubkey,
|
Target: c.target.pubkey,
|
||||||
PaymentAddr: &paymentAddr,
|
PaymentAddr: &paymentAddr,
|
||||||
DestFeatures: lnwire.NewFeatureVector(baseFeatureBits, nil),
|
DestFeatures: lnwire.NewFeatureVector(
|
||||||
Amount: c.amt,
|
baseFeatureBits, lnwire.Features,
|
||||||
CltvLimit: math.MaxUint32,
|
),
|
||||||
MaxParts: maxParts,
|
Amount: c.amt,
|
||||||
RouteHints: c.routeHints,
|
CltvLimit: math.MaxUint32,
|
||||||
|
MaxParts: maxParts,
|
||||||
|
RouteHints: c.routeHints,
|
||||||
}
|
}
|
||||||
|
|
||||||
var paymentHash [32]byte
|
var paymentHash [32]byte
|
||||||
|
|
|
@ -379,7 +379,7 @@ func TestPaymentAddrOnlyNoSplit(t *testing.T) {
|
||||||
twoPathGraph(ctx.graph, chanSize, chanSize)
|
twoPathGraph(ctx.graph, chanSize, chanSize)
|
||||||
|
|
||||||
payAddrOnlyFeatures := []lnwire.FeatureBit{
|
payAddrOnlyFeatures := []lnwire.FeatureBit{
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ var (
|
||||||
|
|
||||||
tlvFeatures = lnwire.NewFeatureVector(
|
tlvFeatures = lnwire.NewFeatureVector(
|
||||||
lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
), lnwire.Features,
|
), lnwire.Features,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,13 +72,13 @@ var (
|
||||||
|
|
||||||
tlvPayAddrFeatures = lnwire.NewFeatureVector(
|
tlvPayAddrFeatures = lnwire.NewFeatureVector(
|
||||||
lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
), lnwire.Features,
|
), lnwire.Features,
|
||||||
)
|
)
|
||||||
|
|
||||||
mppFeatures = lnwire.NewRawFeatureVector(
|
mppFeatures = lnwire.NewRawFeatureVector(
|
||||||
lnwire.TLVOnionPayloadOptional,
|
lnwire.TLVOnionPayloadRequired,
|
||||||
lnwire.PaymentAddrOptional,
|
lnwire.PaymentAddrOptional,
|
||||||
lnwire.MPPOptional,
|
lnwire.MPPOptional,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue