]> git.bitcoin.ninja Git - rust-lightning/commitdiff
impl `Clone` on various public (mostly BOLT12) types
authorMatt Corallo <git@bluematt.me>
Mon, 13 May 2024 14:36:01 +0000 (14:36 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 14 May 2024 13:17:03 +0000 (13:17 +0000)
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
lightning/src/offers/invoice.rs
lightning/src/offers/invoice_request.rs
lightning/src/offers/offer.rs
lightning/src/offers/refund.rs

index 8293a32021e3285dd91a651274c2ca11b902552c..20a1e1dbb621f4a0c4ce68ed9f5a5e0df6aad278 100644 (file)
@@ -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,
index d99e647e9dd495422866b298f8bfe0e0cb9db250..ecb0c80061ba3851b3975373b099111f9eb4ebf0 100644 (file)
@@ -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<u8>,
        contents: InvoiceContents,
index 8b06ba9a5ed52f724413510a95f96c5291c95001..f243ea693f2f019be1e0dddf214a599751213e1a 100644 (file)
@@ -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<u8>,
        contents: InvoiceRequestContents,
index fc17ae48da16a641ee53932fdd2c9d32362c15e0..5a824b9162f283099fd3b9bd489212579b72f96b 100644 (file)
@@ -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<ExplicitMetadata>,
@@ -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<DerivedMetadata>,
index 6a1d24106e906a532f6eec749d4c509d441ad02d..1988a92aaa7450262f0a04d1c2ba00d8545beec3 100644 (file)
@@ -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<secp256k1::All>>,