Skip to content

Commit d36af73

Browse files
committed
Include Refund context in blinded payment paths
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.
1 parent 209c657 commit d36af73

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lightning/src/blinded_path/payment.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ pub enum PaymentContext {
116116
/// [`Offer`]: crate::offers::offer::Offer
117117
offer_id: OfferId,
118118
},
119+
/// The payment was made for invoice sent for a BOLT 12 [`Refund`].
120+
///
121+
/// [`Refund`]: crate::offers::refund::Refund
122+
Bolt12Refund {},
119123
}
120124

121125
impl TryFrom<CounterpartyForwardingInfo> for PaymentRelay {
@@ -339,6 +343,7 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentContext,
339343
(0, Bolt12Offer) => {
340344
(0, offer_id, required),
341345
},
346+
(2, Bolt12Refund) => {},
342347
);
343348

344349
#[cfg(test)]

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7979,8 +7979,9 @@ where
79797979

79807980
match self.create_inbound_payment(Some(amount_msats), relative_expiry, None) {
79817981
Ok((payment_hash, payment_secret)) => {
7982+
let payment_context = PaymentContext::Bolt12Refund {};
79827983
let payment_paths = self.create_blinded_payment_paths(
7983-
amount_msats, payment_secret, None
7984+
amount_msats, payment_secret, Some(payment_context)
79847985
)
79857986
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
79867987

0 commit comments

Comments
 (0)