Skip to content

Commit d963c73

Browse files
committed
tapchannel: trigger noop HTLCs on ProduceHtlcExtraData
Whenever we use the default above-dust anchor amount to send an HTLC with assets we also set the noop flag on the HTLC, which will produce the according noop HTLC record and signal to LND that the satoshi amount should be returned to the sender.
1 parent 72e654d commit d963c73

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tapchannel/aux_traffic_shaper.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,14 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
431431
if htlc.Amounts.Val.Sum() > 0 {
432432
log.Tracef("Already have asset amount (sum %d) in HTLC, not "+
433433
"producing extra data", htlc.Amounts.Val.Sum())
434-
return totalAmount, htlcCustomRecords, nil
434+
435+
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
436+
updatedRecords, err := htlc.ToCustomRecords()
437+
if err != nil {
438+
return 0, nil, err
439+
}
440+
441+
return totalAmount, updatedRecords, nil
435442
}
436443

437444
if htlc.RfqID.ValOpt().IsNone() {
@@ -496,6 +503,12 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
496503
// amount that should be sent on-chain, which is a value in satoshi that
497504
// is just above the dust limit.
498505
htlcAmountMSat := rfqmath.DefaultOnChainHtlcMSat
506+
507+
// Now we set the flag that marks this HTLC as a noop_add, which means
508+
// that the above dust will eventually return to us. This means that
509+
// only the assets will be sent and not any btc balance.
510+
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
511+
499512
updatedRecords, err := htlc.ToCustomRecords()
500513
if err != nil {
501514
return 0, nil, fmt.Errorf("error encoding HTLC blob: %w", err)

0 commit comments

Comments
 (0)