Skip to content

Commit 2173dc4

Browse files
author
ffranr
authored
Merge pull request #1490 from Roasbeef/invoice-cancel-logging
tapchannel: add extra logging when we cancel incoming invoice HTLCs
2 parents 851dcad + 19983fc commit 2173dc4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

tapchannel/aux_invoice_manager.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,13 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
166166
return nil, fmt.Errorf("unable to decode response: %w", err)
167167
}
168168

169-
log.Debugf("Received invoice: %s", jsonBytes)
170-
log.Debugf("Received wire custom records: %v",
169+
iLog := log.WithPrefix(
170+
fmt.Sprintf("Invoice(hash=%x, amt=%v): ",
171+
req.Invoice.RHash, req.Invoice.Value),
172+
)
173+
174+
iLog.Debugf("received invoice: %s", jsonBytes)
175+
iLog.Debugf("received wire custom records: %v",
171176
limitSpewer.Sdump(req.WireCustomRecords))
172177

173178
// Check if any strict forwarding rules need to be applied. Strict
@@ -186,7 +191,12 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
186191
//
187192
// TODO(george): Strict-forwarding could be configurable?
188193
if isAssetInvoice(req.Invoice, s) {
194+
iLog.Debugf("has no asset custom records, but " +
195+
"invoice requires assets, canceling HTLCs")
196+
189197
resp.CancelSet = true
198+
} else {
199+
iLog.Tracef("has no asset custom records, ignoring")
190200
}
191201

192202
return resp, nil
@@ -198,6 +208,9 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
198208
// Since we requested btc we should be receiving btc.
199209
resp.CancelSet = true
200210

211+
iLog.Debugf("has asset custom records, but invoice does not " +
212+
"require assets, canceling HTLCs")
213+
201214
return resp, nil
202215

203216
default:
@@ -209,7 +222,7 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
209222
return nil, fmt.Errorf("unable to decode htlc: %w", err)
210223
}
211224

212-
log.Debugf("Received htlc: %v", limitSpewer.Sdump(htlc))
225+
iLog.Debugf("received htlc: %v", limitSpewer.Sdump(htlc))
213226

214227
// If we don't have an RFQ ID, then this is likely a keysend payment,
215228
// and we don't modify the amount (since the invoice amount will match
@@ -221,7 +234,7 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
221234
// We now run some validation checks on the asset HTLC.
222235
err = s.validateAssetHTLC(ctx, htlc, resp.CircuitKey)
223236
if err != nil {
224-
log.Errorf("Failed to validate asset HTLC: %v", err)
237+
iLog.Errorf("failed to validate asset HTLC: %v", err)
225238

226239
resp.CancelSet = true
227240

@@ -266,7 +279,7 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
266279
totalInboundWithMargin := totalInbound + allowedMarginMSat + 1
267280
invoiceValue := lnwire.MilliSatoshi(req.Invoice.ValueMsat)
268281

269-
log.Debugf("Accepted HTLC sum: %v, current HTLC amount: %v, allowed "+
282+
iLog.Debugf("accepted HTLC sum: %v, current HTLC amount: %v, allowed "+
270283
"margin: %v (total %v), invoice value %v", acceptedHtlcSum,
271284
resp.AmtPaid, allowedMarginMSat, totalInboundWithMargin,
272285
invoiceValue)

0 commit comments

Comments
 (0)