Skip to content

Commit 2c7bc9e

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 141c835 commit 2c7bc9e

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
@@ -473,7 +473,14 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
473473
if htlc.Amounts.Val.Sum() > 0 {
474474
log.Tracef("Already have asset amount (sum %d) in HTLC, not "+
475475
"producing extra data", htlc.Amounts.Val.Sum())
476-
return totalAmount, htlcCustomRecords, nil
476+
477+
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
478+
updatedRecords, err := htlc.ToCustomRecords()
479+
if err != nil {
480+
return 0, nil, err
481+
}
482+
483+
return totalAmount, updatedRecords, nil
477484
}
478485

479486
// Within the context of a payment we may negotiate multiple quotes. All
@@ -569,6 +576,12 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
569576
// amount that should be sent on-chain, which is a value in satoshi that
570577
// is just above the dust limit.
571578
htlcAmountMSat := rfqmath.DefaultOnChainHtlcMSat
579+
580+
// Now we set the flag that marks this HTLC as a noop_add, which means
581+
// that the above dust will eventually return to us. This means that
582+
// only the assets will be sent and not any btc balance.
583+
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
584+
572585
updatedRecords, err := htlc.ToCustomRecords()
573586
if err != nil {
574587
return 0, nil, fmt.Errorf("error encoding HTLC blob: %w", err)

0 commit comments

Comments
 (0)