///
/// [`OffersMessage`]: crate::onion_message::offers::OffersMessage
Offers(OffersContext),
+ /// Context specific to an [`AsyncPaymentsMessage`].
+ ///
+ /// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
+ AsyncPayments(AsyncPaymentsContext),
/// Context specific to a [`CustomOnionMessageHandler::CustomMessage`].
///
/// [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage
},
}
+/// Contains data specific to an [`AsyncPaymentsMessage`].
+///
+/// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
+#[derive(Clone, Debug)]
+pub enum AsyncPaymentsContext {
+ /// Context contained within the reply [`BlindedMessagePath`] we put in outbound
+ /// [`HeldHtlcAvailable`] messages, provided back to us in corresponding [`ReleaseHeldHtlc`]
+ /// messages.
+ ///
+ /// [`HeldHtlcAvailable`]: crate::onion_message::async_payments::HeldHtlcAvailable
+ /// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
+ OutboundPayment {
+ /// ID used when payment to the originating [`Offer`] was initiated. Useful for us to identify
+ /// which of our pending outbound payments should be released to its often-offline payee.
+ ///
+ /// [`Offer`]: crate::offers::offer::Offer
+ payment_id: PaymentId
+ },
+}
+
impl_writeable_tlv_based_enum!(MessageContext,
{0, Offers} => (),
{1, Custom} => (),
+ {2, AsyncPayments} => (),
);
impl_writeable_tlv_based_enum!(OffersContext,
},
);
+impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
+ (0, OutboundPayment) => {
+ (0, payment_id, required),
+ },
+);
+
/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.
pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
secp_ctx: &Secp256k1<T>, intermediate_nodes: &[MessageForwardNode],
(ParsedOnionMessageContents::Offers(_), Some(MessageContext::Offers(_))) => {
Ok(PeeledOnion::Receive(message, context, reply_path))
}
+ #[cfg(async_payments)]
+ (ParsedOnionMessageContents::AsyncPayments(_), Some(MessageContext::AsyncPayments(_))) => {
+ Ok(PeeledOnion::Receive(message, context, reply_path))
+ }
(ParsedOnionMessageContents::Custom(_), Some(MessageContext::Custom(_))) => {
Ok(PeeledOnion::Receive(message, context, reply_path))
}
let context = match context {
None => None,
Some(MessageContext::Offers(context)) => Some(context),
- Some(MessageContext::Custom(_)) => {
+ _ => {
debug_assert!(false, "Checked in peel_onion_message");
return
}
let context = match context {
None => None,
Some(MessageContext::Custom(data)) => Some(data),
- Some(MessageContext::Offers(_)) => {
+ _ => {
debug_assert!(false, "Checked in peel_onion_message");
return
}