Skip to content

Commit 791908b

Browse files
Add MessageContext for async payments.
1 parent 2d37358 commit 791908b

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ pub enum MessageContext {
9898
///
9999
/// [`OffersMessage`]: crate::onion_message::offers::OffersMessage
100100
Offers(OffersContext),
101+
/// Represents the data specific to [`AsyncPaymentsMessage`]s.
102+
///
103+
/// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
104+
AsyncPayments(AsyncPaymentsContext),
101105
/// Represents custom data received in a Custom Onion Message.
102106
Custom(Vec<u8>),
103107
}
@@ -119,9 +123,22 @@ pub enum OffersContext {
119123
},
120124
}
121125

126+
/// Contains data specific to [`AsyncPaymentsMessage`]s.
127+
///
128+
/// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
129+
#[derive(Clone, Debug)]
130+
pub enum AsyncPaymentsContext {
131+
/// Represents an outbound async payment context.
132+
OutboundPayment {
133+
/// Payment id of the outbound payment.
134+
payment_id: PaymentId
135+
},
136+
}
137+
122138
impl_writeable_tlv_based_enum!(MessageContext, ;
123139
(0, Offers),
124140
(1, Custom),
141+
(2, AsyncPayments),
125142
);
126143

127144
impl_writeable_tlv_based_enum!(OffersContext,
@@ -131,6 +148,12 @@ impl_writeable_tlv_based_enum!(OffersContext,
131148
},
132149
;);
133150

151+
impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
152+
(0, OutboundPayment) => {
153+
(0, payment_id, required),
154+
},
155+
;);
156+
134157
/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.
135158
pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
136159
secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey,

lightning/src/onion_message/messenger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ where
14631463
let context = match context {
14641464
None => OffersContext::Unknown {},
14651465
Some(MessageContext::Offers(context)) => context,
1466-
Some(MessageContext::Custom(_)) => {
1466+
Some(MessageContext::Custom(_)) | Some(MessageContext::AsyncPayments(_)) => {
14671467
debug_assert!(false, "Shouldn't have triggered this case.");
14681468
return
14691469
}
@@ -1486,7 +1486,7 @@ where
14861486
let context = match context {
14871487
None => None,
14881488
Some(MessageContext::Custom(data)) => Some(data),
1489-
Some(MessageContext::Offers(_)) => {
1489+
Some(MessageContext::Offers(_)) | Some(MessageContext::AsyncPayments(_)) => {
14901490
debug_assert!(false, "Shouldn't have triggered this case.");
14911491
return
14921492
}

0 commit comments

Comments
 (0)