From 28e16aedd21de3964dc15cb6fce31b908defc8bb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 25 Apr 2023 06:10:05 +0000 Subject: [PATCH] [bindings] Disable BOLT12 builders which require move semantics --- lightning/src/offers/invoice.rs | 12 ++++++++++++ lightning/src/offers/invoice_request.rs | 18 ++++++++++++++++++ lightning/src/offers/offer.rs | 14 ++++++++++++++ lightning/src/offers/parse.rs | 4 ++++ lightning/src/offers/refund.rs | 10 ++++++++++ 5 files changed, 58 insertions(+) diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 05b2b5d01..7dd2a99d1 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -134,6 +134,8 @@ pub(super) const SIGNATURE_TAG: &'static str = concat!("lightning", "invoice", " /// /// See [module-level documentation] for usage. /// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. +/// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest /// [`Refund`]: crate::offers::refund::Refund /// [module-level documentation]: self @@ -145,12 +147,18 @@ pub struct InvoiceBuilder<'a, S: SigningPubkeyStrategy> { } /// Indicates how [`Invoice::signing_pubkey`] was set. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub trait SigningPubkeyStrategy {} /// [`Invoice::signing_pubkey`] was explicitly set. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub struct ExplicitSigningPubkey {} /// [`Invoice::signing_pubkey`] was derived. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub struct DerivedSigningPubkey {} impl SigningPubkeyStrategy for ExplicitSigningPubkey {} @@ -369,6 +377,8 @@ impl<'a> UnsignedInvoice<'a> { } /// Signs the invoice using the given function. + /// + /// This is not exported to bindings users as functions aren't currently mapped. pub fn sign(self, sign: F) -> Result> where F: FnOnce(&Message) -> Result @@ -405,6 +415,8 @@ impl<'a> UnsignedInvoice<'a> { /// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent /// directly after scanning a refund. It includes all the information needed to pay a recipient. /// +/// This is not exported to bindings users as its name conflicts with the BOLT 11 Invoice type. +/// /// [`Offer`]: crate::offers::offer::Offer /// [`Refund`]: crate::offers::refund::Refund /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index e8aeb2c82..8d4755537 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -84,6 +84,8 @@ pub(super) const IV_BYTES: &[u8; IV_LEN] = b"LDK Invreq ~~~~~"; /// /// See [module-level documentation] for usage. /// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. +/// /// [module-level documentation]: self pub struct InvoiceRequestBuilder<'a, 'b, P: PayerIdStrategy, T: secp256k1::Signing> { offer: &'a Offer, @@ -94,12 +96,18 @@ pub struct InvoiceRequestBuilder<'a, 'b, P: PayerIdStrategy, T: secp256k1::Signi } /// Indicates how [`InvoiceRequest::payer_id`] will be set. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub trait PayerIdStrategy {} /// [`InvoiceRequest::payer_id`] will be explicitly set. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub struct ExplicitPayerId {} /// [`InvoiceRequest::payer_id`] will be derived. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub struct DerivedPayerId {} impl PayerIdStrategy for ExplicitPayerId {} @@ -340,6 +348,8 @@ pub struct UnsignedInvoiceRequest<'a> { impl<'a> UnsignedInvoiceRequest<'a> { /// Signs the invoice request using the given function. + /// + /// This is not exported to bindings users as functions are not yet mapped. pub fn sign(self, sign: F) -> Result> where F: FnOnce(&Message) -> Result @@ -465,6 +475,8 @@ impl InvoiceRequest { /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned /// creation time is used for the `created_at` parameter. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Duration`]: core::time::Duration #[cfg(feature = "std")] pub fn respond_with( @@ -493,6 +505,8 @@ impl InvoiceRequest { /// /// Errors if the request contains unknown required features. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Invoice::created_at`]: crate::offers::invoice::Invoice::created_at pub fn respond_with_no_std( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, @@ -511,6 +525,8 @@ impl InvoiceRequest { /// /// See [`InvoiceRequest::respond_with`] for further details. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Invoice`]: crate::offers::invoice::Invoice #[cfg(feature = "std")] pub fn verify_and_respond_using_derived_keys( @@ -532,6 +548,8 @@ impl InvoiceRequest { /// /// See [`InvoiceRequest::respond_with_no_std`] for further details. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Invoice`]: crate::offers::invoice::Invoice pub fn verify_and_respond_using_derived_keys_no_std( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index 887318c0c..ac16b6ef2 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -98,6 +98,8 @@ pub(super) const IV_BYTES: &[u8; IV_LEN] = b"LDK Offer ~~~~~~"; /// /// See [module-level documentation] for usage. /// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. +/// /// [module-level documentation]: self pub struct OfferBuilder<'a, M: MetadataStrategy, T: secp256k1::Signing> { offer: OfferContents, @@ -106,12 +108,18 @@ pub struct OfferBuilder<'a, M: MetadataStrategy, T: secp256k1::Signing> { } /// Indicates how [`Offer::metadata`] may be set. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub trait MetadataStrategy {} /// [`Offer::metadata`] may be explicitly set or left empty. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub struct ExplicitMetadata {} /// [`Offer::metadata`] will be derived. +/// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. pub struct DerivedMetadata {} impl MetadataStrategy for ExplicitMetadata {} @@ -448,6 +456,8 @@ impl Offer { /// /// Useful to protect the sender's privacy. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id /// [`InvoiceRequest::metadata`]: crate::offers::invoice_request::InvoiceRequest::metadata /// [`Invoice::verify`]: crate::offers::invoice::Invoice::verify @@ -470,6 +480,8 @@ impl Offer { /// /// Useful for recurring payments using the same `payer_id` with different invoices. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id pub fn request_invoice_deriving_metadata( &self, payer_id: PublicKey, expanded_key: &ExpandedKey, entropy_source: ES @@ -496,6 +508,8 @@ impl Offer { /// /// Errors if the offer contains unknown required features. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest pub fn request_invoice( &self, metadata: Vec, payer_id: PublicKey diff --git a/lightning/src/offers/parse.rs b/lightning/src/offers/parse.rs index 3f1a9c887..42ed2e002 100644 --- a/lightning/src/offers/parse.rs +++ b/lightning/src/offers/parse.rs @@ -116,6 +116,8 @@ impl TryFrom> for ParsedMessage { } /// Error when parsing a bech32 encoded message using [`str::parse`]. +/// +/// This is not exported to bindings users as its name conflicts with the BOLT 11 ParseError type. #[derive(Debug, PartialEq)] pub enum ParseError { /// The bech32 encoding does not conform to the BOLT 12 requirements for continuing messages @@ -135,6 +137,8 @@ pub enum ParseError { } /// Error when interpreting a TLV stream as a specific type. +/// +/// This is not exported to bindings users as its name conflicts with the BOLT 11 SemanticError type. #[derive(Debug, PartialEq)] pub enum SemanticError { /// The current [`std::time::SystemTime`] is past the offer or invoice's expiration. diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index d5d80198e..6cbdd2da2 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -105,6 +105,8 @@ pub(super) const IV_BYTES: &[u8; IV_LEN] = b"LDK Refund ~~~~~"; /// /// See [module-level documentation] for usage. /// +/// This is not exported to bindings users as builder patterns don't map outside of move semantics. +/// /// [module-level documentation]: self pub struct RefundBuilder<'a, T: secp256k1::Signing> { refund: RefundContents, @@ -387,6 +389,8 @@ impl Refund { /// See [`Refund::respond_with_no_std`] for further details where the aforementioned creation /// time is used for the `created_at` parameter. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Duration`]: core::time::Duration #[cfg(feature = "std")] pub fn respond_with( @@ -419,6 +423,8 @@ impl Refund { /// /// Errors if the request contains unknown required features. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Invoice::created_at`]: crate::offers::invoice::Invoice::created_at pub fn respond_with_no_std( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, @@ -436,6 +442,8 @@ impl Refund { /// /// See [`Refund::respond_with`] for further details. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Invoice`]: crate::offers::invoice::Invoice #[cfg(feature = "std")] pub fn respond_using_derived_keys( @@ -459,6 +467,8 @@ impl Refund { /// /// See [`Refund::respond_with_no_std`] for further details. /// + /// This is not exported to bindings users as builder patterns don't map outside of move semantics. + /// /// [`Invoice`]: crate::offers::invoice::Invoice pub fn respond_using_derived_keys_no_std( &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash, -- 2.39.5