Skip to content

Commit f6a1db8

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 42f317d commit f6a1db8

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
@@ -395,7 +395,14 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
395395
if htlc.Amounts.Val.Sum() > 0 {
396396
log.Tracef("Already have asset amount (sum %d) in HTLC, not "+
397397
"producing extra data", htlc.Amounts.Val.Sum())
398-
return totalAmount, htlcCustomRecords, nil
398+
399+
htlc.SetNoopAdd()
400+
updatedRecords, err := htlc.ToCustomRecords()
401+
if err != nil {
402+
return 0, nil, err
403+
}
404+
405+
return totalAmount, updatedRecords, nil
399406
}
400407

401408
if htlc.RfqID.ValOpt().IsNone() {
@@ -460,6 +467,12 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
460467
// amount that should be sent on-chain, which is a value in satoshi that
461468
// is just above the dust limit.
462469
htlcAmountMSat := rfqmath.DefaultOnChainHtlcMSat
470+
471+
// Now we set the flag that marks this HTLC as a noop_add, which means
472+
// that the above dust will eventually return to us. This means that
473+
// only the assets will be sent and not any btc balance.
474+
htlc.SetNoopAdd()
475+
463476
updatedRecords, err := htlc.ToCustomRecords()
464477
if err != nil {
465478
return 0, nil, fmt.Errorf("error encoding HTLC blob: %w", err)

0 commit comments

Comments
 (0)