Blinded payments to unannounced introduction node
[rust-lightning] / lightning / src / offers / invoice.rs
index 6695121b34631b32b0b9f5e9fa3cd7b138134461..3f96e703b2a6dcae21bef4019070c4f792da24ce 100644 (file)
@@ -124,7 +124,7 @@ use crate::offers::parse::{Bolt12ParseError, Bolt12SemanticError, ParsedMessage}
 use crate::offers::payer::{PAYER_METADATA_TYPE, PayerTlvStream, PayerTlvStreamRef};
 use crate::offers::refund::{IV_BYTES as REFUND_IV_BYTES, Refund, RefundContents};
 use crate::offers::signer;
-use crate::util::ser::{HighZeroBytesDroppedBigSize, Iterable, SeekReadable, WithoutLength, Writeable, Writer};
+use crate::util::ser::{HighZeroBytesDroppedBigSize, Iterable, Readable, SeekReadable, WithoutLength, Writeable, Writer};
 use crate::util::string::PrintableString;
 
 #[allow(unused_imports)]
@@ -1119,6 +1119,13 @@ impl Writeable for Bolt12Invoice {
        }
 }
 
+impl Readable for Bolt12Invoice {
+       fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+               let bytes: WithoutLength<Vec<u8>> = Readable::read(reader)?;
+               Self::try_from(bytes.0).map_err(|_| DecodeError::InvalidValue)
+       }
+}
+
 impl Writeable for InvoiceContents {
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
                self.as_tlv_stream().write(writer)