19aef23363d8e0afc9a5ddd758d5808098d1d03f
[rust-lightning] / lightning / src / offers / payer.rs
1 // This file is Copyright its original authors, visible in version control
2 // history.
3 //
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
8 // licenses.
9
10 //! Data structures and encoding for `invoice_request_metadata` records.
11
12 use crate::offers::signer::Metadata;
13 use crate::util::ser::WithoutLength;
14
15 use crate::prelude::*;
16
17 /// An unpredictable sequence of bytes typically containing information needed to derive
18 /// [`InvoiceRequest::payer_id`].
19 ///
20 /// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id
21 #[derive(Clone, Debug)]
22 #[cfg_attr(test, derive(PartialEq))]
23 pub(super) struct PayerContents(pub Metadata);
24
25 /// TLV record type for [`InvoiceRequest::payer_metadata`] and [`Refund::payer_metadata`].
26 ///
27 /// [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata
28 /// [`Refund::payer_metadata`]: crate::offers::refund::Refund::payer_metadata
29 pub(super) const PAYER_METADATA_TYPE: u64 = 0;
30
31 tlv_stream!(PayerTlvStream, PayerTlvStreamRef, 0..1, {
32         (PAYER_METADATA_TYPE, metadata: (Vec<u8>, WithoutLength)),
33 });