mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-07 22:10:27 +02:00
multi: add custom message overrides to protocol config options
This commit is contained in:
12
config.go
12
config.go
@ -39,6 +39,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/routing"
|
"github.com/lightningnetwork/lnd/routing"
|
||||||
"github.com/lightningnetwork/lnd/signal"
|
"github.com/lightningnetwork/lnd/signal"
|
||||||
"github.com/lightningnetwork/lnd/sweep"
|
"github.com/lightningnetwork/lnd/sweep"
|
||||||
@ -1656,6 +1657,17 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
lncfg.DefaultIncomingBroadcastDelta)
|
lncfg.DefaultIncomingBroadcastDelta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the experimental protocol options specify any protocol messages
|
||||||
|
// that we want to handle as custom messages, set them now.
|
||||||
|
//nolint:lll
|
||||||
|
customMsg := cfg.ProtocolOptions.ExperimentalProtocol.CustomMessageOverrides()
|
||||||
|
|
||||||
|
// We can safely set our custom override values during startup because
|
||||||
|
// startup is blocked on config parsing.
|
||||||
|
if err := lnwire.SetCustomOverrides(customMsg); err != nil {
|
||||||
|
return nil, mkErr("custom-message: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Validate the subconfigs for workers, caches, and the tower client.
|
// Validate the subconfigs for workers, caches, and the tower client.
|
||||||
err = lncfg.Validate(
|
err = lncfg.Validate(
|
||||||
cfg.Workers,
|
cfg.Workers,
|
||||||
|
@ -7,3 +7,9 @@ package lncfg
|
|||||||
// features that also require a build-tag to activate.
|
// features that also require a build-tag to activate.
|
||||||
type ExperimentalProtocol struct {
|
type ExperimentalProtocol struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CustomMessageOverrides returns the set of protocol messages that we override
|
||||||
|
// to allow custom handling.
|
||||||
|
func (p ExperimentalProtocol) CustomMessageOverrides() []uint16 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -5,5 +5,14 @@ package lncfg
|
|||||||
|
|
||||||
// ExperimentalProtocol is a sub-config that houses any experimental protocol
|
// ExperimentalProtocol is a sub-config that houses any experimental protocol
|
||||||
// features that also require a build-tag to activate.
|
// features that also require a build-tag to activate.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
type ExperimentalProtocol struct {
|
type ExperimentalProtocol struct {
|
||||||
|
CustomMessage []uint16 `long:"custom-message" description:"allows the custom message apis to send and report messages with the protocol number provided that fall outside of the custom message number range."`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomMessageOverrides returns the set of protocol messages that we override
|
||||||
|
// to allow custom handling.
|
||||||
|
func (p ExperimentalProtocol) CustomMessageOverrides() []uint16 {
|
||||||
|
return p.CustomMessage
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user