Skip to content

Commit

Permalink
Expose LNURL-pay comment (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-21 authored Apr 23, 2024
1 parent 126729b commit e21c495
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,10 @@ fn print_outgoing_payment(payment: OutgoingPaymentInfo) -> Result<()> {
amount_to_string(&payment.network_fees)
);
println!(" Recipient: {:?}", payment.recipient);
println!(
" Comment sent: {:?}",
payment.comment_for_recipient
);
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions src/lipalightninglib.udl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ dictionary OutgoingPaymentInfo {
PaymentInfo payment_info;
Amount network_fees;
Recipient recipient;
string? comment_for_recipient;
};

enum PaymentState {
Expand Down
12 changes: 10 additions & 2 deletions src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ pub struct OutgoingPaymentInfo {
pub network_fees: Amount,
/// Information about a payment's recipient.
pub recipient: Recipient,
/// Comment sent to the recipient.
/// Only set for LNURL-pay and lightning address payments where a comment has been sent.
pub comment_for_recipient: Option<String>,
}

impl OutgoingPaymentInfo {
Expand All @@ -197,18 +200,23 @@ impl OutgoingPaymentInfo {
.fee_msat
.as_msats()
.to_amount_up(exchange_rate);
let recipient = match breez_payment.details {
PaymentDetails::Ln { ref data } => Recipient::new(data),
let data = match breez_payment.details {
PaymentDetails::Ln { ref data } => data,
PaymentDetails::ClosedChannel { .. } => {
permanent_failure!("OutgoingPaymentInfo cannot be created from channel close")
}
};
let recipient = Recipient::new(data);
// TODO: Read the comment from `data`.
// let comment_for_recipient = data.lnurl_pay_comment.clone();
let comment_for_recipient = None;
let payment_info =
PaymentInfo::new(breez_payment, exchange_rate, tz_config, personal_note)?;
Ok(Self {
payment_info,
network_fees,
recipient,
comment_for_recipient,
})
}
}
Expand Down

0 comments on commit e21c495

Please sign in to comment.