From bccddcaabdca983bcfe8807d794458454fb350fc Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 13 May 2024 14:36:01 +0000 Subject: [PATCH] impl `Clone` on various public (mostly BOLT12) types This is required for bindings as passing types from Rust to GC'd languages can't map the concept of a type that has a lifetime of the called function but instead needs to clone for safety. --- lightning/src/ln/onion_payment.rs | 2 +- lightning/src/offers/invoice.rs | 1 + lightning/src/offers/invoice_request.rs | 1 + lightning/src/offers/offer.rs | 2 ++ lightning/src/offers/refund.rs | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/onion_payment.rs b/lightning/src/ln/onion_payment.rs index 8293a3202..20a1e1dbb 100644 --- a/lightning/src/ln/onion_payment.rs +++ b/lightning/src/ln/onion_payment.rs @@ -26,7 +26,7 @@ use crate::prelude::*; use core::ops::Deref; /// Invalid inbound onion payment. -#[derive(Debug)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct InboundHTLCErr { /// BOLT 4 error code. pub err_code: u16, diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index d99e647e9..ecb0c8006 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -503,6 +503,7 @@ for InvoiceBuilder<'a, DerivedSigningPubkey> { /// /// This is serialized as a TLV stream, which includes TLV records from the originating message. As /// such, it may include unknown, odd TLV records. +#[derive(Clone)] pub struct UnsignedBolt12Invoice { bytes: Vec, contents: InvoiceContents, diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index 8b06ba9a5..f243ea693 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -487,6 +487,7 @@ for InvoiceRequestBuilder<'a, 'b, DerivedPayerId, secp256k1::All> { /// /// This is serialized as a TLV stream, which includes TLV records from the originating message. As /// such, it may include unknown, odd TLV records. +#[derive(Clone)] pub struct UnsignedInvoiceRequest { bytes: Vec, contents: InvoiceRequestContents, diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index fc17ae48d..5a824b916 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -165,6 +165,7 @@ pub struct OfferBuilder<'a, M: MetadataStrategy, T: secp256k1::Signing> { /// /// [module-level documentation]: self #[cfg(c_bindings)] +#[derive(Clone)] pub struct OfferWithExplicitMetadataBuilder<'a> { offer: OfferContents, metadata_strategy: core::marker::PhantomData, @@ -177,6 +178,7 @@ pub struct OfferWithExplicitMetadataBuilder<'a> { /// /// [module-level documentation]: self #[cfg(c_bindings)] +#[derive(Clone)] pub struct OfferWithDerivedMetadataBuilder<'a> { offer: OfferContents, metadata_strategy: core::marker::PhantomData, diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index 6a1d24106..1988a92aa 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -141,6 +141,7 @@ pub struct RefundBuilder<'a, T: secp256k1::Signing> { /// /// [module-level documentation]: self #[cfg(c_bindings)] +#[derive(Clone)] pub struct RefundMaybeWithDerivedMetadataBuilder<'a> { refund: RefundContents, secp_ctx: Option<&'a Secp256k1>, -- 2.39.5