X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fblinded_path%2Fpayment.rs;h=99979ecf4a37140ef5f7375fdc2c0cc67e0eaa7b;hb=48d9245f199e58449bb4f7d0eeb314fa5aca104e;hp=39f7c7f11088c51bdb5a55393084274d96631820;hpb=ac6d4cb9ad45189e963bd906e9da971502dff129;p=rust-lightning diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index 39f7c7f1..99979ecf 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -12,6 +12,7 @@ use crate::ln::channelmanager::CounterpartyForwardingInfo; use crate::ln::features::BlindedHopFeatures; use crate::ln::msgs::DecodeError; use crate::offers::invoice::BlindedPayInfo; +use crate::offers::offer::OfferId; use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, Writeable, Writer}; #[allow(unused_imports)] @@ -108,12 +109,28 @@ pub struct PaymentConstraints { pub enum PaymentContext { /// The payment context was unknown. Unknown(UnknownPaymentContext), + + /// The payment was made for an invoice requested from a BOLT 12 [`Offer`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + Bolt12Offer(Bolt12OfferContext), } /// An unknown payment context. #[derive(Clone, Debug, Eq, PartialEq)] pub struct UnknownPaymentContext(()); +/// The context of a payment made for an invoice requested from a BOLT 12 [`Offer`]. +/// +/// [`Offer`]: crate::offers::offer::Offer +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Bolt12OfferContext { + /// The identifier of the [`Offer`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + pub offer_id: OfferId, +} + impl PaymentContext { pub(crate) fn unknown() -> Self { PaymentContext::Unknown(UnknownPaymentContext(())) @@ -340,6 +357,7 @@ impl Readable for PaymentConstraints { impl_writeable_tlv_based_enum!(PaymentContext, ; (0, Unknown), + (1, Bolt12Offer), ); impl Writeable for UnknownPaymentContext { @@ -354,6 +372,10 @@ impl Readable for UnknownPaymentContext { } } +impl_writeable_tlv_based!(Bolt12OfferContext, { + (0, offer_id, required), +}); + #[cfg(test)] mod tests { use bitcoin::secp256k1::PublicKey;