Skip to content

Commit 8737847

Browse files
committed
tapchannel: use prefix logger for invoices in handleInvoiceAccept
This'll make it easier to follow operations related to a given invoice in the logs.
1 parent b600049 commit 8737847

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tapchannel/aux_invoice_manager.go

Lines changed: 10 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
@@ -209,7 +214,7 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
209214
return nil, fmt.Errorf("unable to decode htlc: %w", err)
210215
}
211216

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

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

226231
resp.CancelSet = true
227232

@@ -266,7 +271,7 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(ctx context.Context,
266271
totalInboundWithMargin := totalInbound + allowedMarginMSat + 1
267272
invoiceValue := lnwire.MilliSatoshi(req.Invoice.ValueMsat)
268273

269-
log.Debugf("Accepted HTLC sum: %v, current HTLC amount: %v, allowed "+
274+
iLog.Debugf("accepted HTLC sum: %v, current HTLC amount: %v, allowed "+
270275
"margin: %v (total %v), invoice value %v", acceptedHtlcSum,
271276
resp.AmtPaid, allowedMarginMSat, totalInboundWithMargin,
272277
invoiceValue)

0 commit comments

Comments
 (0)