@@ -86,8 +86,9 @@ type Policy interface {
86
86
// GenerateInterceptorResponse generates an interceptor response for the
87
87
// HTLC interceptor from the policy.
88
88
GenerateInterceptorResponse (
89
- lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
90
- error )
89
+ lndclient.InterceptedHtlc ,
90
+ * tapfeatures.AuxChannelNegotiator ,
91
+ ) (* lndclient.InterceptedHtlcResponse , error )
91
92
}
92
93
93
94
// AssetSalePolicy is a struct that holds the terms which determine whether an
@@ -127,10 +128,6 @@ type AssetSalePolicy struct {
127
128
// wants us to produce NoOp HTLCs.
128
129
NoOpHTLCs bool
129
130
130
- // auxChannelNegotiator is used to query the supported feature bits that
131
- // are supported by a peer, or a channel.
132
- auxChanNegotiator * tapfeatures.AuxChannelNegotiator
133
-
134
131
// peer is the peer pub key of the peer we established this policy with.
135
132
peer route.Vertex
136
133
@@ -140,9 +137,7 @@ type AssetSalePolicy struct {
140
137
}
141
138
142
139
// NewAssetSalePolicy creates a new asset sale policy.
143
- func NewAssetSalePolicy (quote rfqmsg.BuyAccept , noop bool ,
144
- chanNegotiator * tapfeatures.AuxChannelNegotiator ,
145
- peer route.Vertex ) * AssetSalePolicy {
140
+ func NewAssetSalePolicy (quote rfqmsg.BuyAccept , noop bool ) * AssetSalePolicy {
146
141
147
142
htlcToAmtMap := make (map [models.CircuitKey ]lnwire.MilliSatoshi )
148
143
@@ -154,8 +149,7 @@ func NewAssetSalePolicy(quote rfqmsg.BuyAccept, noop bool,
154
149
expiry : uint64 (quote .AssetRate .Expiry .Unix ()),
155
150
htlcToAmt : htlcToAmtMap ,
156
151
NoOpHTLCs : noop ,
157
- auxChanNegotiator : chanNegotiator ,
158
- peer : peer ,
152
+ peer : quote .Peer ,
159
153
}
160
154
}
161
155
@@ -265,8 +259,9 @@ func (c *AssetSalePolicy) Scid() uint64 {
265
259
266
260
// GenerateInterceptorResponse generates an interceptor response for the policy.
267
261
func (c * AssetSalePolicy ) GenerateInterceptorResponse (
268
- htlc lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
269
- error ) {
262
+ htlc lndclient.InterceptedHtlc ,
263
+ auxChanNegotiator * tapfeatures.AuxChannelNegotiator ,
264
+ ) (* lndclient.InterceptedHtlcResponse , error ) {
270
265
271
266
outgoingAmt := rfqmath .DefaultOnChainHtlcMSat
272
267
@@ -304,7 +299,7 @@ func (c *AssetSalePolicy) GenerateInterceptorResponse(
304
299
fn .None [[]rfqmsg.ID ](),
305
300
)
306
301
307
- peerFeatures := c . auxChanNegotiator .GetPeerFeatures (c .peer )
302
+ peerFeatures := auxChanNegotiator .GetPeerFeatures (c .peer )
308
303
supportNoOp := peerFeatures .HasFeature (tapfeatures .NoOpHTLCsOptional )
309
304
310
305
// We are about to create an outgoing HTLC that carries assets. Let's
@@ -510,8 +505,9 @@ func (c *AssetPurchasePolicy) Scid() uint64 {
510
505
511
506
// GenerateInterceptorResponse generates an interceptor response for the policy.
512
507
func (c * AssetPurchasePolicy ) GenerateInterceptorResponse (
513
- htlc lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
514
- error ) {
508
+ htlc lndclient.InterceptedHtlc ,
509
+ _ * tapfeatures.AuxChannelNegotiator ,
510
+ ) (* lndclient.InterceptedHtlcResponse , error ) {
515
511
516
512
htlcRecord , err := parseHtlcCustomRecords (htlc .InWireCustomRecords )
517
513
if err != nil {
@@ -639,19 +635,20 @@ func (a *AssetForwardPolicy) Scid() uint64 {
639
635
640
636
// GenerateInterceptorResponse generates an interceptor response for the policy.
641
637
func (a * AssetForwardPolicy ) GenerateInterceptorResponse (
642
- htlc lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
643
- error ) {
638
+ htlc lndclient.InterceptedHtlc ,
639
+ auxChanNegotiator * tapfeatures.AuxChannelNegotiator ,
640
+ ) (* lndclient.InterceptedHtlcResponse , error ) {
644
641
645
642
incomingResponse , err := a .incomingPolicy .GenerateInterceptorResponse (
646
- htlc ,
643
+ htlc , auxChanNegotiator ,
647
644
)
648
645
if err != nil {
649
646
return nil , fmt .Errorf ("error generating incoming interceptor " +
650
647
"response: %w" , err )
651
648
}
652
649
653
650
outgoingResponse , err := a .outgoingPolicy .GenerateInterceptorResponse (
654
- htlc ,
651
+ htlc , auxChanNegotiator ,
655
652
)
656
653
if err != nil {
657
654
return nil , fmt .Errorf ("error generating outgoing interceptor " +
@@ -815,7 +812,7 @@ func (h *OrderHandler) handleIncomingHtlc(ctx context.Context,
815
812
log .Debug ("HTLC complies with policy. Broadcasting accept event." )
816
813
h .cfg .AcceptHtlcEvents <- NewAcceptHtlcEvent (htlc , policy )
817
814
818
- return policy .GenerateInterceptorResponse (htlc )
815
+ return policy .GenerateInterceptorResponse (htlc , h . cfg . AuxChanNegotiator )
819
816
}
820
817
821
818
// setupHtlcIntercept sets up HTLC interception.
@@ -962,10 +959,7 @@ func (h *OrderHandler) RegisterAssetSalePolicy(buyAccept rfqmsg.BuyAccept) {
962
959
log .Debugf ("Order handler is registering an asset sale policy given a " +
963
960
"buy accept message: %s" , buyAccept .String ())
964
961
965
- policy := NewAssetSalePolicy (
966
- buyAccept , h .cfg .NoOpHTLCs , h .cfg .AuxChanNegotiator ,
967
- buyAccept .Peer ,
968
- )
962
+ policy := NewAssetSalePolicy (buyAccept , h .cfg .NoOpHTLCs )
969
963
970
964
h .policies .Store (policy .AcceptedQuoteId .Scid (), policy )
971
965
}
0 commit comments