X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Fchannelmanager.rs;fp=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Fchannelmanager.rs;h=b1dedd51c31ab4abdcddd058dbe9191d0c8865fe;hp=19642acfa3d2a6c0326c351ea3f4d4227e1f1bf7;hb=0ac4dbdb8352c898100b34f0ef8ed9cebfea7786;hpb=c16401631dddadcefa37b05074ca7def51b85af4 diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 19642ac..b1dedd5 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -25,6 +25,761 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +/// Information about where a received HTLC('s onion) has indicated the HTLC should go. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum PendingHTLCRouting { + /// An HTLC which should be forwarded on to another node. + Forward { + /// The onion which should be included in the forwarded HTLC, telling the next hop what to + /// do with the HTLC. + onion_packet: crate::lightning::ln::msgs::OnionPacket, + /// The short channel ID of the channel which we were instructed to forward this HTLC to. + /// + /// This could be a real on-chain SCID, an SCID alias, or some other SCID which has meaning + /// to the receiving node, such as one returned from + /// [`ChannelManager::get_intercept_scid`] or [`ChannelManager::get_phantom_scid`]. + short_channel_id: u64, + /// Set if this HTLC is being forwarded within a blinded path. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + blinded: crate::lightning::ln::channelmanager::BlindedForward, + }, + /// The onion indicates that this is a payment for an invoice (supposedly) generated by us. + /// + /// Note that at this point, we have not checked that the invoice being paid was actually + /// generated by us, but rather it's claiming to pay an invoice of ours. + Receive { + /// Information about the amount the sender intended to pay and (potential) proof that this + /// is a payment for an invoice we generated. This proof of payment is is also used for + /// linking MPP parts of a larger payment. + payment_data: crate::lightning::ln::msgs::FinalOnionHopData, + /// Additional data which we (allegedly) instructed the sender to include in the onion. + /// + /// For HTLCs received by LDK, this will ultimately be exposed in + /// [`Event::PaymentClaimable::onion_fields`] as + /// [`RecipientOnionFields::payment_metadata`]. + payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, + /// CLTV expiry of the received HTLC. + /// + /// Used to track when we should expire pending HTLCs that go unclaimed. + incoming_cltv_expiry: u32, + /// If the onion had forwarding instructions to one of our phantom node SCIDs, this will + /// provide the onion shared secret used to decrypt the next level of forwarding + /// instructions. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + phantom_shared_secret: crate::c_types::ThirtyTwoBytes, + /// Custom TLVs which were set by the sender. + /// + /// For HTLCs received by LDK, this will ultimately be exposed in + /// [`Event::PaymentClaimable::onion_fields`] as + /// [`RecipientOnionFields::custom_tlvs`]. + custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, + /// Set if this HTLC is the final hop in a multi-hop blinded path. + requires_blinded_error: bool, + }, + /// The onion indicates that this is for payment to us but which contains the preimage for + /// claiming included, and is unrelated to any invoice we'd previously generated (aka a + /// \"keysend\" or \"spontaneous\" payment). + ReceiveKeysend { + /// Information about the amount the sender intended to pay and possibly a token to + /// associate MPP parts of a larger payment. + /// + /// This will only be filled in if receiving MPP keysend payments is enabled, and it being + /// present will cause deserialization to fail on versions of LDK prior to 0.0.116. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + payment_data: crate::lightning::ln::msgs::FinalOnionHopData, + /// Preimage for this onion payment. This preimage is provided by the sender and will be + /// used to settle the spontaneous payment. + payment_preimage: crate::c_types::ThirtyTwoBytes, + /// Additional data which we (allegedly) instructed the sender to include in the onion. + /// + /// For HTLCs received by LDK, this will ultimately bubble back up as + /// [`RecipientOnionFields::payment_metadata`]. + payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, + /// CLTV expiry of the received HTLC. + /// + /// Used to track when we should expire pending HTLCs that go unclaimed. + incoming_cltv_expiry: u32, + /// Custom TLVs which were set by the sender. + /// + /// For HTLCs received by LDK, these will ultimately bubble back up as + /// [`RecipientOnionFields::custom_tlvs`]. + custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, + }, +} +use lightning::ln::channelmanager::PendingHTLCRouting as PendingHTLCRoutingImport; +pub(crate) type nativePendingHTLCRouting = PendingHTLCRoutingImport; + +impl PendingHTLCRouting { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePendingHTLCRouting { + match self { + PendingHTLCRouting::Forward {ref onion_packet, ref short_channel_id, ref blinded, } => { + let mut onion_packet_nonref = Clone::clone(onion_packet); + let mut short_channel_id_nonref = Clone::clone(short_channel_id); + let mut blinded_nonref = Clone::clone(blinded); + let mut local_blinded_nonref = if blinded_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(blinded_nonref.take_inner()) } }) }; + nativePendingHTLCRouting::Forward { + onion_packet: *unsafe { Box::from_raw(onion_packet_nonref.take_inner()) }, + short_channel_id: short_channel_id_nonref, + blinded: local_blinded_nonref, + } + }, + PendingHTLCRouting::Receive {ref payment_data, ref payment_metadata, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => { + let mut payment_data_nonref = Clone::clone(payment_data); + let mut payment_metadata_nonref = Clone::clone(payment_metadata); + let mut local_payment_metadata_nonref = { /*payment_metadata_nonref*/ let payment_metadata_nonref_opt = payment_metadata_nonref; if payment_metadata_nonref_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_nonref_0 = Vec::new(); for mut item in { payment_metadata_nonref_opt.take() }.into_rust().drain(..) { local_payment_metadata_nonref_0.push( { item }); }; local_payment_metadata_nonref_0 }})} }; + let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); + let mut phantom_shared_secret_nonref = Clone::clone(phantom_shared_secret); + let mut local_phantom_shared_secret_nonref = if phantom_shared_secret_nonref.data == [0; 32] { None } else { Some( { phantom_shared_secret_nonref.data }) }; + let mut custom_tlvs_nonref = Clone::clone(custom_tlvs); + let mut local_custom_tlvs_nonref = Vec::new(); for mut item in custom_tlvs_nonref.into_rust().drain(..) { local_custom_tlvs_nonref.push( { let (mut orig_custom_tlvs_nonref_0_0, mut orig_custom_tlvs_nonref_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_nonref_0_1 = Vec::new(); for mut item in orig_custom_tlvs_nonref_0_1.into_rust().drain(..) { local_orig_custom_tlvs_nonref_0_1.push( { item }); }; let mut local_custom_tlvs_nonref_0 = (orig_custom_tlvs_nonref_0_0, local_orig_custom_tlvs_nonref_0_1); local_custom_tlvs_nonref_0 }); }; + let mut requires_blinded_error_nonref = Clone::clone(requires_blinded_error); + nativePendingHTLCRouting::Receive { + payment_data: *unsafe { Box::from_raw(payment_data_nonref.take_inner()) }, + payment_metadata: local_payment_metadata_nonref, + incoming_cltv_expiry: incoming_cltv_expiry_nonref, + phantom_shared_secret: local_phantom_shared_secret_nonref, + custom_tlvs: local_custom_tlvs_nonref, + requires_blinded_error: requires_blinded_error_nonref, + } + }, + PendingHTLCRouting::ReceiveKeysend {ref payment_data, ref payment_preimage, ref payment_metadata, ref incoming_cltv_expiry, ref custom_tlvs, } => { + let mut payment_data_nonref = Clone::clone(payment_data); + let mut local_payment_data_nonref = if payment_data_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_data_nonref.take_inner()) } }) }; + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut payment_metadata_nonref = Clone::clone(payment_metadata); + let mut local_payment_metadata_nonref = { /*payment_metadata_nonref*/ let payment_metadata_nonref_opt = payment_metadata_nonref; if payment_metadata_nonref_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_nonref_0 = Vec::new(); for mut item in { payment_metadata_nonref_opt.take() }.into_rust().drain(..) { local_payment_metadata_nonref_0.push( { item }); }; local_payment_metadata_nonref_0 }})} }; + let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); + let mut custom_tlvs_nonref = Clone::clone(custom_tlvs); + let mut local_custom_tlvs_nonref = Vec::new(); for mut item in custom_tlvs_nonref.into_rust().drain(..) { local_custom_tlvs_nonref.push( { let (mut orig_custom_tlvs_nonref_0_0, mut orig_custom_tlvs_nonref_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_nonref_0_1 = Vec::new(); for mut item in orig_custom_tlvs_nonref_0_1.into_rust().drain(..) { local_orig_custom_tlvs_nonref_0_1.push( { item }); }; let mut local_custom_tlvs_nonref_0 = (orig_custom_tlvs_nonref_0_0, local_orig_custom_tlvs_nonref_0_1); local_custom_tlvs_nonref_0 }); }; + nativePendingHTLCRouting::ReceiveKeysend { + payment_data: local_payment_data_nonref, + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), + payment_metadata: local_payment_metadata_nonref, + incoming_cltv_expiry: incoming_cltv_expiry_nonref, + custom_tlvs: local_custom_tlvs_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePendingHTLCRouting { + match self { + PendingHTLCRouting::Forward {mut onion_packet, mut short_channel_id, mut blinded, } => { + let mut local_blinded = if blinded.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(blinded.take_inner()) } }) }; + nativePendingHTLCRouting::Forward { + onion_packet: *unsafe { Box::from_raw(onion_packet.take_inner()) }, + short_channel_id: short_channel_id, + blinded: local_blinded, + } + }, + PendingHTLCRouting::Receive {mut payment_data, mut payment_metadata, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => { + let mut local_payment_metadata = { /*payment_metadata*/ let payment_metadata_opt = payment_metadata; if payment_metadata_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_0 = Vec::new(); for mut item in { payment_metadata_opt.take() }.into_rust().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0 }})} }; + let mut local_phantom_shared_secret = if phantom_shared_secret.data == [0; 32] { None } else { Some( { phantom_shared_secret.data }) }; + let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.into_rust().drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.into_rust().drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1); local_custom_tlvs_0 }); }; + nativePendingHTLCRouting::Receive { + payment_data: *unsafe { Box::from_raw(payment_data.take_inner()) }, + payment_metadata: local_payment_metadata, + incoming_cltv_expiry: incoming_cltv_expiry, + phantom_shared_secret: local_phantom_shared_secret, + custom_tlvs: local_custom_tlvs, + requires_blinded_error: requires_blinded_error, + } + }, + PendingHTLCRouting::ReceiveKeysend {mut payment_data, mut payment_preimage, mut payment_metadata, mut incoming_cltv_expiry, mut custom_tlvs, } => { + let mut local_payment_data = if payment_data.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_data.take_inner()) } }) }; + let mut local_payment_metadata = { /*payment_metadata*/ let payment_metadata_opt = payment_metadata; if payment_metadata_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_0 = Vec::new(); for mut item in { payment_metadata_opt.take() }.into_rust().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0 }})} }; + let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.into_rust().drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.into_rust().drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1); local_custom_tlvs_0 }); }; + nativePendingHTLCRouting::ReceiveKeysend { + payment_data: local_payment_data, + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), + payment_metadata: local_payment_metadata, + incoming_cltv_expiry: incoming_cltv_expiry, + custom_tlvs: local_custom_tlvs, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &PendingHTLCRoutingImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativePendingHTLCRouting) }; + match native { + nativePendingHTLCRouting::Forward {ref onion_packet, ref short_channel_id, ref blinded, } => { + let mut onion_packet_nonref = Clone::clone(onion_packet); + let mut short_channel_id_nonref = Clone::clone(short_channel_id); + let mut blinded_nonref = Clone::clone(blinded); + let mut local_blinded_nonref = crate::lightning::ln::channelmanager::BlindedForward { inner: if blinded_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((blinded_nonref.unwrap())) } }, is_owned: true }; + PendingHTLCRouting::Forward { + onion_packet: crate::lightning::ln::msgs::OnionPacket { inner: ObjOps::heap_alloc(onion_packet_nonref), is_owned: true }, + short_channel_id: short_channel_id_nonref, + blinded: local_blinded_nonref, + } + }, + nativePendingHTLCRouting::Receive {ref payment_data, ref payment_metadata, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => { + let mut payment_data_nonref = Clone::clone(payment_data); + let mut payment_metadata_nonref = Clone::clone(payment_metadata); + let mut local_payment_metadata_nonref = if payment_metadata_nonref.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_nonref_0 = Vec::new(); for mut item in payment_metadata_nonref.unwrap().drain(..) { local_payment_metadata_nonref_0.push( { item }); }; local_payment_metadata_nonref_0.into() }) }; + let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); + let mut phantom_shared_secret_nonref = Clone::clone(phantom_shared_secret); + let mut local_phantom_shared_secret_nonref = if phantom_shared_secret_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (phantom_shared_secret_nonref.unwrap()) } } }; + let mut custom_tlvs_nonref = Clone::clone(custom_tlvs); + let mut local_custom_tlvs_nonref = Vec::new(); for mut item in custom_tlvs_nonref.drain(..) { local_custom_tlvs_nonref.push( { let (mut orig_custom_tlvs_nonref_0_0, mut orig_custom_tlvs_nonref_0_1) = item; let mut local_orig_custom_tlvs_nonref_0_1 = Vec::new(); for mut item in orig_custom_tlvs_nonref_0_1.drain(..) { local_orig_custom_tlvs_nonref_0_1.push( { item }); }; let mut local_custom_tlvs_nonref_0 = (orig_custom_tlvs_nonref_0_0, local_orig_custom_tlvs_nonref_0_1.into()).into(); local_custom_tlvs_nonref_0 }); }; + let mut requires_blinded_error_nonref = Clone::clone(requires_blinded_error); + PendingHTLCRouting::Receive { + payment_data: crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(payment_data_nonref), is_owned: true }, + payment_metadata: local_payment_metadata_nonref, + incoming_cltv_expiry: incoming_cltv_expiry_nonref, + phantom_shared_secret: local_phantom_shared_secret_nonref, + custom_tlvs: local_custom_tlvs_nonref.into(), + requires_blinded_error: requires_blinded_error_nonref, + } + }, + nativePendingHTLCRouting::ReceiveKeysend {ref payment_data, ref payment_preimage, ref payment_metadata, ref incoming_cltv_expiry, ref custom_tlvs, } => { + let mut payment_data_nonref = Clone::clone(payment_data); + let mut local_payment_data_nonref = crate::lightning::ln::msgs::FinalOnionHopData { inner: if payment_data_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((payment_data_nonref.unwrap())) } }, is_owned: true }; + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut payment_metadata_nonref = Clone::clone(payment_metadata); + let mut local_payment_metadata_nonref = if payment_metadata_nonref.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_nonref_0 = Vec::new(); for mut item in payment_metadata_nonref.unwrap().drain(..) { local_payment_metadata_nonref_0.push( { item }); }; local_payment_metadata_nonref_0.into() }) }; + let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); + let mut custom_tlvs_nonref = Clone::clone(custom_tlvs); + let mut local_custom_tlvs_nonref = Vec::new(); for mut item in custom_tlvs_nonref.drain(..) { local_custom_tlvs_nonref.push( { let (mut orig_custom_tlvs_nonref_0_0, mut orig_custom_tlvs_nonref_0_1) = item; let mut local_orig_custom_tlvs_nonref_0_1 = Vec::new(); for mut item in orig_custom_tlvs_nonref_0_1.drain(..) { local_orig_custom_tlvs_nonref_0_1.push( { item }); }; let mut local_custom_tlvs_nonref_0 = (orig_custom_tlvs_nonref_0_0, local_orig_custom_tlvs_nonref_0_1.into()).into(); local_custom_tlvs_nonref_0 }); }; + PendingHTLCRouting::ReceiveKeysend { + payment_data: local_payment_data_nonref, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, + payment_metadata: local_payment_metadata_nonref, + incoming_cltv_expiry: incoming_cltv_expiry_nonref, + custom_tlvs: local_custom_tlvs_nonref.into(), + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePendingHTLCRouting) -> Self { + match native { + nativePendingHTLCRouting::Forward {mut onion_packet, mut short_channel_id, mut blinded, } => { + let mut local_blinded = crate::lightning::ln::channelmanager::BlindedForward { inner: if blinded.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((blinded.unwrap())) } }, is_owned: true }; + PendingHTLCRouting::Forward { + onion_packet: crate::lightning::ln::msgs::OnionPacket { inner: ObjOps::heap_alloc(onion_packet), is_owned: true }, + short_channel_id: short_channel_id, + blinded: local_blinded, + } + }, + nativePendingHTLCRouting::Receive {mut payment_data, mut payment_metadata, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => { + let mut local_payment_metadata = if payment_metadata.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_0 = Vec::new(); for mut item in payment_metadata.unwrap().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0.into() }) }; + let mut local_phantom_shared_secret = if phantom_shared_secret.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (phantom_shared_secret.unwrap()) } } }; + let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item; let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1.into()).into(); local_custom_tlvs_0 }); }; + PendingHTLCRouting::Receive { + payment_data: crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(payment_data), is_owned: true }, + payment_metadata: local_payment_metadata, + incoming_cltv_expiry: incoming_cltv_expiry, + phantom_shared_secret: local_phantom_shared_secret, + custom_tlvs: local_custom_tlvs.into(), + requires_blinded_error: requires_blinded_error, + } + }, + nativePendingHTLCRouting::ReceiveKeysend {mut payment_data, mut payment_preimage, mut payment_metadata, mut incoming_cltv_expiry, mut custom_tlvs, } => { + let mut local_payment_data = crate::lightning::ln::msgs::FinalOnionHopData { inner: if payment_data.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((payment_data.unwrap())) } }, is_owned: true }; + let mut local_payment_metadata = if payment_metadata.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_0 = Vec::new(); for mut item in payment_metadata.unwrap().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0.into() }) }; + let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item; let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1.into()).into(); local_custom_tlvs_0 }); }; + PendingHTLCRouting::ReceiveKeysend { + payment_data: local_payment_data, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, + payment_metadata: local_payment_metadata, + incoming_cltv_expiry: incoming_cltv_expiry, + custom_tlvs: local_custom_tlvs.into(), + } + }, + } + } +} +/// Frees any resources used by the PendingHTLCRouting +#[no_mangle] +pub extern "C" fn PendingHTLCRouting_free(this_ptr: PendingHTLCRouting) { } +/// Creates a copy of the PendingHTLCRouting +#[no_mangle] +pub extern "C" fn PendingHTLCRouting_clone(orig: &PendingHTLCRouting) -> PendingHTLCRouting { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PendingHTLCRouting_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PendingHTLCRouting)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PendingHTLCRouting_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut PendingHTLCRouting) }; +} +#[no_mangle] +/// Utility method to constructs a new Forward-variant PendingHTLCRouting +pub extern "C" fn PendingHTLCRouting_forward(onion_packet: crate::lightning::ln::msgs::OnionPacket, short_channel_id: u64, blinded: crate::lightning::ln::channelmanager::BlindedForward) -> PendingHTLCRouting { + PendingHTLCRouting::Forward { + onion_packet, + short_channel_id, + blinded, + } +} +#[no_mangle] +/// Utility method to constructs a new Receive-variant PendingHTLCRouting +pub extern "C" fn PendingHTLCRouting_receive(payment_data: crate::lightning::ln::msgs::FinalOnionHopData, payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, incoming_cltv_expiry: u32, phantom_shared_secret: crate::c_types::ThirtyTwoBytes, custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, requires_blinded_error: bool) -> PendingHTLCRouting { + PendingHTLCRouting::Receive { + payment_data, + payment_metadata, + incoming_cltv_expiry, + phantom_shared_secret, + custom_tlvs, + requires_blinded_error, + } +} +#[no_mangle] +/// Utility method to constructs a new ReceiveKeysend-variant PendingHTLCRouting +pub extern "C" fn PendingHTLCRouting_receive_keysend(payment_data: crate::lightning::ln::msgs::FinalOnionHopData, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, incoming_cltv_expiry: u32, custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ) -> PendingHTLCRouting { + PendingHTLCRouting::ReceiveKeysend { + payment_data, + payment_preimage, + payment_metadata, + incoming_cltv_expiry, + custom_tlvs, + } +} + +use lightning::ln::channelmanager::BlindedForward as nativeBlindedForwardImport; +pub(crate) type nativeBlindedForward = nativeBlindedForwardImport; + +/// Information used to forward or fail this HTLC that is being forwarded within a blinded path. +#[must_use] +#[repr(C)] +pub struct BlindedForward { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBlindedForward, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for BlindedForward { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedForward>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedForward, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedForward_free(this_obj: BlindedForward) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedForward_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedForward) }; +} +#[allow(unused)] +impl BlindedForward { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedForward { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedForward { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBlindedForward { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound +/// onion payload if we're the introduction node. Useful for calculating the next hop's +/// [`msgs::UpdateAddHTLC::blinding_point`]. +#[no_mangle] +pub extern "C" fn BlindedForward_get_inbound_blinding_point(this_ptr: &BlindedForward) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_blinding_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound +/// onion payload if we're the introduction node. Useful for calculating the next hop's +/// [`msgs::UpdateAddHTLC::blinding_point`]. +#[no_mangle] +pub extern "C" fn BlindedForward_set_inbound_blinding_point(this_ptr: &mut BlindedForward, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_blinding_point = val.into_rust(); +} +/// If needed, this determines how this HTLC should be failed backwards, based on whether we are +/// the introduction node. +#[no_mangle] +pub extern "C" fn BlindedForward_get_failure(this_ptr: &BlindedForward) -> crate::lightning::ln::channelmanager::BlindedFailure { + let mut inner_val = &mut this_ptr.get_native_mut_ref().failure; + crate::lightning::ln::channelmanager::BlindedFailure::from_native(inner_val) +} +/// If needed, this determines how this HTLC should be failed backwards, based on whether we are +/// the introduction node. +#[no_mangle] +pub extern "C" fn BlindedForward_set_failure(this_ptr: &mut BlindedForward, mut val: crate::lightning::ln::channelmanager::BlindedFailure) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure = val.into_native(); +} +/// Constructs a new BlindedForward given each field +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedForward_new(mut inbound_blinding_point_arg: crate::c_types::PublicKey, mut failure_arg: crate::lightning::ln::channelmanager::BlindedFailure) -> BlindedForward { + BlindedForward { inner: ObjOps::heap_alloc(nativeBlindedForward { + inbound_blinding_point: inbound_blinding_point_arg.into_rust(), + failure: failure_arg.into_native(), + }), is_owned: true } +} +impl Clone for BlindedForward { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedForward>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedForward_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedForward)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedForward +pub extern "C" fn BlindedForward_clone(orig: &BlindedForward) -> BlindedForward { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedForward object +pub extern "C" fn BlindedForward_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::BlindedForward }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedForward. +#[no_mangle] +pub extern "C" fn BlindedForward_hash(o: &BlindedForward) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BlindedForwards contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn BlindedForward_eq(a: &BlindedForward, b: &BlindedForward) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::channelmanager::PendingHTLCInfo as nativePendingHTLCInfoImport; +pub(crate) type nativePendingHTLCInfo = nativePendingHTLCInfoImport; + +/// Information about an incoming HTLC, including the [`PendingHTLCRouting`] describing where it +/// should go next. +#[must_use] +#[repr(C)] +pub struct PendingHTLCInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePendingHTLCInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PendingHTLCInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePendingHTLCInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the PendingHTLCInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_free(this_obj: PendingHTLCInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PendingHTLCInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePendingHTLCInfo) }; +} +#[allow(unused)] +impl PendingHTLCInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativePendingHTLCInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePendingHTLCInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativePendingHTLCInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Further routing details based on whether the HTLC is being forwarded or received. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_routing(this_ptr: &PendingHTLCInfo) -> crate::lightning::ln::channelmanager::PendingHTLCRouting { + let mut inner_val = &mut this_ptr.get_native_mut_ref().routing; + crate::lightning::ln::channelmanager::PendingHTLCRouting::from_native(inner_val) +} +/// Further routing details based on whether the HTLC is being forwarded or received. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_routing(this_ptr: &mut PendingHTLCInfo, mut val: crate::lightning::ln::channelmanager::PendingHTLCRouting) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.routing = val.into_native(); +} +/// The onion shared secret we build with the sender used to decrypt the onion. +/// +/// This is later used to encrypt failure packets in the event that the HTLC is failed. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_incoming_shared_secret(this_ptr: &PendingHTLCInfo) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().incoming_shared_secret; + inner_val +} +/// The onion shared secret we build with the sender used to decrypt the onion. +/// +/// This is later used to encrypt failure packets in the event that the HTLC is failed. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_incoming_shared_secret(this_ptr: &mut PendingHTLCInfo, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.incoming_shared_secret = val.data; +} +/// Hash of the payment preimage, to lock the payment until the receiver releases the preimage. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_payment_hash(this_ptr: &PendingHTLCInfo) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash; + &inner_val.0 +} +/// Hash of the payment preimage, to lock the payment until the receiver releases the preimage. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_payment_hash(this_ptr: &mut PendingHTLCInfo, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data); +} +/// Amount received in the incoming HTLC. +/// +/// This field was added in LDK 0.0.113 and will be `None` for objects written by prior +/// versions. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_incoming_amt_msat(this_ptr: &PendingHTLCInfo) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().incoming_amt_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// Amount received in the incoming HTLC. +/// +/// This field was added in LDK 0.0.113 and will be `None` for objects written by prior +/// versions. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_incoming_amt_msat(this_ptr: &mut PendingHTLCInfo, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.incoming_amt_msat = local_val; +} +/// The amount the sender indicated should be forwarded on to the next hop or amount the sender +/// intended for us to receive for received payments. +/// +/// If the received amount is less than this for received payments, an intermediary hop has +/// attempted to steal some of our funds and we should fail the HTLC (the sender should retry +/// it along another path). +/// +/// Because nodes can take less than their required fees, and because senders may wish to +/// improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for +/// received payments. In such cases, recipients must handle this HTLC as if it had received +/// [`Self::outgoing_amt_msat`]. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_outgoing_amt_msat(this_ptr: &PendingHTLCInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outgoing_amt_msat; + *inner_val +} +/// The amount the sender indicated should be forwarded on to the next hop or amount the sender +/// intended for us to receive for received payments. +/// +/// If the received amount is less than this for received payments, an intermediary hop has +/// attempted to steal some of our funds and we should fail the HTLC (the sender should retry +/// it along another path). +/// +/// Because nodes can take less than their required fees, and because senders may wish to +/// improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for +/// received payments. In such cases, recipients must handle this HTLC as if it had received +/// [`Self::outgoing_amt_msat`]. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_outgoing_amt_msat(this_ptr: &mut PendingHTLCInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outgoing_amt_msat = val; +} +/// The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated +/// should have been set on the received HTLC for received payments). +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_outgoing_cltv_value(this_ptr: &PendingHTLCInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outgoing_cltv_value; + *inner_val +} +/// The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated +/// should have been set on the received HTLC for received payments). +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_outgoing_cltv_value(this_ptr: &mut PendingHTLCInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outgoing_cltv_value = val; +} +/// The fee taken for this HTLC in addition to the standard protocol HTLC fees. +/// +/// If this is a payment for forwarding, this is the fee we are taking before forwarding the +/// HTLC. +/// +/// If this is a received payment, this is the fee that our counterparty took. +/// +/// This is used to allow LSPs to take fees as a part of payments, without the sender having to +/// shoulder them. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_get_skimmed_fee_msat(this_ptr: &PendingHTLCInfo) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The fee taken for this HTLC in addition to the standard protocol HTLC fees. +/// +/// If this is a payment for forwarding, this is the fee we are taking before forwarding the +/// HTLC. +/// +/// If this is a received payment, this is the fee that our counterparty took. +/// +/// This is used to allow LSPs to take fees as a part of payments, without the sender having to +/// shoulder them. +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_set_skimmed_fee_msat(this_ptr: &mut PendingHTLCInfo, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val; +} +/// Constructs a new PendingHTLCInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn PendingHTLCInfo_new(mut routing_arg: crate::lightning::ln::channelmanager::PendingHTLCRouting, mut incoming_shared_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut incoming_amt_msat_arg: crate::c_types::derived::COption_u64Z, mut outgoing_amt_msat_arg: u64, mut outgoing_cltv_value_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z) -> PendingHTLCInfo { + let mut local_incoming_amt_msat_arg = if incoming_amt_msat_arg.is_some() { Some( { incoming_amt_msat_arg.take() }) } else { None }; + let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None }; + PendingHTLCInfo { inner: ObjOps::heap_alloc(nativePendingHTLCInfo { + routing: routing_arg.into_native(), + incoming_shared_secret: incoming_shared_secret_arg.data, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_arg.data), + incoming_amt_msat: local_incoming_amt_msat_arg, + outgoing_amt_msat: outgoing_amt_msat_arg, + outgoing_cltv_value: outgoing_cltv_value_arg, + skimmed_fee_msat: local_skimmed_fee_msat_arg, + }), is_owned: true } +} +impl Clone for PendingHTLCInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePendingHTLCInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PendingHTLCInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePendingHTLCInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the PendingHTLCInfo +pub extern "C" fn PendingHTLCInfo_clone(orig: &PendingHTLCInfo) -> PendingHTLCInfo { + orig.clone() +} +/// Whether this blinded HTLC is being failed backwards by the introduction node or a blinded node, +/// which determines the failure message that should be used. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum BlindedFailure { + /// This HTLC is being failed backwards by the introduction node, and thus should be failed with + /// [`msgs::UpdateFailHTLC`] and error code `0x8000|0x4000|24`. + FromIntroductionNode, + /// This HTLC is being failed backwards by a blinded node within the path, and thus should be + /// failed with [`msgs::UpdateFailMalformedHTLC`] and error code `0x8000|0x4000|24`. + FromBlindedNode, +} +use lightning::ln::channelmanager::BlindedFailure as BlindedFailureImport; +pub(crate) type nativeBlindedFailure = BlindedFailureImport; + +impl BlindedFailure { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBlindedFailure { + match self { + BlindedFailure::FromIntroductionNode => nativeBlindedFailure::FromIntroductionNode, + BlindedFailure::FromBlindedNode => nativeBlindedFailure::FromBlindedNode, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBlindedFailure { + match self { + BlindedFailure::FromIntroductionNode => nativeBlindedFailure::FromIntroductionNode, + BlindedFailure::FromBlindedNode => nativeBlindedFailure::FromBlindedNode, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &BlindedFailureImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBlindedFailure) }; + match native { + nativeBlindedFailure::FromIntroductionNode => BlindedFailure::FromIntroductionNode, + nativeBlindedFailure::FromBlindedNode => BlindedFailure::FromBlindedNode, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBlindedFailure) -> Self { + match native { + nativeBlindedFailure::FromIntroductionNode => BlindedFailure::FromIntroductionNode, + nativeBlindedFailure::FromBlindedNode => BlindedFailure::FromBlindedNode, + } + } +} +/// Creates a copy of the BlindedFailure +#[no_mangle] +pub extern "C" fn BlindedFailure_clone(orig: &BlindedFailure) -> BlindedFailure { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedFailure_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const BlindedFailure)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedFailure_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut BlindedFailure) }; +} +#[no_mangle] +/// Utility method to constructs a new FromIntroductionNode-variant BlindedFailure +pub extern "C" fn BlindedFailure_from_introduction_node() -> BlindedFailure { + BlindedFailure::FromIntroductionNode} +#[no_mangle] +/// Utility method to constructs a new FromBlindedNode-variant BlindedFailure +pub extern "C" fn BlindedFailure_from_blinded_node() -> BlindedFailure { + BlindedFailure::FromBlindedNode} +/// Get a string which allows debug introspection of a BlindedFailure object +pub extern "C" fn BlindedFailure_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::BlindedFailure }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedFailure. +#[no_mangle] +pub extern "C" fn BlindedFailure_hash(o: &BlindedFailure) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BlindedFailures contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn BlindedFailure_eq(a: &BlindedFailure, b: &BlindedFailure) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// This enum is used to specify which error data to send to peers when failing back an HTLC /// using [`ChannelManager::fail_htlc_backwards_with_reason`]. /// @@ -86,7 +841,8 @@ impl FailureCode { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeFailureCode) -> Self { + pub(crate) fn from_native(native: &FailureCodeImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeFailureCode) }; match native { nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure, nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing, @@ -504,6 +1260,9 @@ pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo { orig.clone() } +/// Get a string which allows debug introspection of a CounterpartyForwardingInfo object +pub extern "C" fn CounterpartyForwardingInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::CounterpartyForwardingInfo }).into()} use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport; pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport; @@ -691,6 +1450,9 @@ pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty { orig.clone() } +/// Get a string which allows debug introspection of a ChannelCounterparty object +pub extern "C" fn ChannelCounterparty_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelCounterparty }).into()} use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport; pub(crate) type nativeChannelDetails = nativeChannelDetailsImport; @@ -1398,6 +2160,9 @@ pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> * pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails { orig.clone() } +/// Get a string which allows debug introspection of a ChannelDetails object +pub extern "C" fn ChannelDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelDetails }).into()} /// Gets the current SCID which should be used to identify this channel for inbound payments. /// This should be used for providing invoice hints or in any other context where our /// counterparty will forward a payment to us. @@ -1474,7 +2239,8 @@ impl ChannelShutdownState { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeChannelShutdownState) -> Self { + pub(crate) fn from_native(native: &ChannelShutdownStateImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeChannelShutdownState) }; match native { nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, @@ -1529,6 +2295,9 @@ pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutd /// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState { ChannelShutdownState::ShutdownComplete} +/// Get a string which allows debug introspection of a ChannelShutdownState object +pub extern "C" fn ChannelShutdownState_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelShutdownState }).into()} /// Checks if two ChannelShutdownStates contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -1654,7 +2423,8 @@ impl RecentPaymentDetails { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeRecentPaymentDetails) -> Self { + pub(crate) fn from_native(native: &RecentPaymentDetailsImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeRecentPaymentDetails) }; match native { nativeRecentPaymentDetails::AwaitingInvoice {ref payment_id, } => { let mut payment_id_nonref = Clone::clone(payment_id); @@ -1772,6 +2542,9 @@ pub extern "C" fn RecentPaymentDetails_abandoned(payment_id: crate::c_types::Thi payment_hash, } } +/// Get a string which allows debug introspection of a RecentPaymentDetails object +pub extern "C" fn RecentPaymentDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::RecentPaymentDetails }).into()} use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport; pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport; @@ -1943,6 +2716,9 @@ pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &cr /// connection is available, the outbound `open_channel` message may fail to send, resulting in /// the channel eventually being silently forgotten (dropped on reload). /// +/// If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the +/// channel. Otherwise, a random one will be generated for you. +/// /// Returns the new Channel's temporary `channel_id`. This ID will appear as /// [`Event::FundingGenerationReady::temporary_channel_id`] and in /// [`ChannelDetails::channel_id`] until after @@ -1957,9 +2733,10 @@ pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &cr /// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_channel_id: crate::c_types::U128, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult_ThirtyTwoBytesAPIErrorZ { +pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_channel_id: crate::c_types::U128, mut temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult_ThirtyTwoBytesAPIErrorZ { + let mut local_temporary_channel_id = { /*temporary_channel_id*/ let temporary_channel_id_opt = temporary_channel_id; if temporary_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ temporary_channel_id_opt.take() }.data) }})} }; let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_channel_id.into(), local_override_config); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_channel_id.into(), local_temporary_channel_id, local_override_config); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -2354,7 +3131,7 @@ pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate: /// Return values are identical to [`Self::funding_transaction_generated`], respective to /// each individual channel and transaction output. /// -/// Do NOT broadcast the funding transaction yourself. This batch funding transcaction +/// Do NOT broadcast the funding transaction yourself. This batch funding transaction /// will only be broadcast when we have safely received and persisted the counterparty's /// signature for each channel. /// @@ -2679,8 +3456,11 @@ pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf( /// /// # Errors /// -/// Errors if a duplicate `payment_id` is provided given the caveats in the aforementioned link -/// or if the provided parameters are invalid for the offer. +/// Errors if: +/// - a duplicate `payment_id` is provided given the caveats in the aforementioned link, +/// - the provided parameters are invalid for the offer, +/// - the parameterized [`Router`] is unable to create a blinded reply path for the invoice +/// request. /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest /// [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity @@ -2715,6 +3495,11 @@ pub extern "C" fn ChannelManager_pay_for_offer(this_arg: &crate::lightning::ln:: /// node meeting the aforementioned criteria, but there's no guarantee that they will be /// received and no retries will be made. /// +/// # Errors +/// +/// Errors if the parameterized [`Router`] is unable to create a blinded payment path or reply +/// path for the invoice. +/// /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[no_mangle] @@ -2999,9 +3784,9 @@ extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] -extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ { +extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_2.unwrap().as_ref() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0.as_ref() }, orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); }; local_ret.into() } @@ -3099,6 +3884,10 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana handle_channel_ready: ChannelManager_ChannelMessageHandler_handle_channel_ready, handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed, + handle_stfu: ChannelManager_ChannelMessageHandler_handle_stfu, + handle_splice: ChannelManager_ChannelMessageHandler_handle_splice, + handle_splice_ack: ChannelManager_ChannelMessageHandler_handle_splice_ack, + handle_splice_locked: ChannelManager_ChannelMessageHandler_handle_splice_locked, handle_tx_add_input: ChannelManager_ChannelMessageHandler_handle_tx_add_input, handle_tx_add_output: ChannelManager_ChannelMessageHandler_handle_tx_add_output, handle_tx_remove_input: ChannelManager_ChannelMessageHandler_handle_tx_remove_input, @@ -3159,6 +3948,18 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *co extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_stfu(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu) { + >::handle_stfu(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_splice(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Splice) { + >::handle_splice(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_splice_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceAck) { + >::handle_splice_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_splice_locked(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceLocked) { + >::handle_splice_locked(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -3241,7 +4042,7 @@ extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_a #[must_use] extern "C" fn ChannelManager_ChannelMessageHandler_get_chain_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ { let mut ret = >::get_chain_hashes(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_ret_0.into() }) }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) }; local_ret } @@ -3353,6 +4154,70 @@ pub extern "C" fn PhantomRouteHints_read(ser: crate::c_types::u8slice) -> crate: local_res } #[no_mangle] +/// Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read +pub extern "C" fn BlindedForward_write(obj: &crate::lightning::ln::channelmanager::BlindedForward) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn BlindedForward_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedForward) }) +} +#[no_mangle] +/// Read a BlindedForward from a byte array, created by BlindedForward_write +pub extern "C" fn BlindedForward_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedForwardDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::BlindedForward { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the PendingHTLCRouting object into a byte array which can be read by PendingHTLCRouting_read +pub extern "C" fn PendingHTLCRouting_write(obj: &crate::lightning::ln::channelmanager::PendingHTLCRouting) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn PendingHTLCRouting_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + PendingHTLCRouting_write(unsafe { &*(obj as *const PendingHTLCRouting) }) +} +#[no_mangle] +/// Read a PendingHTLCRouting from a byte array, created by PendingHTLCRouting_write +pub extern "C" fn PendingHTLCRouting_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PendingHTLCRoutingDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::PendingHTLCRouting::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read +pub extern "C" fn PendingHTLCInfo_write(obj: &crate::lightning::ln::channelmanager::PendingHTLCInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn PendingHTLCInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePendingHTLCInfo) }) +} +#[no_mangle] +/// Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write +pub extern "C" fn PendingHTLCInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PendingHTLCInfoDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::PendingHTLCInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the BlindedFailure object into a byte array which can be read by BlindedFailure_read +pub extern "C" fn BlindedFailure_write(obj: &crate::lightning::ln::channelmanager::BlindedFailure) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn BlindedFailure_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + BlindedFailure_write(unsafe { &*(obj as *const BlindedFailure) }) +} +#[no_mangle] +/// Read a BlindedFailure from a byte array, created by BlindedFailure_write +pub extern "C" fn BlindedFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedFailureDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::BlindedFailure::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) @@ -3604,6 +4469,6 @@ pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightnin pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::lightning::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) }; let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_res_0_0.as_ref() }, crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res }