Add no-export tags for lightning-invoice where we can't map to C
authorMatt Corallo <git@bluematt.me>
Fri, 16 Apr 2021 22:32:49 +0000 (22:32 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 29 Apr 2021 15:48:16 +0000 (15:48 +0000)
lightning-invoice/src/lib.rs
lightning/src/ln/features.rs

index 086169ed7cbaed743b4e5735881b894cad07dc74..b33b1b374d85b1bea79e5d38a984b7be36e8b0d0 100644 (file)
@@ -151,6 +151,8 @@ pub fn check_platform() {
 ///  * `D`: exactly one `Description` or `DescriptionHash`
 ///  * `H`: exactly one `PaymentHash`
 ///  * `T`: the timestamp is set
+///
+/// (C-not exported) as we likely need to manually select one set of boolean type parameters.
 #[derive(Eq, PartialEq, Debug, Clone)]
 pub struct InvoiceBuilder<D: tb::Bool, H: tb::Bool, T: tb::Bool> {
        currency: Currency,
@@ -178,6 +180,9 @@ pub struct Invoice {
 
 /// Represents the description of an invoice which has to be either a directly included string or
 /// a hash of a description provided out of band.
+///
+/// (C-not exported) As we don't have a good way to map the reference lifetimes making this
+/// practically impossible to use safely in languages like C.
 #[derive(Eq, PartialEq, Debug, Clone)]
 pub enum InvoiceDescription<'f> {
        /// Reference to the directly supplied description in the invoice
@@ -225,6 +230,8 @@ pub struct RawInvoice {
 }
 
 /// Data of the `RawInvoice` that is encoded in the human readable part
+///
+/// (C-not exported) As we don't yet support Option<Enum>
 #[derive(Eq, PartialEq, Debug, Clone)]
 pub struct RawHrp {
        /// The currency deferred from the 3rd and 4th character of the bech32 transaction
@@ -283,6 +290,9 @@ impl SiPrefix {
 
        /// Returns all enum variants of `SiPrefix` sorted in descending order of their associated
        /// multiplier.
+       ///
+       /// (C-not exported) As we don't yet support a slice of enums, and also because this function
+       /// isn't the most critical to expose.
        pub fn values_desc() -> &'static [SiPrefix] {
                use SiPrefix::*;
                static VALUES: [SiPrefix; 4] = [Milli, Micro, Nano, Pico];
@@ -760,6 +770,9 @@ impl RawInvoice {
        /// Signs the invoice using the supplied `sign_function`. This function MAY fail with an error
        /// of type `E`. Since the signature of a `SignedRawInvoice` is not required to be valid there
        /// are no constraints regarding the validity of the produced signature.
+       ///
+       /// (C-not exported) As we don't currently support passing function pointers into methods
+       /// explicitly.
        pub fn sign<F, E>(self, sign_method: F) -> Result<SignedRawInvoice, E>
                where F: FnOnce(&Message) -> Result<RecoverableSignature, E>
        {
@@ -776,6 +789,8 @@ impl RawInvoice {
        }
 
        /// Returns an iterator over all tagged fields with known semantics.
+       ///
+       /// (C-not exported) As there is not yet a manual mapping for a FilterMap
        pub fn known_tagged_fields(&self)
                -> FilterMap<Iter<RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>>
        {
@@ -824,6 +839,7 @@ impl RawInvoice {
                find_extract!(self.known_tagged_fields(), TaggedField::Features(ref x), x)
        }
 
+       /// (C-not exported) as we don't support Vec<&NonOpaqueType>
        pub fn fallbacks(&self) -> Vec<&Fallback> {
                self.known_tagged_fields().filter_map(|tf| match tf {
                        &TaggedField::Fallback(ref f) => Some(f),
@@ -981,6 +997,8 @@ impl Invoice {
        }
 
        /// Returns an iterator over all tagged fields of this Invoice.
+       ///
+       /// (C-not exported) As there is not yet a manual mapping for a FilterMap
        pub fn tagged_fields(&self)
                -> FilterMap<Iter<RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>> {
                self.signed_invoice.raw_invoice().known_tagged_fields()
@@ -992,6 +1010,8 @@ impl Invoice {
        }
 
        /// Return the description or a hash of it for longer ones
+       ///
+       /// (C-not exported) because we don't yet export InvoiceDescription
        pub fn description(&self) -> InvoiceDescription {
                if let Some(ref direct) = self.signed_invoice.description() {
                        return InvoiceDescription::Direct(direct);
@@ -1034,6 +1054,8 @@ impl Invoice {
        }
 
        /// Returns a list of all fallback addresses
+       ///
+       /// (C-not exported) as we don't support Vec<&NonOpaqueType>
        pub fn fallbacks(&self) -> Vec<&Fallback> {
                self.signed_invoice.fallbacks()
        }
@@ -1277,6 +1299,8 @@ impl std::error::Error for SemanticError { }
 
 /// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
 /// may occur.
+///
+/// (C-not exported) As we don't support unbounded generics
 #[derive(Eq, PartialEq, Debug, Clone)]
 pub enum SignOrCreationError<S> {
        /// An error occurred during signing
index dd6ac3307f88d1c14a97a7874e1de2556d87696b..02e403b46d9708100f2b86bb0d3346922a9235a6 100644 (file)
@@ -502,6 +502,7 @@ impl<T: sealed::Context> Features<T> {
 
        /// Create a Features given a set of flags, in little-endian. This is in reverse byte order from
        /// most on-the-wire encodings.
+       /// (C-not exported) as we don't support export across multiple T
        pub fn from_le_bytes(flags: Vec<u8>) -> Features<T> {
                Features {
                        flags,