Skip to content

Commit 62a1709

Browse files
committed
tapchannel: detect invalid noops on invoice acceptor
It is possible for someone to pay to a sats invoice with sats HTLCs over a taproot assets channel. If for any reason they set the noop flag we must not accept the HTLC as it would be accounted for in the invoice but the amount would never be received on the channel.
1 parent a52f621 commit 62a1709

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tapchannel/aux_invoice_manager.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/lightningnetwork/lnd/invoices"
1818
"github.com/lightningnetwork/lnd/lnrpc"
1919
"github.com/lightningnetwork/lnd/lnutils"
20+
"github.com/lightningnetwork/lnd/lnwallet"
2021
"github.com/lightningnetwork/lnd/lnwire"
2122
"github.com/lightningnetwork/lnd/routing/route"
2223
)
@@ -196,7 +197,26 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
196197

197198
resp.CancelSet = true
198199
} else {
199-
iLog.Tracef("has no asset custom records, ignoring")
200+
noopTLV := uint64(lnwallet.NoOpHtlcTLVEntry.TypeVal())
201+
_, isNoop := req.WireCustomRecords[noopTLV]
202+
203+
// If the HTLC does not carry assets and the invoice is
204+
// also not expecting assets then we do not want to
205+
// modify anything as assets are not involved. If for
206+
// any reason the noop flag is set (which is meant for
207+
// asset HTLCs) we want to log a warning and cancel the
208+
// HTLCs. Letting this HTLC through at this point means
209+
// that we would be accounting a certain sats amount
210+
// in favor of our invoice, without ever receiving that
211+
// amount.
212+
if isNoop {
213+
resp.CancelSet = true
214+
iLog.Warnf("sats HTLC without assets " +
215+
"attempted a noop-add, cancelling set")
216+
} else {
217+
iLog.Tracef("has no asset custom records, " +
218+
"ignoring")
219+
}
200220
}
201221

202222
return resp, nil

0 commit comments

Comments
 (0)