2021-08-23 10:35:48 +02:00
//go:build dev
2020-07-08 14:26:05 -07:00
// +build dev
package lncfg
2023-04-03 11:53:02 +02:00
import (
"github.com/lightningnetwork/lnd/feature"
"github.com/lightningnetwork/lnd/lnwire"
)
2020-07-08 14:26:05 -07:00
// ExperimentalProtocol is a sub-config that houses any experimental protocol
// features that also require a build-tag to activate.
2022-07-06 09:26:47 +02:00
//
//nolint:lll
2020-07-08 14:26:05 -07:00
type ExperimentalProtocol struct {
2022-07-06 09:26:47 +02:00
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." `
2023-04-03 11:53:02 +02:00
CustomInit [ ] uint16 ` long:"custom-init" description:"custom feature bits to advertise in the node's init message" `
CustomNodeAnn [ ] uint16 ` long:"custom-nodeann" description:"custom feature bits to advertise in the node's announcement message" `
CustomInvoice [ ] uint16 ` long:"custom-invoice" description:"custom feature bits to advertise in the node's invoices" `
2022-07-06 09:26:47 +02:00
}
// CustomMessageOverrides returns the set of protocol messages that we override
// to allow custom handling.
func ( p ExperimentalProtocol ) CustomMessageOverrides ( ) [ ] uint16 {
return p . CustomMessage
2020-07-08 14:26:05 -07:00
}
2023-04-03 11:53:02 +02:00
// CustomFeatures returns a custom set of feature bits to advertise.
//
//nolint:lll
func ( p ExperimentalProtocol ) CustomFeatures ( ) map [ feature . Set ] [ ] lnwire . FeatureBit {
customFeatures := make ( map [ feature . Set ] [ ] lnwire . FeatureBit )
setFeatures := func ( set feature . Set , bits [ ] uint16 ) {
for _ , customFeature := range bits {
customFeatures [ set ] = append (
customFeatures [ set ] ,
lnwire . FeatureBit ( customFeature ) ,
)
}
}
setFeatures ( feature . SetInit , p . CustomInit )
setFeatures ( feature . SetNodeAnn , p . CustomNodeAnn )
setFeatures ( feature . SetInvoice , p . CustomInvoice )
return customFeatures
}