- /// The TLV record type for the message as used in an `onionmsg_tlv` TLV stream.
- pub fn tlv_type(&self) -> u64 {
+ fn parse(tlv_type: u64, bytes: Vec<u8>) -> Result<Self, Bolt12ParseError> {
+ match tlv_type {
+ INVOICE_REQUEST_TLV_TYPE => Ok(Self::InvoiceRequest(InvoiceRequest::try_from(bytes)?)),
+ INVOICE_TLV_TYPE => Ok(Self::Invoice(Bolt12Invoice::try_from(bytes)?)),
+ _ => Err(Bolt12ParseError::Decode(DecodeError::InvalidValue)),
+ }
+ }
+}
+
+impl OnionMessageContents for OffersMessage {
+ fn tlv_type(&self) -> u64 {