/ lncfg / protocol_integration.go
protocol_integration.go
  1  //go:build integration
  2  
  3  package lncfg
  4  
  5  import (
  6  	"github.com/lightningnetwork/lnd/feature"
  7  	"github.com/lightningnetwork/lnd/lnwire"
  8  )
  9  
 10  // ProtocolOptions is a struct that we use to be able to test backwards
 11  // compatibility of protocol additions, while defaulting to the latest within
 12  // lnd, or to enable experimental protocol changes.
 13  //
 14  // TODO(yy): delete this build flag to unify with `lncfg/protocol.go`.
 15  //
 16  //nolint:ll
 17  type ProtocolOptions struct {
 18  	// LegacyProtocol is a sub-config that houses all the legacy protocol
 19  	// options.  These are mostly used for integration tests as most modern
 20  	// nodes should always run with them on by default.
 21  	LegacyProtocol `group:"legacy" namespace:"legacy"`
 22  
 23  	// ExperimentalProtocol is a sub-config that houses any experimental
 24  	// protocol features that also require a build-tag to activate.
 25  	ExperimentalProtocol
 26  
 27  	// WumboChans should be set if we want to enable support for wumbo
 28  	// (channels larger than 0.16 BTC) channels, which is the opposite of
 29  	// mini.
 30  	WumboChans bool `long:"wumbo-channels" description:"if set, then lnd will create and accept requests for channels larger chan 0.16 BTC"`
 31  
 32  	// TaprootChans should be set if we want to enable support for the
 33  	// experimental simple taproot chans commitment type.
 34  	TaprootChans bool `long:"simple-taproot-chans" description:"if set, then lnd will create and accept requests for channels using the simple taproot commitment type"`
 35  
 36  	// TaprootOverlayChans should be set if we want to enable support for
 37  	// the experimental taproot overlay chan type.
 38  	TaprootOverlayChans bool `long:"simple-taproot-overlay-chans" description:"if set, then lnd will create and accept requests for channels using the taproot overlay commitment type"`
 39  
 40  	// Anchors enables anchor commitments.
 41  	// TODO(halseth): transition itests to anchors instead!
 42  	Anchors bool `long:"anchors" description:"enable support for anchor commitments"`
 43  
 44  	// RbfCoopClose should be set if we want to signal that we support for
 45  	// the new experimental RBF coop close feature.
 46  	RbfCoopClose bool `long:"rbf-coop-close" description:"if set, then lnd will signal that it supports the new RBF based coop close protocol"`
 47  
 48  	// ScriptEnforcedLease enables script enforced commitments for channel
 49  	// leases.
 50  	//
 51  	// TODO: Move to experimental?
 52  	ScriptEnforcedLease bool `long:"script-enforced-lease" description:"enable support for script enforced lease commitments"`
 53  
 54  	// OptionScidAlias should be set if we want to signal the
 55  	// option-scid-alias feature bit. This allows scid aliases and the
 56  	// option-scid-alias channel-type.
 57  	OptionScidAlias bool `long:"option-scid-alias" description:"enable support for option_scid_alias channels"`
 58  
 59  	// OptionZeroConf should be set if we want to signal the zero-conf
 60  	// feature bit.
 61  	OptionZeroConf bool `long:"zero-conf" description:"enable support for zero-conf channels, must have option-scid-alias set also"`
 62  
 63  	// NoOptionAnySegwit should be set to true if we don't want to use any
 64  	// Taproot (and beyond) addresses for co-op closing.
 65  	NoOptionAnySegwit bool `long:"no-any-segwit" description:"disallow using any segiwt witness version as a co-op close address"`
 66  
 67  	// NoTimestampQueryOption should be set to true if we don't want our
 68  	// syncing peers to also send us the timestamps of announcement messages
 69  	// when we send them a channel range query. Setting this to true will
 70  	// also mean that we won't respond with timestamps if requested by our
 71  	// peers.
 72  	NoTimestampQueryOption bool `long:"no-timestamp-query-option" description:"do not query syncing peers for announcement timestamps and do not respond with timestamps if requested"`
 73  
 74  	// NoRouteBlindingOption disables forwarding of payments in blinded routes.
 75  	NoRouteBlindingOption bool `long:"no-route-blinding" description:"do not forward payments that are a part of a blinded route"`
 76  
 77  	// NoOnionMessagesOption disables onion message forwarding.
 78  	NoOnionMessagesOption bool `long:"no-onion-messages" description:"disable support for onion messaging"`
 79  
 80  	// NoExperimentalAccountabilityOption disables experimental accountability.
 81  	NoExperimentalAccountabilityOption bool `long:"no-experimental-accountability" description:"do not forward experimental accountability signals"`
 82  
 83  	// NoExperimentalEndorsementOption is the deprecated name for
 84  	// NoExperimentalAccountabilityOption. It is hidden and will be removed
 85  	// in a future release.
 86  	NoExperimentalEndorsementOption bool `long:"no-experimental-endorsement" hidden:"true" description:"deprecated: use no-experimental-accountability instead"`
 87  
 88  	// NoQuiescenceOption disables quiescence for all channels.
 89  	NoQuiescenceOption bool `long:"no-quiescence" description:"do not allow or advertise quiescence for any channel"`
 90  
 91  	// CustomMessage allows the custom message APIs to handle messages with
 92  	// the provided protocol numbers, which fall outside the custom message
 93  	// number range.
 94  	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."`
 95  
 96  	// CustomInit specifies feature bits to advertise in the node's init
 97  	// message.
 98  	CustomInit []uint16 `long:"custom-init" description:"custom feature bits to advertise in the node's init message"`
 99  
100  	// CustomNodeAnn specifies custom feature bits to advertise in the
101  	// node's announcement message.
102  	CustomNodeAnn []uint16 `long:"custom-nodeann" description:"custom feature bits to advertise in the node's announcement message"`
103  
104  	// CustomInvoice specifies custom feature bits to advertise in the
105  	// node's invoices.
106  	CustomInvoice []uint16 `long:"custom-invoice" description:"custom feature bits to advertise in the node's invoices"`
107  }
108  
109  // Wumbo returns true if lnd should permit the creation and acceptance of wumbo
110  // channels.
111  func (l *ProtocolOptions) Wumbo() bool {
112  	return l.WumboChans
113  }
114  
115  // NoAnchorCommitments returns true if we have disabled support for the anchor
116  // commitment type.
117  func (l *ProtocolOptions) NoAnchorCommitments() bool {
118  	return !l.Anchors
119  }
120  
121  // NoScriptEnforcementLease returns true if we have disabled support for the
122  // script enforcement commitment type for leased channels.
123  func (l *ProtocolOptions) NoScriptEnforcementLease() bool {
124  	return !l.ScriptEnforcedLease
125  }
126  
127  // ScidAlias returns true if we have enabled the option-scid-alias feature bit.
128  func (l *ProtocolOptions) ScidAlias() bool {
129  	return l.OptionScidAlias
130  }
131  
132  // ZeroConf returns true if we have enabled the zero-conf feature bit.
133  func (l *ProtocolOptions) ZeroConf() bool {
134  	return l.OptionZeroConf
135  }
136  
137  // NoAnySegwit returns true if we don't signal that we understand other newer
138  // segwit witness versions for co-op close addresses.
139  func (l *ProtocolOptions) NoAnySegwit() bool {
140  	return l.NoOptionAnySegwit
141  }
142  
143  // NoRouteBlinding returns true if forwarding of blinded payments is disabled.
144  func (l *ProtocolOptions) NoRouteBlinding() bool {
145  	return l.NoRouteBlindingOption
146  }
147  
148  // NoOnionMessages returns true if onion messaging is disabled.
149  func (l *ProtocolOptions) NoOnionMessages() bool {
150  	return l.NoOnionMessagesOption
151  }
152  
153  // NoExpAccountability returns true if experimental accountability should be
154  // disabled. It also checks the deprecated NoExperimentalEndorsementOption for
155  // backwards compatibility.
156  func (l *ProtocolOptions) NoExpAccountability() bool {
157  	return l.NoExperimentalAccountabilityOption ||
158  		l.NoExperimentalEndorsementOption
159  }
160  
161  // NoQuiescence returns true if quiescence is disabled.
162  func (l *ProtocolOptions) NoQuiescence() bool {
163  	return l.NoQuiescenceOption
164  }
165  
166  // CustomMessageOverrides returns the set of protocol messages that we override
167  // to allow custom handling.
168  func (l ProtocolOptions) CustomMessageOverrides() []uint16 {
169  	return l.CustomMessage
170  }
171  
172  // CustomFeatures returns a custom set of feature bits to advertise.
173  func (l ProtocolOptions) CustomFeatures() map[feature.Set][]lnwire.FeatureBit {
174  	customFeatures := make(map[feature.Set][]lnwire.FeatureBit)
175  
176  	setFeatures := func(set feature.Set, bits []uint16) {
177  		for _, customFeature := range bits {
178  			customFeatures[set] = append(
179  				customFeatures[set],
180  				lnwire.FeatureBit(customFeature),
181  			)
182  		}
183  	}
184  
185  	setFeatures(feature.SetInit, l.CustomInit)
186  	setFeatures(feature.SetNodeAnn, l.CustomNodeAnn)
187  	setFeatures(feature.SetInvoice, l.CustomInvoice)
188  
189  	return customFeatures
190  }