Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,449 changes: 1,731 additions & 1,718 deletions lnrpc/lightning.pb.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions lnrpc/lightning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3202,6 +3202,13 @@ message QueryRoutesRequest {
channel may be used.
*/
repeated uint64 outgoing_chan_ids = 20;

/*
An optional payment address to be included in the MPP record for the
payment. If present, an MPP record will be included in the final hop
of the returned route. This should be a 32-byte value when encoded.
*/
bytes payment_addr = 21;
}

message NodePair {
Expand Down
13 changes: 13 additions & 0 deletions lnrpc/lightning.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,14 @@
"format": "uint64"
},
"collectionFormat": "multi"
},
{
"name": "payment_addr",
"description": "An optional payment address to be included in the MPP record for the\npayment. If present, an MPP record will be included in the final hop\nof the returned route. This should be a 32-byte value when encoded.",
"in": "query",
"required": false,
"type": "string",
"format": "byte"
}
],
"tags": [
Expand Down Expand Up @@ -1683,6 +1691,11 @@
"format": "uint64"
},
"description": "The channel ids of the channels allowed for the first hop. If empty, any\nchannel may be used."
},
"payment_addr": {
"type": "string",
"format": "byte",
"description": "An optional payment address to be included in the MPP record for the\npayment. If present, an MPP record will be included in the final hop\nof the returned route. This should be a 32-byte value when encoded."
}
}
}
Expand Down
75 changes: 75 additions & 0 deletions lnrpc/routerrpc/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package routerrpc

import (
"fmt"

"github.com/lightningnetwork/lnd/aliasmgr"
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/routing"
Expand Down Expand Up @@ -51,6 +53,9 @@ type Config struct {
// AliasMgr is the alias manager instance that is used to handle all the
// SCID alias related information for channels.
AliasMgr *aliasmgr.Manager

// MPPValidator validates MPP record requirements for payments.
MPPValidator *MPPValidator
}

// DefaultConfig defines the config defaults.
Expand All @@ -75,6 +80,13 @@ func DefaultConfig() *Config {
DecayTime: routing.DefaultBimodalDecayTime,
},
FeeEstimationTimeout: routing.DefaultFeeEstimationTimeout,
MPPConfig: &MPPConfig{
EnforcementMode: "warn",
MetricsEnabled: true,
EmergencyOverride: false,
GracePeriodDays: 90,
DisableAutoUpgrade: false,
},
}

return &Config{
Expand Down Expand Up @@ -103,5 +115,68 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
DecayTime: cfg.BimodalConfig.DecayTime,
},
FeeEstimationTimeout: cfg.FeeEstimationTimeout,
MPPConfig: &MPPConfig{
EnforcementMode: cfg.MPPConfig.EnforcementMode,
QueryRoutesMode: cfg.MPPConfig.QueryRoutesMode,
SendToRouteMode: cfg.MPPConfig.SendToRouteMode,
BuildRouteMode: cfg.MPPConfig.BuildRouteMode,
MetricsEnabled: cfg.MPPConfig.MetricsEnabled,
EmergencyOverride: cfg.MPPConfig.EmergencyOverride,
GracePeriodDays: cfg.MPPConfig.GracePeriodDays,
DisableAutoUpgrade: cfg.MPPConfig.DisableAutoUpgrade,
},
}
}

// GetMPPValidationConfig converts the routing config MPP settings to
// MPPValidationConfig.
func GetMPPValidationConfig(cfg *RoutingConfig) (*MPPValidationConfig, error) {
if cfg.MPPConfig == nil {
return DefaultMPPValidationConfig(), nil
}

// Parse global enforcement mode
globalMode, err := ParseEnforcementMode(cfg.MPPConfig.EnforcementMode)
if err != nil {
return nil, fmt.Errorf(
"invalid global enforcement mode: %w", err)
}

// Parse per-RPC modes
perRPCModes := make(map[string]EnforcementMode)

if cfg.MPPConfig.QueryRoutesMode != "" {
mode, err := ParseEnforcementMode(cfg.MPPConfig.QueryRoutesMode)
if err != nil {
return nil, fmt.Errorf(
"invalid QueryRoutes enforcement mode: %w", err)
}
perRPCModes["QueryRoutes"] = mode
}

if cfg.MPPConfig.SendToRouteMode != "" {
mode, err := ParseEnforcementMode(cfg.MPPConfig.SendToRouteMode)
if err != nil {
return nil, fmt.Errorf(
"invalid SendToRoute enforcement mode: %w", err)
}
perRPCModes["SendToRoute"] = mode
}

if cfg.MPPConfig.BuildRouteMode != "" {
mode, err := ParseEnforcementMode(cfg.MPPConfig.BuildRouteMode)
if err != nil {
return nil, fmt.Errorf(
"invalid BuildRoute enforcement mode: %w", err)
}
perRPCModes["BuildRoute"] = mode
}

return &MPPValidationConfig{
GlobalMode: globalMode,
PerRPCModes: perRPCModes,
EmergencyOverride: cfg.MPPConfig.EmergencyOverride,
MetricsEnabled: cfg.MPPConfig.MetricsEnabled,
GracePeriodDays: cfg.MPPConfig.GracePeriodDays,
}, nil
}
Loading