Skip to content

Conversation

@TheBlueMatt
Copy link
Collaborator

In much of LDK we pass around `Logger` objects both to avoid having
to `Clone` `Logger` `Deref`s (soon to only be `Logger`s) and to
allow us to set context with a wrapper such that any log calls on
that wrapper get additional useful metadata in them.

Sadly, when we added a `Logger` type to `OutboundPayments` we broke
the ability to do the second thing - payment information logged
directly or indirectly via logic in the `OutboundPayments` has no
context making log-searching rather challenging.

Here we move to instead using the automated `add_logging`
proc-macro to require that `OutboundPayment` functions receive a
`WithContext` logger, appropriately setting (especially) the
`payment_hash` as we do so.

Fixes #4307

I believe the first three commits can/should be backported to 0.2. Ideally we'd also backports a variant to 0.1 to fix #4307 there but I'm not really sure its quite worth it to write a whole new version just for 0.1.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 25, 2026

I've assigned @wpaulino as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

In much of LDK we pass around `Logger` objects both to avoid having
to `Clone` `Logger` `Deref`s (soon to only be `Logger`s) and to
allow us to set context with a wrapper such that any log calls on
that wrapper get additional useful metadata in them.

Sadly, when we added a `Logger` type to `OutboundPayments` we broke
the ability to do the second thing - payment information logged
directly or indirectly via logic in the `OutboundPayments` has no
context making log-searching rather challenging.

Here we simplify some of the changes that will be required to
remove `OutboundPayments::logger` and pass it in from calsites
(with context required) by adding a proc-macro that will at least
add the required bounds and parameters to `outbound_payments.rs`
and pass the logger automatically when we call methods on `self`.
In `ChannelMonitor` logging, we often wrap a logger with
`WithChannelMonitor` to automatically include metadata in our
structured logging. That's great, except having too many logger
wrapping types flying around makes for less compatibility if we
have methods that want to require a wrapped-logger.

Here we change the `WithChannelMonitor` "constructors" to actually
return a `WithContext` instead, making things more consistent.
In much of LDK we pass around `Logger` objects both to avoid having
to `Clone` `Logger` `Deref`s (soon to only be `Logger`s) and to
allow us to set context with a wrapper such that any log calls on
that wrapper get additional useful metadata in them.

Sadly, when we added a `Logger` type to `OutboundPayments` we broke
the ability to do the second thing - payment information logged
directly or indirectly via logic in the `OutboundPayments` has no
context making log-searching rather challenging.

Here we move to instead using the automated `add_logging`
proc-macro to require that `OutboundPayment` functions receive a
`WithContext` logger, appropriately setting (especially) the
`payment_hash` as we do so.

Fixes lightningdevkit#4307
While `PaymentHash`es are great for searching logs, in the case of
BOLT 12 the hash isn't selected until well into the payment
process. Thus, its important that we allow for filtering by
`PaymentId` as well to ensure payment-related logs are always
reliably searchable.
@TheBlueMatt TheBlueMatt force-pushed the 2026-01-decode-log-payment-hash branch from 3ca1fbd to ad93b8d Compare January 25, 2026 16:51
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 81.06996% with 92 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.02%. Comparing base (3fee76b) to head (ad93b8d).

Files with missing lines Patch % Lines
lightning-macros/src/lib.rs 72.05% 57 Missing and 7 partials ⚠️
lightning/src/ln/outbound_payment.rs 84.67% 11 Missing and 8 partials ⚠️
lightning/src/ln/channelmanager.rs 90.21% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4342      +/-   ##
==========================================
- Coverage   86.08%   86.02%   -0.06%     
==========================================
  Files         156      156              
  Lines      102416   102485      +69     
  Branches   102416   102485      +69     
==========================================
+ Hits        88165    88167       +2     
- Misses      11759    11816      +57     
- Partials     2492     2502      +10     
Flag Coverage Δ
tests 86.02% <81.06%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decode_onion_failure loggers dont have a payment hash

2 participants