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