Skip to content

Commit

Permalink
Merge pull request #132 from orbitalturtle/improve-logs
Browse files Browse the repository at this point in the history
offers: improve offer flow logs
  • Loading branch information
orbitalturtle authored Jul 5, 2024
2 parents 6b2171f + d844f75 commit 80fcd0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,12 @@ impl OffersMessageHandler for OfferHandler {
None
}
OffersMessage::Invoice(invoice) => {
info!("Received an invoice: {invoice:?}");
let secp_ctx = &Secp256k1::new();
// We verify that this invoice is a response to an invoice request we sent.
match invoice.verify(&self.expanded_key, secp_ctx) {
Ok(payment_id) => {
info!("Received an invoice: {invoice:?}");

info!("Successfully verified invoice for payment_id {payment_id}");
let mut active_payments = self.active_payments.lock().unwrap();
match active_payments.get_mut(&payment_id) {
Some(pay_info) => match pay_info.invoice {
Expand Down
15 changes: 14 additions & 1 deletion src/lndk_offers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use lightning::offers::parse::{Bolt12ParseError, Bolt12SemanticError};
use lightning::onion_message::messenger::{Destination, PendingOnionMessage};
use lightning::onion_message::offers::OffersMessage;
use lightning::sign::EntropySource;
use log::error;
use log::{debug, error};
use std::collections::hash_map::Entry;
use std::error::Error;
use std::fmt::Display;
Expand Down Expand Up @@ -128,6 +128,14 @@ impl OfferHandler {
let pubkey = PublicKey::from_str(&info.identity_pubkey).unwrap();
reply_path = Some(self.create_reply_path(client.clone(), pubkey).await?)
};

if let Some(ref reply_path) = reply_path {
debug!(
"In invoice request, we chose {} as the introduction node of the reply path",
reply_path.introduction_node_id
);
};

let contents = OffersMessage::InvoiceRequest(invoice_request);
let pending_message = PendingOnionMessage {
contents,
Expand Down Expand Up @@ -266,6 +274,11 @@ impl OfferHandler {
mut payer: impl InvoicePayer + std::marker::Send + 'static,
params: PayInvoiceParams,
) -> Result<Payment, OfferError<Secp256k1Error>> {
debug!(
"Attempting to pay invoice with introduction node {}",
params.path.introduction_node_id
);

let resp = payer
.query_routes(
params.path,
Expand Down

0 comments on commit 80fcd0c

Please sign in to comment.