Skip to content

Commit

Permalink
multi: enable optional route blinding feature
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaKC committed Mar 18, 2024
1 parent 9a65140 commit 1be045a
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 331 deletions.
5 changes: 5 additions & 0 deletions feature/default_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ var defaultSetDesc = setDesc{
SetInit: {}, // I
SetNodeAnn: {}, // N
},
lnwire.RouteBlindingOptional: {
SetInit: {}, // I
SetNodeAnn: {}, // N
SetInvoice: {}, // 9
},
lnwire.ShutdownAnySegwitOptional: {
SetInit: {}, // I
SetNodeAnn: {}, // N
Expand Down
6 changes: 6 additions & 0 deletions feature/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ var deps = depDesc{
lnwire.AnchorsZeroFeeHtlcTxOptional: {},
lnwire.ExplicitChannelTypeOptional: {},
},
lnwire.RouteBlindingOptional: {
lnwire.TLVOnionPayloadOptional: {},
},
lnwire.RouteBlindingRequired: {
lnwire.TLVOnionPayloadRequired: {},
},
}

// ValidateDeps asserts that a feature vector sets all features and their
Expand Down
10 changes: 9 additions & 1 deletion feature/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type Config struct {
// segwit witness versions for co-op closes.
NoAnySegwit bool

// NoRouteBlinding unsets route blinding feature bits.
NoRouteBlinding bool

// CustomFeatures is a set of custom features to advertise in each
// set.
CustomFeatures map[Set][]lnwire.FeatureBit
Expand Down Expand Up @@ -123,6 +126,8 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
raw.Unset(lnwire.PaymentAddrRequired)
raw.Unset(lnwire.MPPOptional)
raw.Unset(lnwire.MPPRequired)
raw.Unset(lnwire.RouteBlindingOptional)
raw.Unset(lnwire.RouteBlindingRequired)
raw.Unset(lnwire.AMPOptional)
raw.Unset(lnwire.AMPRequired)
raw.Unset(lnwire.KeysendOptional)
Expand Down Expand Up @@ -179,7 +184,10 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
raw.Unset(lnwire.SimpleTaprootChannelsOptionalStaging)
raw.Unset(lnwire.SimpleTaprootChannelsRequiredStaging)
}

if cfg.NoRouteBlinding {
raw.Unset(lnwire.RouteBlindingOptional)
raw.Unset(lnwire.RouteBlindingRequired)
}
for _, custom := range cfg.CustomFeatures[set] {
if custom > set.Maximum() {
return nil, fmt.Errorf("feature bit: %v "+
Expand Down
670 changes: 340 additions & 330 deletions lnrpc/lightning.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lnrpc/lightning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4280,6 +4280,8 @@ enum FeatureBit {
ANCHORS_OPT = 21;
ANCHORS_ZERO_FEE_HTLC_REQ = 22;
ANCHORS_ZERO_FEE_HTLC_OPT = 23;
ROUTE_BLINDING_REQUIRED = 24;
ROUTE_BLINDING_OPTIONAL = 25;
AMP_REQ = 30;
AMP_OPT = 31;
}
Expand Down
4 changes: 4 additions & 0 deletions lnrpc/lightning.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,8 @@
"ANCHORS_OPT",
"ANCHORS_ZERO_FEE_HTLC_REQ",
"ANCHORS_ZERO_FEE_HTLC_OPT",
"ROUTE_BLINDING_REQUIRED",
"ROUTE_BLINDING_OPTIONAL",
"AMP_REQ",
"AMP_OPT"
]
Expand Down Expand Up @@ -4650,6 +4652,8 @@
"ANCHORS_OPT",
"ANCHORS_ZERO_FEE_HTLC_REQ",
"ANCHORS_ZERO_FEE_HTLC_OPT",
"ROUTE_BLINDING_REQUIRED",
"ROUTE_BLINDING_OPTIONAL",
"AMP_REQ",
"AMP_OPT"
],
Expand Down
2 changes: 2 additions & 0 deletions lnrpc/peersrpc/peers.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
"ANCHORS_OPT",
"ANCHORS_ZERO_FEE_HTLC_REQ",
"ANCHORS_ZERO_FEE_HTLC_OPT",
"ROUTE_BLINDING_REQUIRED",
"ROUTE_BLINDING_OPTIONAL",
"AMP_REQ",
"AMP_OPT"
],
Expand Down
2 changes: 2 additions & 0 deletions lnrpc/routerrpc/router.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@
"ANCHORS_OPT",
"ANCHORS_ZERO_FEE_HTLC_REQ",
"ANCHORS_ZERO_FEE_HTLC_OPT",
"ROUTE_BLINDING_REQUIRED",
"ROUTE_BLINDING_OPTIONAL",
"AMP_REQ",
"AMP_OPT"
],
Expand Down
10 changes: 10 additions & 0 deletions lnwire/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ const (
// transactions, which also imply anchor commitments.
AnchorsZeroFeeHtlcTxOptional FeatureBit = 23

// RouteBlindingRequired is a required feature bit that signals that
// the node supports blinded payments.
RouteBlindingRequired FeatureBit = 24

// RouteBlindingOptional is an optional feature bit that signals that
// the node supports blinded payments.
RouteBlindingOptional FeatureBit = 25

// ShutdownAnySegwitRequired is an required feature bit that signals
// that the sender is able to properly handle/parse segwit witness
// programs up to version 16. This enables utilization of Taproot
Expand Down Expand Up @@ -315,6 +323,8 @@ var Features = map[FeatureBit]string{
ScidAliasOptional: "scid-alias",
ZeroConfRequired: "zero-conf",
ZeroConfOptional: "zero-conf",
RouteBlindingRequired: "route-blinding",
RouteBlindingOptional: "route-blinding",
ShutdownAnySegwitRequired: "shutdown-any-segwit",
ShutdownAnySegwitOptional: "shutdown-any-segwit",
SimpleTaprootChannelsRequiredFinal: "simple-taproot-chans",
Expand Down
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
NoAnySegwit: cfg.ProtocolOptions.NoAnySegwit(),
CustomFeatures: cfg.ProtocolOptions.ExperimentalProtocol.CustomFeatures(),
NoTaprootChans: !cfg.ProtocolOptions.TaprootChans,
NoRouteBlinding: cfg.ProtocolOptions.NoRouteBlinding(),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 1be045a

Please sign in to comment.