Skip to content

Commit 2484c1a

Browse files
committed
Add no-export tags for lightning-invoice where we can't map to C
1 parent 3d3147f commit 2484c1a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ pub fn check_platform() {
151151
/// * `D`: exactly one `Description` or `DescriptionHash`
152152
/// * `H`: exactly one `PaymentHash`
153153
/// * `T`: the timestamp is set
154+
///
155+
/// (C-not exported) as we likely need to manually select one set of boolean type parameters.
154156
#[derive(Eq, PartialEq, Debug, Clone)]
155157
pub struct InvoiceBuilder<D: tb::Bool, H: tb::Bool, T: tb::Bool> {
156158
currency: Currency,
@@ -178,6 +180,9 @@ pub struct Invoice {
178180

179181
/// Represents the description of an invoice which has to be either a directly included string or
180182
/// a hash of a description provided out of band.
183+
///
184+
/// (C-not exported) As we don't have a good way to map the reference lifetimes making this
185+
/// practically impossible to use safely in languages like C.
181186
#[derive(Eq, PartialEq, Debug, Clone)]
182187
pub enum InvoiceDescription<'f> {
183188
/// Reference to the directly supplied description in the invoice
@@ -225,6 +230,8 @@ pub struct RawInvoice {
225230
}
226231

227232
/// Data of the `RawInvoice` that is encoded in the human readable part
233+
///
234+
/// (C-not exported) As we don't yet support Option<Enum>
228235
#[derive(Eq, PartialEq, Debug, Clone)]
229236
pub struct RawHrp {
230237
/// The currency deferred from the 3rd and 4th character of the bech32 transaction
@@ -283,6 +290,9 @@ impl SiPrefix {
283290

284291
/// Returns all enum variants of `SiPrefix` sorted in descending order of their associated
285292
/// multiplier.
293+
///
294+
/// (C-not exported) As we don't yet support a slice of enums, and also because this function
295+
/// isn't the most critical to expose.
286296
pub fn values_desc() -> &'static [SiPrefix] {
287297
use SiPrefix::*;
288298
static VALUES: [SiPrefix; 4] = [Milli, Micro, Nano, Pico];
@@ -760,6 +770,9 @@ impl RawInvoice {
760770
/// Signs the invoice using the supplied `sign_function`. This function MAY fail with an error
761771
/// of type `E`. Since the signature of a `SignedRawInvoice` is not required to be valid there
762772
/// are no constraints regarding the validity of the produced signature.
773+
///
774+
/// (C-not exported) As we don't currently support passing function pointers into methods
775+
/// explicitly.
763776
pub fn sign<F, E>(self, sign_method: F) -> Result<SignedRawInvoice, E>
764777
where F: FnOnce(&Message) -> Result<RecoverableSignature, E>
765778
{
@@ -776,6 +789,8 @@ impl RawInvoice {
776789
}
777790

778791
/// Returns an iterator over all tagged fields with known semantics.
792+
///
793+
/// (C-not exported) As there is not yet a manual mapping for a FilterMap
779794
pub fn known_tagged_fields(&self)
780795
-> FilterMap<Iter<RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>>
781796
{
@@ -824,6 +839,7 @@ impl RawInvoice {
824839
find_extract!(self.known_tagged_fields(), TaggedField::Features(ref x), x)
825840
}
826841

842+
/// (C-not exported) as we don't support Vec<&NonOpaqueType>
827843
pub fn fallbacks(&self) -> Vec<&Fallback> {
828844
self.known_tagged_fields().filter_map(|tf| match tf {
829845
&TaggedField::Fallback(ref f) => Some(f),
@@ -981,6 +997,8 @@ impl Invoice {
981997
}
982998

983999
/// Returns an iterator over all tagged fields of this Invoice.
1000+
///
1001+
/// (C-not exported) As there is not yet a manual mapping for a FilterMap
9841002
pub fn tagged_fields(&self)
9851003
-> FilterMap<Iter<RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>> {
9861004
self.signed_invoice.raw_invoice().known_tagged_fields()
@@ -992,6 +1010,8 @@ impl Invoice {
9921010
}
9931011

9941012
/// Return the description or a hash of it for longer ones
1013+
///
1014+
/// (C-not exported) because we don't yet export InvoiceDescription
9951015
pub fn description(&self) -> InvoiceDescription {
9961016
if let Some(ref direct) = self.signed_invoice.description() {
9971017
return InvoiceDescription::Direct(direct);
@@ -1034,6 +1054,8 @@ impl Invoice {
10341054
}
10351055

10361056
/// Returns a list of all fallback addresses
1057+
///
1058+
/// (C-not exported) as we don't support Vec<&NonOpaqueType>
10371059
pub fn fallbacks(&self) -> Vec<&Fallback> {
10381060
self.signed_invoice.fallbacks()
10391061
}
@@ -1277,6 +1299,8 @@ impl std::error::Error for SemanticError { }
12771299

12781300
/// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
12791301
/// may occur.
1302+
///
1303+
/// (C-not exported) As we don't support unbounded generics
12801304
#[derive(Eq, PartialEq, Debug, Clone)]
12811305
pub enum SignOrCreationError<S> {
12821306
/// An error occurred during signing

lightning/src/ln/features.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ impl<T: sealed::Context> Features<T> {
502502

503503
/// Create a Features given a set of flags, in little-endian. This is in reverse byte order from
504504
/// most on-the-wire encodings.
505+
/// (C-not exported) as we don't support export across multiple T
505506
pub fn from_le_bytes(flags: Vec<u8>) -> Features<T> {
506507
Features {
507508
flags,

0 commit comments

Comments
 (0)