@@ -70,6 +70,18 @@ type PeerMessenger interface {
7070 msg lnwire.Message ) error
7171}
7272
73+ // ErrNoPeer is returned when a peer can't be found.
74+ var ErrNoPeer = errors .New ("peer not found" )
75+
76+ // FeatureBitVerifer is an interface that allows us to verify that a peer has a
77+ // given feature bit set.
78+ type FeatureBitVerifer interface {
79+ // HasFeature returns true if the peer has the given feature bit set.
80+ // If the peer can't be found, then ErrNoPeer is returned.
81+ HasFeature (ctx context.Context , peerPub btcec.PublicKey ,
82+ bit lnwire.FeatureBit ) (bool , error )
83+ }
84+
7385// OpenChanReq is a request to open a new asset channel with a remote peer.
7486type OpenChanReq struct {
7587 // ChanAmt is the amount of BTC to put into the channel. Some BTC is
@@ -200,6 +212,10 @@ type FundingControllerCfg struct {
200212 // AssetSyncer is used to ensure that we've already verified the asset
201213 // genesis for any assets used within channels.
202214 AssetSyncer AssetSyncer
215+
216+ // FeatureBits is used to verify that the peer has the required feature
217+ // to fund asset channels.
218+ FeatureBits FeatureBitVerifer
203219}
204220
205221// bindFundingReq is a request to bind a pending channel ID to a complete aux
@@ -1322,6 +1338,21 @@ func (f *FundingController) processFundingMsg(ctx context.Context,
13221338func (f * FundingController ) processFundingReq (fundingFlows fundingFlowIndex ,
13231339 fundReq * FundReq ) error {
13241340
1341+ // Before we even attempt funding, let's make sure that the remote peer
1342+ // actually supports the feature bit.
1343+ supportsAssetChans , err := f .cfg .FeatureBits .HasFeature (
1344+ fundReq .ctx , fundReq .PeerPub ,
1345+ lnwire .SimpleTaprootOverlayChansOptional ,
1346+ )
1347+ if err != nil {
1348+ return fmt .Errorf ("unable to query peer feature bits: %w" , err )
1349+ }
1350+
1351+ if ! supportsAssetChans {
1352+ return fmt .Errorf ("peer %x does not support asset channels" ,
1353+ fundReq .PeerPub .SerializeCompressed ())
1354+ }
1355+
13251356 // To start, we'll make a new pending asset funding desc. This'll be
13261357 // our scratch pad during the asset funding process.
13271358 tempPID , err := newPendingChanID ()
0 commit comments