From c13b6d814bfb5dd95f9e40f8ff07dd45c47a387e Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Mon, 25 Mar 2024 14:04:57 +0100 Subject: [PATCH] Implement `Readable` for `Offer` When storing `Offer`s, it's useful for them to implement LDK's deserialization trait. --- lightning/src/offers/offer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index 762bc1f33..db910b5e1 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -966,6 +966,13 @@ impl OfferContents { } } +impl Readable for Offer { + fn read(reader: &mut R) -> Result { + let bytes: WithoutLength> = Readable::read(reader)?; + Self::try_from(bytes.0).map_err(|_| DecodeError::InvalidValue) + } +} + impl Writeable for Offer { fn write(&self, writer: &mut W) -> Result<(), io::Error> { WithoutLength(&self.bytes).write(writer) -- 2.39.5