@@ -14,11 +14,13 @@ import (
14
14
"github.com/lightninglabs/taproot-assets/fn"
15
15
"github.com/lightninglabs/taproot-assets/rfqmath"
16
16
"github.com/lightninglabs/taproot-assets/rfqmsg"
17
+ "github.com/lightninglabs/taproot-assets/tapfeatures"
17
18
"github.com/lightningnetwork/lnd/graph/db/models"
18
19
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
19
20
"github.com/lightningnetwork/lnd/lnutils"
20
21
"github.com/lightningnetwork/lnd/lnwallet"
21
22
"github.com/lightningnetwork/lnd/lnwire"
23
+ "github.com/lightningnetwork/lnd/routing/route"
22
24
"github.com/lightningnetwork/lnd/tlv"
23
25
)
24
26
@@ -125,13 +127,20 @@ type AssetSalePolicy struct {
125
127
// wants us to produce NoOp HTLCs.
126
128
NoOpHTLCs bool
127
129
130
+ auxChanNegotiator * tapfeatures.AuxChannelNegotiator
131
+
132
+ peer route.Vertex
133
+
128
134
// expiry is the policy's expiry unix timestamp after which the policy
129
135
// is no longer valid.
130
136
expiry uint64
131
137
}
132
138
133
139
// NewAssetSalePolicy creates a new asset sale policy.
134
- func NewAssetSalePolicy (quote rfqmsg.BuyAccept , noop bool ) * AssetSalePolicy {
140
+ func NewAssetSalePolicy (quote rfqmsg.BuyAccept , noop bool ,
141
+ chanNegotiator * tapfeatures.AuxChannelNegotiator ,
142
+ peer route.Vertex ) * AssetSalePolicy {
143
+
135
144
htlcToAmtMap := make (map [models.CircuitKey ]lnwire.MilliSatoshi )
136
145
137
146
return & AssetSalePolicy {
@@ -142,6 +151,8 @@ func NewAssetSalePolicy(quote rfqmsg.BuyAccept, noop bool) *AssetSalePolicy {
142
151
expiry : uint64 (quote .AssetRate .Expiry .Unix ()),
143
152
htlcToAmt : htlcToAmtMap ,
144
153
NoOpHTLCs : noop ,
154
+ auxChanNegotiator : chanNegotiator ,
155
+ peer : peer ,
145
156
}
146
157
}
147
158
@@ -290,10 +301,13 @@ func (c *AssetSalePolicy) GenerateInterceptorResponse(
290
301
fn .None [[]rfqmsg.ID ](),
291
302
)
292
303
304
+ peerFeatures := c .auxChanNegotiator .GetPeerFeatures (c .peer )
305
+ supportNoOp := peerFeatures .HasFeature (tapfeatures .NoOpHTLCsOptional )
306
+
293
307
// We are about to create an outgoing HTLC that carries assets. Let's
294
308
// set the noop flag in order to eventually only settle the assets but
295
309
// never settle the sats anchor amount that will carry them.
296
- if c .NoOpHTLCs {
310
+ if c .NoOpHTLCs && supportNoOp {
297
311
htlcRecord .SetNoopAdd (rfqmsg .UseNoOpHTLCs )
298
312
}
299
313
@@ -686,6 +700,11 @@ type OrderHandlerCfg struct {
686
700
// NoOpHTLCs is a boolean indicating whether the daemon configuration
687
701
// wants us to produce NoOp HTLCs.
688
702
NoOpHTLCs bool
703
+
704
+ // AuxChannelNegotiator is responsible for producing the extra tlv blob
705
+ // that is encapsulated in the init and reestablish peer messages. This
706
+ // helps us communicate custom feature bits with our peer.
707
+ AuxChanNegotiator * tapfeatures.AuxChannelNegotiator
689
708
}
690
709
691
710
// OrderHandler orchestrates management of accepted quote bundles. It monitors
@@ -940,7 +959,11 @@ func (h *OrderHandler) RegisterAssetSalePolicy(buyAccept rfqmsg.BuyAccept) {
940
959
log .Debugf ("Order handler is registering an asset sale policy given a " +
941
960
"buy accept message: %s" , buyAccept .String ())
942
961
943
- policy := NewAssetSalePolicy (buyAccept , h .cfg .NoOpHTLCs )
962
+ policy := NewAssetSalePolicy (
963
+ buyAccept , h .cfg .NoOpHTLCs , h .cfg .AuxChanNegotiator ,
964
+ buyAccept .Peer ,
965
+ )
966
+
944
967
h .policies .Store (policy .AcceptedQuoteId .Scid (), policy )
945
968
}
946
969
0 commit comments