Skip to content

Commit 5911187

Browse files
committed
tapchannel: check feature bit before setting noop htlc
1 parent ac87431 commit 5911187

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tapchannel/aux_traffic_shaper.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/lightninglabs/taproot-assets/rfqmath"
1515
"github.com/lightninglabs/taproot-assets/rfqmsg"
1616
cmsg "github.com/lightninglabs/taproot-assets/tapchannelmsg"
17+
"github.com/lightninglabs/taproot-assets/tapfeatures"
1718
lfn "github.com/lightningnetwork/lnd/fn/v2"
1819
"github.com/lightningnetwork/lnd/lntypes"
1920
"github.com/lightningnetwork/lnd/lnutils"
@@ -30,6 +31,8 @@ type TrafficShaperConfig struct {
3031

3132
RfqManager *rfq.Manager
3233

34+
AuxChanNegotiator *tapfeatures.AuxChannelNegotiator
35+
3336
// NoOpHTLCs is a boolean indicating whether the daemon configuration
3437
// wants us to produce NoOp HTLCs.
3538
NoopHTLCs bool
@@ -464,6 +467,9 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
464467
return totalAmount, nil, nil
465468
}
466469

470+
peerFeatures := s.cfg.AuxChanNegotiator.GetPeerFeatures(peer)
471+
supportNoOp := peerFeatures.HasFeature(tapfeatures.NoOpHTLCsOptional)
472+
467473
// We need to do a round trip to convert the custom records to a blob
468474
// that we can then parse into the correct struct again.
469475
htlc, err := rfqmsg.HtlcFromCustomRecords(htlcCustomRecords)
@@ -478,7 +484,7 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
478484
log.Tracef("Already have asset amount (sum %d) in HTLC, not "+
479485
"producing extra data", htlc.Amounts.Val.Sum())
480486

481-
if s.cfg.NoopHTLCs {
487+
if s.cfg.NoopHTLCs && supportNoOp {
482488
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
483489
}
484490

@@ -587,7 +593,7 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
587593
// Now we set the flag that marks this HTLC as a noop_add, which means
588594
// that the above dust will eventually return to us. This means that
589595
// only the assets will be sent and not any btc balance.
590-
if s.cfg.NoopHTLCs {
596+
if s.cfg.NoopHTLCs && supportNoOp {
591597
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
592598
}
593599

0 commit comments

Comments
 (0)