Skip to content

Commit

Permalink
Include Refund context in blinded payment paths
Browse files Browse the repository at this point in the history
When requesting a payment for a refund, include a context in the
Bolt12Invoice's blinded payment paths indicated it is for such. When the
eventual payment is received, the user can use the payment hash to
correlate it with the corresponding Refund.
  • Loading branch information
jkczyz committed Mar 26, 2024
1 parent 209c657 commit d36af73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ pub enum PaymentContext {
/// [`Offer`]: crate::offers::offer::Offer
offer_id: OfferId,
},
/// The payment was made for invoice sent for a BOLT 12 [`Refund`].
///
/// [`Refund`]: crate::offers::refund::Refund
Bolt12Refund {},
}

impl TryFrom<CounterpartyForwardingInfo> for PaymentRelay {
Expand Down Expand Up @@ -339,6 +343,7 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentContext,
(0, Bolt12Offer) => {
(0, offer_id, required),
},
(2, Bolt12Refund) => {},
);

#[cfg(test)]
Expand Down
3 changes: 2 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7979,8 +7979,9 @@ where

match self.create_inbound_payment(Some(amount_msats), relative_expiry, None) {
Ok((payment_hash, payment_secret)) => {
let payment_context = PaymentContext::Bolt12Refund {};
let payment_paths = self.create_blinded_payment_paths(
amount_msats, payment_secret, None
amount_msats, payment_secret, Some(payment_context)
)
.map_err(|_| Bolt12SemanticError::MissingPaths)?;

Expand Down

0 comments on commit d36af73

Please sign in to comment.