@@ -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,10 +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 {
146
-
140
+ func NewAssetSalePolicy (quote rfqmsg.BuyAccept , noop bool ) * AssetSalePolicy {
147
141
htlcToAmtMap := make (map [models.CircuitKey ]lnwire.MilliSatoshi )
148
142
149
143
return & AssetSalePolicy {
@@ -154,8 +148,7 @@ func NewAssetSalePolicy(quote rfqmsg.BuyAccept, noop bool,
154
148
expiry : uint64 (quote .AssetRate .Expiry .Unix ()),
155
149
htlcToAmt : htlcToAmtMap ,
156
150
NoOpHTLCs : noop ,
157
- auxChanNegotiator : chanNegotiator ,
158
- peer : peer ,
151
+ peer : quote .Peer ,
159
152
}
160
153
}
161
154
@@ -265,8 +258,9 @@ func (c *AssetSalePolicy) Scid() uint64 {
265
258
266
259
// GenerateInterceptorResponse generates an interceptor response for the policy.
267
260
func (c * AssetSalePolicy ) GenerateInterceptorResponse (
268
- htlc lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
269
- error ) {
261
+ htlc lndclient.InterceptedHtlc ,
262
+ auxChanNegotiator * tapfeatures.AuxChannelNegotiator ,
263
+ ) (* lndclient.InterceptedHtlcResponse , error ) {
270
264
271
265
outgoingAmt := rfqmath .DefaultOnChainHtlcMSat
272
266
@@ -304,7 +298,7 @@ func (c *AssetSalePolicy) GenerateInterceptorResponse(
304
298
fn .None [[]rfqmsg.ID ](),
305
299
)
306
300
307
- peerFeatures := c . auxChanNegotiator .GetPeerFeatures (c .peer )
301
+ peerFeatures := auxChanNegotiator .GetPeerFeatures (c .peer )
308
302
supportNoOp := peerFeatures .HasFeature (tapfeatures .NoOpHTLCsOptional )
309
303
310
304
// We are about to create an outgoing HTLC that carries assets. Let's
@@ -510,8 +504,9 @@ func (c *AssetPurchasePolicy) Scid() uint64 {
510
504
511
505
// GenerateInterceptorResponse generates an interceptor response for the policy.
512
506
func (c * AssetPurchasePolicy ) GenerateInterceptorResponse (
513
- htlc lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
514
- error ) {
507
+ htlc lndclient.InterceptedHtlc ,
508
+ _ * tapfeatures.AuxChannelNegotiator ,
509
+ ) (* lndclient.InterceptedHtlcResponse , error ) {
515
510
516
511
htlcRecord , err := parseHtlcCustomRecords (htlc .InWireCustomRecords )
517
512
if err != nil {
@@ -639,19 +634,20 @@ func (a *AssetForwardPolicy) Scid() uint64 {
639
634
640
635
// GenerateInterceptorResponse generates an interceptor response for the policy.
641
636
func (a * AssetForwardPolicy ) GenerateInterceptorResponse (
642
- htlc lndclient.InterceptedHtlc ) (* lndclient.InterceptedHtlcResponse ,
643
- error ) {
637
+ htlc lndclient.InterceptedHtlc ,
638
+ auxChanNegotiator * tapfeatures.AuxChannelNegotiator ,
639
+ ) (* lndclient.InterceptedHtlcResponse , error ) {
644
640
645
641
incomingResponse , err := a .incomingPolicy .GenerateInterceptorResponse (
646
- htlc ,
642
+ htlc , auxChanNegotiator ,
647
643
)
648
644
if err != nil {
649
645
return nil , fmt .Errorf ("error generating incoming interceptor " +
650
646
"response: %w" , err )
651
647
}
652
648
653
649
outgoingResponse , err := a .outgoingPolicy .GenerateInterceptorResponse (
654
- htlc ,
650
+ htlc , auxChanNegotiator ,
655
651
)
656
652
if err != nil {
657
653
return nil , fmt .Errorf ("error generating outgoing interceptor " +
@@ -815,7 +811,7 @@ func (h *OrderHandler) handleIncomingHtlc(ctx context.Context,
815
811
log .Debug ("HTLC complies with policy. Broadcasting accept event." )
816
812
h .cfg .AcceptHtlcEvents <- NewAcceptHtlcEvent (htlc , policy )
817
813
818
- return policy .GenerateInterceptorResponse (htlc )
814
+ return policy .GenerateInterceptorResponse (htlc , h . cfg . AuxChanNegotiator )
819
815
}
820
816
821
817
// setupHtlcIntercept sets up HTLC interception.
@@ -962,10 +958,7 @@ func (h *OrderHandler) RegisterAssetSalePolicy(buyAccept rfqmsg.BuyAccept) {
962
958
log .Debugf ("Order handler is registering an asset sale policy given a " +
963
959
"buy accept message: %s" , buyAccept .String ())
964
960
965
- policy := NewAssetSalePolicy (
966
- buyAccept , h .cfg .NoOpHTLCs , h .cfg .AuxChanNegotiator ,
967
- buyAccept .Peer ,
968
- )
961
+ policy := NewAssetSalePolicy (buyAccept , h .cfg .NoOpHTLCs )
969
962
970
963
h .policies .Store (policy .AcceptedQuoteId .Scid (), policy )
971
964
}
0 commit comments