Merge pull request #236 from a-mpch/2025-09-refactor-logs

multi: add logs when tracking payments
This commit is contained in:
Maurice Poirrier 2025-09-15 17:42:52 -03:00 committed by GitHub
commit 24f3f0ff5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 5 deletions

View file

@ -2,7 +2,7 @@ use lightning::blinded_path::payment::BlindedPaymentPath;
use lightning::blinded_path::IntroductionNode;
use lightning::offers::invoice_request::InvoiceRequest;
use lightning::offers::offer::Amount;
use log::error;
use log::{error, trace};
use tonic::async_trait;
use tonic_lnd::lnrpc::{
AddInvoiceResponse, FeeLimit, GetInfoRequest, GetInfoResponse, HtlcAttempt, Invoice, PayReq,
@ -184,6 +184,10 @@ impl InvoicePayer for Client {
} else if payment.status() == tonic_lnd::lnrpc::payment::PaymentStatus::Failed {
return Err(OfferError::PaymentFailure);
} else {
trace!(
"Payment with preimage {} has not settled.",
payment.payment_preimage,
);
continue;
}
}

View file

@ -416,7 +416,7 @@ impl OffersMessageHandler for OfferHandler {
return None;
}
};
log::trace!("Invoice created: {:?}", invoice_info);
log::trace!("Invoice created successfully created...");
let invoice_builder = match verfied_invoice.respond_using_derived_keys(
invoice_info.payment_paths,

View file

@ -117,11 +117,22 @@ pub(crate) async fn send_payment(
.await
.map_err(OfferError::RouteFailure)?;
let _ = payer
trace!("Routes found {}...", resp.routes.len());
let resp = payer
.send_to_route(params.payment_hash, resp.routes[0].clone())
.await
.map_err(OfferError::RouteFailure)?;
trace!(
"Sent payment using preimage {} using attempt_id {} with status {}. {}",
hex::encode(resp.preimage),
resp.attempt_id,
resp.status,
resp.failure.map_or("".to_string(), |f| format!(
"failed with reason: {}.",
f.code
))
);
Ok(())
}

View file

@ -116,7 +116,10 @@ impl Offers for LNDKServer {
let payment = match self.offer_handler.pay_offer(cfg).await {
Ok(payment) => {
log::info!("Payment succeeded.");
log::info!(
"Payment succeeded with preimage {}.",
payment.payment_preimage
);
payment
}
Err(e) => match e {
@ -204,7 +207,7 @@ impl Offers for LNDKServer {
let (invoice, _, payment_id) = match self.offer_handler.get_invoice(cfg).await {
Ok(invoice) => {
log::info!("Invoice request succeeded.");
log::info!("Invoice request succeeded for payment_id {}.", invoice.2);
invoice
}
Err(e) => match e {