0ff12a5b35d9b8d633daf306e7691e80a1d2e23f
[ldk-c-bindings] / lightning-c-bindings / src / lightning / events / bump_transaction.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Utilities for bumping transactions originating from [`Event`]s.
10 //!
11 //! [`Event`]: crate::events::Event
12
13 use alloc::str::FromStr;
14 use core::ffi::c_void;
15 use core::convert::Infallible;
16 use bitcoin::hashes::Hash;
17 use crate::c_types::*;
18 #[cfg(feature="no-std")]
19 use alloc::{vec::Vec, boxed::Box};
20
21
22 use lightning::events::bump_transaction::ChannelDerivationParameters as nativeChannelDerivationParametersImport;
23 pub(crate) type nativeChannelDerivationParameters = nativeChannelDerivationParametersImport;
24
25 /// The parameters required to derive a channel signer via [`SignerProvider`].
26 #[must_use]
27 #[repr(C)]
28 pub struct ChannelDerivationParameters {
29         /// A pointer to the opaque Rust object.
30
31         /// Nearly everywhere, inner must be non-null, however in places where
32         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
33         pub inner: *mut nativeChannelDerivationParameters,
34         /// Indicates that this is the only struct which contains the same pointer.
35
36         /// Rust functions which take ownership of an object provided via an argument require
37         /// this to be true and invalidate the object pointed to by inner.
38         pub is_owned: bool,
39 }
40
41 impl Drop for ChannelDerivationParameters {
42         fn drop(&mut self) {
43                 if self.is_owned && !<*mut nativeChannelDerivationParameters>::is_null(self.inner) {
44                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
45                 }
46         }
47 }
48 /// Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL.
49 #[no_mangle]
50 pub extern "C" fn ChannelDerivationParameters_free(this_obj: ChannelDerivationParameters) { }
51 #[allow(unused)]
52 /// Used only if an object of this type is returned as a trait impl by a method
53 pub(crate) extern "C" fn ChannelDerivationParameters_free_void(this_ptr: *mut c_void) {
54         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDerivationParameters) };
55 }
56 #[allow(unused)]
57 impl ChannelDerivationParameters {
58         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDerivationParameters {
59                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
60         }
61         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDerivationParameters {
62                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
63         }
64         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
65         pub(crate) fn take_inner(mut self) -> *mut nativeChannelDerivationParameters {
66                 assert!(self.is_owned);
67                 let ret = ObjOps::untweak_ptr(self.inner);
68                 self.inner = core::ptr::null_mut();
69                 ret
70         }
71 }
72 /// The value in satoshis of the channel we're attempting to spend the anchor output of.
73 #[no_mangle]
74 pub extern "C" fn ChannelDerivationParameters_get_value_satoshis(this_ptr: &ChannelDerivationParameters) -> u64 {
75         let mut inner_val = &mut this_ptr.get_native_mut_ref().value_satoshis;
76         *inner_val
77 }
78 /// The value in satoshis of the channel we're attempting to spend the anchor output of.
79 #[no_mangle]
80 pub extern "C" fn ChannelDerivationParameters_set_value_satoshis(this_ptr: &mut ChannelDerivationParameters, mut val: u64) {
81         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.value_satoshis = val;
82 }
83 /// The unique identifier to re-derive the signer for the associated channel.
84 #[no_mangle]
85 pub extern "C" fn ChannelDerivationParameters_get_keys_id(this_ptr: &ChannelDerivationParameters) -> *const [u8; 32] {
86         let mut inner_val = &mut this_ptr.get_native_mut_ref().keys_id;
87         inner_val
88 }
89 /// The unique identifier to re-derive the signer for the associated channel.
90 #[no_mangle]
91 pub extern "C" fn ChannelDerivationParameters_set_keys_id(this_ptr: &mut ChannelDerivationParameters, mut val: crate::c_types::ThirtyTwoBytes) {
92         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys_id = val.data;
93 }
94 /// The necessary channel parameters that need to be provided to the re-derived signer through
95 /// [`ChannelSigner::provide_channel_parameters`].
96 ///
97 /// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters
98 #[no_mangle]
99 pub extern "C" fn ChannelDerivationParameters_get_transaction_parameters(this_ptr: &ChannelDerivationParameters) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters {
100         let mut inner_val = &mut this_ptr.get_native_mut_ref().transaction_parameters;
101         crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }
102 }
103 /// The necessary channel parameters that need to be provided to the re-derived signer through
104 /// [`ChannelSigner::provide_channel_parameters`].
105 ///
106 /// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters
107 #[no_mangle]
108 pub extern "C" fn ChannelDerivationParameters_set_transaction_parameters(this_ptr: &mut ChannelDerivationParameters, mut val: crate::lightning::ln::chan_utils::ChannelTransactionParameters) {
109         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.transaction_parameters = *unsafe { Box::from_raw(val.take_inner()) };
110 }
111 /// Constructs a new ChannelDerivationParameters given each field
112 #[must_use]
113 #[no_mangle]
114 pub extern "C" fn ChannelDerivationParameters_new(mut value_satoshis_arg: u64, mut keys_id_arg: crate::c_types::ThirtyTwoBytes, mut transaction_parameters_arg: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> ChannelDerivationParameters {
115         ChannelDerivationParameters { inner: ObjOps::heap_alloc(nativeChannelDerivationParameters {
116                 value_satoshis: value_satoshis_arg,
117                 keys_id: keys_id_arg.data,
118                 transaction_parameters: *unsafe { Box::from_raw(transaction_parameters_arg.take_inner()) },
119         }), is_owned: true }
120 }
121 impl Clone for ChannelDerivationParameters {
122         fn clone(&self) -> Self {
123                 Self {
124                         inner: if <*mut nativeChannelDerivationParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
125                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
126                         is_owned: true,
127                 }
128         }
129 }
130 #[allow(unused)]
131 /// Used only if an object of this type is returned as a trait impl by a method
132 pub(crate) extern "C" fn ChannelDerivationParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
133         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDerivationParameters)).clone() })) as *mut c_void
134 }
135 #[no_mangle]
136 /// Creates a copy of the ChannelDerivationParameters
137 pub extern "C" fn ChannelDerivationParameters_clone(orig: &ChannelDerivationParameters) -> ChannelDerivationParameters {
138         orig.clone()
139 }
140 /// Checks if two ChannelDerivationParameterss contain equal inner contents.
141 /// This ignores pointers and is_owned flags and looks at the values in fields.
142 /// Two objects with NULL inner values will be considered "equal" here.
143 #[no_mangle]
144 pub extern "C" fn ChannelDerivationParameters_eq(a: &ChannelDerivationParameters, b: &ChannelDerivationParameters) -> bool {
145         if a.inner == b.inner { return true; }
146         if a.inner.is_null() || b.inner.is_null() { return false; }
147         if a.get_native_ref() == b.get_native_ref() { true } else { false }
148 }
149
150 use lightning::events::bump_transaction::AnchorDescriptor as nativeAnchorDescriptorImport;
151 pub(crate) type nativeAnchorDescriptor = nativeAnchorDescriptorImport;
152
153 /// A descriptor used to sign for a commitment transaction's anchor output.
154 #[must_use]
155 #[repr(C)]
156 pub struct AnchorDescriptor {
157         /// A pointer to the opaque Rust object.
158
159         /// Nearly everywhere, inner must be non-null, however in places where
160         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
161         pub inner: *mut nativeAnchorDescriptor,
162         /// Indicates that this is the only struct which contains the same pointer.
163
164         /// Rust functions which take ownership of an object provided via an argument require
165         /// this to be true and invalidate the object pointed to by inner.
166         pub is_owned: bool,
167 }
168
169 impl Drop for AnchorDescriptor {
170         fn drop(&mut self) {
171                 if self.is_owned && !<*mut nativeAnchorDescriptor>::is_null(self.inner) {
172                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
173                 }
174         }
175 }
176 /// Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL.
177 #[no_mangle]
178 pub extern "C" fn AnchorDescriptor_free(this_obj: AnchorDescriptor) { }
179 #[allow(unused)]
180 /// Used only if an object of this type is returned as a trait impl by a method
181 pub(crate) extern "C" fn AnchorDescriptor_free_void(this_ptr: *mut c_void) {
182         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnchorDescriptor) };
183 }
184 #[allow(unused)]
185 impl AnchorDescriptor {
186         pub(crate) fn get_native_ref(&self) -> &'static nativeAnchorDescriptor {
187                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
188         }
189         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnchorDescriptor {
190                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
191         }
192         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
193         pub(crate) fn take_inner(mut self) -> *mut nativeAnchorDescriptor {
194                 assert!(self.is_owned);
195                 let ret = ObjOps::untweak_ptr(self.inner);
196                 self.inner = core::ptr::null_mut();
197                 ret
198         }
199 }
200 /// The parameters required to derive the signer for the anchor input.
201 #[no_mangle]
202 pub extern "C" fn AnchorDescriptor_get_channel_derivation_parameters(this_ptr: &AnchorDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters {
203         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters;
204         crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false }
205 }
206 /// The parameters required to derive the signer for the anchor input.
207 #[no_mangle]
208 pub extern "C" fn AnchorDescriptor_set_channel_derivation_parameters(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) {
209         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) };
210 }
211 /// The transaction input's outpoint corresponding to the commitment transaction's anchor
212 /// output.
213 #[no_mangle]
214 pub extern "C" fn AnchorDescriptor_get_outpoint(this_ptr: &AnchorDescriptor) -> crate::lightning::chain::transaction::OutPoint {
215         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
216         crate::c_types::bitcoin_to_C_outpoint(inner_val)
217 }
218 /// The transaction input's outpoint corresponding to the commitment transaction's anchor
219 /// output.
220 #[no_mangle]
221 pub extern "C" fn AnchorDescriptor_set_outpoint(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) {
222         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
223 }
224 /// Constructs a new AnchorDescriptor given each field
225 #[must_use]
226 #[no_mangle]
227 pub extern "C" fn AnchorDescriptor_new(mut channel_derivation_parameters_arg: crate::lightning::events::bump_transaction::ChannelDerivationParameters, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint) -> AnchorDescriptor {
228         AnchorDescriptor { inner: ObjOps::heap_alloc(nativeAnchorDescriptor {
229                 channel_derivation_parameters: *unsafe { Box::from_raw(channel_derivation_parameters_arg.take_inner()) },
230                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
231         }), is_owned: true }
232 }
233 impl Clone for AnchorDescriptor {
234         fn clone(&self) -> Self {
235                 Self {
236                         inner: if <*mut nativeAnchorDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
237                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
238                         is_owned: true,
239                 }
240         }
241 }
242 #[allow(unused)]
243 /// Used only if an object of this type is returned as a trait impl by a method
244 pub(crate) extern "C" fn AnchorDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
245         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnchorDescriptor)).clone() })) as *mut c_void
246 }
247 #[no_mangle]
248 /// Creates a copy of the AnchorDescriptor
249 pub extern "C" fn AnchorDescriptor_clone(orig: &AnchorDescriptor) -> AnchorDescriptor {
250         orig.clone()
251 }
252 /// Checks if two AnchorDescriptors contain equal inner contents.
253 /// This ignores pointers and is_owned flags and looks at the values in fields.
254 /// Two objects with NULL inner values will be considered "equal" here.
255 #[no_mangle]
256 pub extern "C" fn AnchorDescriptor_eq(a: &AnchorDescriptor, b: &AnchorDescriptor) -> bool {
257         if a.inner == b.inner { return true; }
258         if a.inner.is_null() || b.inner.is_null() { return false; }
259         if a.get_native_ref() == b.get_native_ref() { true } else { false }
260 }
261 /// Returns the UTXO to be spent by the anchor input, which can be obtained via
262 /// [`Self::unsigned_tx_input`].
263 #[must_use]
264 #[no_mangle]
265 pub extern "C" fn AnchorDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxOut {
266         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo();
267         crate::c_types::TxOut::from_rust(&ret)
268 }
269
270 /// Returns the unsigned transaction input spending the anchor output in the commitment
271 /// transaction.
272 #[must_use]
273 #[no_mangle]
274 pub extern "C" fn AnchorDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxIn {
275         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input();
276         crate::c_types::TxIn::from_rust(&ret)
277 }
278
279 /// Returns the witness script of the anchor output in the commitment transaction.
280 #[must_use]
281 #[no_mangle]
282 pub extern "C" fn AnchorDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::derived::CVec_u8Z {
283         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script();
284         ret.into_bytes().into()
285 }
286
287 /// Returns the fully signed witness required to spend the anchor output in the commitment
288 /// transaction.
289 #[must_use]
290 #[no_mangle]
291 pub extern "C" fn AnchorDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, mut signature: crate::c_types::Signature) -> crate::c_types::Witness {
292         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust());
293         crate::c_types::Witness::from_bitcoin(&ret)
294 }
295
296 /// Derives the channel signer required to sign the anchor input.
297 #[must_use]
298 #[no_mangle]
299 pub extern "C" fn AnchorDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
300         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider);
301         Into::into(ret)
302 }
303
304
305 use lightning::events::bump_transaction::HTLCDescriptor as nativeHTLCDescriptorImport;
306 pub(crate) type nativeHTLCDescriptor = nativeHTLCDescriptorImport;
307
308 /// A descriptor used to sign for a commitment transaction's HTLC output.
309 #[must_use]
310 #[repr(C)]
311 pub struct HTLCDescriptor {
312         /// A pointer to the opaque Rust object.
313
314         /// Nearly everywhere, inner must be non-null, however in places where
315         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
316         pub inner: *mut nativeHTLCDescriptor,
317         /// Indicates that this is the only struct which contains the same pointer.
318
319         /// Rust functions which take ownership of an object provided via an argument require
320         /// this to be true and invalidate the object pointed to by inner.
321         pub is_owned: bool,
322 }
323
324 impl Drop for HTLCDescriptor {
325         fn drop(&mut self) {
326                 if self.is_owned && !<*mut nativeHTLCDescriptor>::is_null(self.inner) {
327                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
328                 }
329         }
330 }
331 /// Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL.
332 #[no_mangle]
333 pub extern "C" fn HTLCDescriptor_free(this_obj: HTLCDescriptor) { }
334 #[allow(unused)]
335 /// Used only if an object of this type is returned as a trait impl by a method
336 pub(crate) extern "C" fn HTLCDescriptor_free_void(this_ptr: *mut c_void) {
337         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHTLCDescriptor) };
338 }
339 #[allow(unused)]
340 impl HTLCDescriptor {
341         pub(crate) fn get_native_ref(&self) -> &'static nativeHTLCDescriptor {
342                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
343         }
344         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHTLCDescriptor {
345                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
346         }
347         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
348         pub(crate) fn take_inner(mut self) -> *mut nativeHTLCDescriptor {
349                 assert!(self.is_owned);
350                 let ret = ObjOps::untweak_ptr(self.inner);
351                 self.inner = core::ptr::null_mut();
352                 ret
353         }
354 }
355 /// The parameters required to derive the signer for the HTLC input.
356 #[no_mangle]
357 pub extern "C" fn HTLCDescriptor_get_channel_derivation_parameters(this_ptr: &HTLCDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters {
358         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters;
359         crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false }
360 }
361 /// The parameters required to derive the signer for the HTLC input.
362 #[no_mangle]
363 pub extern "C" fn HTLCDescriptor_set_channel_derivation_parameters(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) {
364         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) };
365 }
366 /// The number of the commitment transaction in which the HTLC output lives.
367 #[no_mangle]
368 pub extern "C" fn HTLCDescriptor_get_per_commitment_number(this_ptr: &HTLCDescriptor) -> u64 {
369         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_number;
370         *inner_val
371 }
372 /// The number of the commitment transaction in which the HTLC output lives.
373 #[no_mangle]
374 pub extern "C" fn HTLCDescriptor_set_per_commitment_number(this_ptr: &mut HTLCDescriptor, mut val: u64) {
375         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_number = val;
376 }
377 /// The key tweak corresponding to the number of the commitment transaction in which the HTLC
378 /// output lives. This tweak is applied to all the basepoints for both parties in the channel to
379 /// arrive at unique keys per commitment.
380 ///
381 /// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
382 #[no_mangle]
383 pub extern "C" fn HTLCDescriptor_get_per_commitment_point(this_ptr: &HTLCDescriptor) -> crate::c_types::PublicKey {
384         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point;
385         crate::c_types::PublicKey::from_rust(&inner_val)
386 }
387 /// The key tweak corresponding to the number of the commitment transaction in which the HTLC
388 /// output lives. This tweak is applied to all the basepoints for both parties in the channel to
389 /// arrive at unique keys per commitment.
390 ///
391 /// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
392 #[no_mangle]
393 pub extern "C" fn HTLCDescriptor_set_per_commitment_point(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::PublicKey) {
394         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust();
395 }
396 /// The details of the HTLC as it appears in the commitment transaction.
397 #[no_mangle]
398 pub extern "C" fn HTLCDescriptor_get_htlc(this_ptr: &HTLCDescriptor) -> crate::lightning::ln::chan_utils::HTLCOutputInCommitment {
399         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc;
400         crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }
401 }
402 /// The details of the HTLC as it appears in the commitment transaction.
403 #[no_mangle]
404 pub extern "C" fn HTLCDescriptor_set_htlc(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) {
405         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc = *unsafe { Box::from_raw(val.take_inner()) };
406 }
407 /// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
408 /// taken.
409 #[no_mangle]
410 pub extern "C" fn HTLCDescriptor_get_preimage(this_ptr: &HTLCDescriptor) -> crate::c_types::derived::COption_PaymentPreimageZ {
411         let mut inner_val = &mut this_ptr.get_native_mut_ref().preimage;
412         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_PaymentPreimageZ::None } else { crate::c_types::derived::COption_PaymentPreimageZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) };
413         local_inner_val
414 }
415 /// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
416 /// taken.
417 #[no_mangle]
418 pub extern "C" fn HTLCDescriptor_set_preimage(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::derived::COption_PaymentPreimageZ) {
419         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ val_opt.take() }.data) }})} };
420         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.preimage = local_val;
421 }
422 /// The counterparty's signature required to spend the HTLC output.
423 #[no_mangle]
424 pub extern "C" fn HTLCDescriptor_get_counterparty_sig(this_ptr: &HTLCDescriptor) -> crate::c_types::Signature {
425         let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty_sig;
426         crate::c_types::Signature::from_rust(&inner_val)
427 }
428 /// The counterparty's signature required to spend the HTLC output.
429 #[no_mangle]
430 pub extern "C" fn HTLCDescriptor_set_counterparty_sig(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::Signature) {
431         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty_sig = val.into_rust();
432 }
433 impl Clone for HTLCDescriptor {
434         fn clone(&self) -> Self {
435                 Self {
436                         inner: if <*mut nativeHTLCDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
437                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
438                         is_owned: true,
439                 }
440         }
441 }
442 #[allow(unused)]
443 /// Used only if an object of this type is returned as a trait impl by a method
444 pub(crate) extern "C" fn HTLCDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
445         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCDescriptor)).clone() })) as *mut c_void
446 }
447 #[no_mangle]
448 /// Creates a copy of the HTLCDescriptor
449 pub extern "C" fn HTLCDescriptor_clone(orig: &HTLCDescriptor) -> HTLCDescriptor {
450         orig.clone()
451 }
452 /// Checks if two HTLCDescriptors contain equal inner contents.
453 /// This ignores pointers and is_owned flags and looks at the values in fields.
454 /// Two objects with NULL inner values will be considered "equal" here.
455 #[no_mangle]
456 pub extern "C" fn HTLCDescriptor_eq(a: &HTLCDescriptor, b: &HTLCDescriptor) -> bool {
457         if a.inner == b.inner { return true; }
458         if a.inner.is_null() || b.inner.is_null() { return false; }
459         if a.get_native_ref() == b.get_native_ref() { true } else { false }
460 }
461 /// Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
462 /// being spent by the HTLC input in the HTLC transaction.
463 #[must_use]
464 #[no_mangle]
465 pub extern "C" fn HTLCDescriptor_outpoint(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::lightning::chain::transaction::OutPoint {
466         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.outpoint();
467         crate::c_types::bitcoin_to_C_outpoint(&ret)
468 }
469
470 /// Returns the UTXO to be spent by the HTLC input, which can be obtained via
471 /// [`Self::unsigned_tx_input`].
472 #[must_use]
473 #[no_mangle]
474 pub extern "C" fn HTLCDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut {
475         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo(secp256k1::global::SECP256K1);
476         crate::c_types::TxOut::from_rust(&ret)
477 }
478
479 /// Returns the unsigned transaction input spending the HTLC output in the commitment
480 /// transaction.
481 #[must_use]
482 #[no_mangle]
483 pub extern "C" fn HTLCDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxIn {
484         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input();
485         crate::c_types::TxIn::from_rust(&ret)
486 }
487
488 /// Returns the delayed output created as a result of spending the HTLC output in the commitment
489 /// transaction.
490 #[must_use]
491 #[no_mangle]
492 pub extern "C" fn HTLCDescriptor_tx_output(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut {
493         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_output(secp256k1::global::SECP256K1);
494         crate::c_types::TxOut::from_rust(&ret)
495 }
496
497 /// Returns the witness script of the HTLC output in the commitment transaction.
498 #[must_use]
499 #[no_mangle]
500 pub extern "C" fn HTLCDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CVec_u8Z {
501         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script(secp256k1::global::SECP256K1);
502         ret.into_bytes().into()
503 }
504
505 /// Returns the fully signed witness required to spend the HTLC output in the commitment
506 /// transaction.
507 #[must_use]
508 #[no_mangle]
509 pub extern "C" fn HTLCDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, mut signature: crate::c_types::Signature, mut witness_script: crate::c_types::u8slice) -> crate::c_types::Witness {
510         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), &::bitcoin::blockdata::script::Script::from(Vec::from(witness_script.to_slice())));
511         crate::c_types::Witness::from_bitcoin(&ret)
512 }
513
514 /// Derives the channel signer required to sign the HTLC input.
515 #[must_use]
516 #[no_mangle]
517 pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner {
518         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider);
519         Into::into(ret)
520 }
521
522 /// Represents the different types of transactions, originating from LDK, to be bumped.
523 #[derive(Clone)]
524 #[must_use]
525 #[repr(C)]
526 pub enum BumpTransactionEvent {
527         /// Indicates that a channel featuring anchor outputs is to be closed by broadcasting the local
528         /// commitment transaction. Since commitment transactions have a static feerate pre-agreed upon,
529         /// they may need additional fees to be attached through a child transaction using the popular
530         /// [Child-Pays-For-Parent](https://bitcoinops.org/en/topics/cpfp) fee bumping technique. This
531         /// child transaction must include the anchor input described within `anchor_descriptor` along
532         /// with additional inputs to meet the target feerate. Failure to meet the target feerate
533         /// decreases the confirmation odds of the transaction package (which includes the commitment
534         /// and child anchor transactions), possibly resulting in a loss of funds. Once the transaction
535         /// is constructed, it must be fully signed for and broadcast by the consumer of the event
536         /// along with the `commitment_tx` enclosed. Note that the `commitment_tx` must always be
537         /// broadcast first, as the child anchor transaction depends on it.
538         ///
539         /// The consumer should be able to sign for any of the additional inputs included within the
540         /// child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be
541         /// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature
542         /// can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be
543         /// provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the
544         /// full witness required to spend.
545         ///
546         /// It is possible to receive more than one instance of this event if a valid child anchor
547         /// transaction is never broadcast or is but not with a sufficient fee to be mined. Care should
548         /// be taken by the consumer of the event to ensure any future iterations of the child anchor
549         /// transaction adhere to the [Replace-By-Fee
550         /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md)
551         /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of
552         /// these events is not user-controlled, users may ignore/drop the event if they are no longer
553         /// able to commit external confirmed funds to the child anchor transaction.
554         ///
555         /// The set of `pending_htlcs` on the commitment transaction to be broadcast can be inspected to
556         /// determine whether a significant portion of the channel's funds are allocated to HTLCs,
557         /// enabling users to make their own decisions regarding the importance of the commitment
558         /// transaction's confirmation. Note that this is not required, but simply exists as an option
559         /// for users to override LDK's behavior. On commitments with no HTLCs (indicated by those with
560         /// an empty `pending_htlcs`), confirmation of the commitment transaction can be considered to
561         /// be not urgent.
562         ///
563         /// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner
564         /// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::EcdsaChannelSigner::sign_holder_anchor_input
565         /// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness
566         ChannelClose {
567                 /// The unique identifier for the claim of the anchor output in the commitment transaction.
568                 ///
569                 /// The identifier must map to the set of external UTXOs assigned to the claim, such that
570                 /// they can be reused when a new claim with the same identifier needs to be made, resulting
571                 /// in a fee-bumping attempt.
572                 claim_id: crate::c_types::ThirtyTwoBytes,
573                 /// The target feerate that the transaction package, which consists of the commitment
574                 /// transaction and the to-be-crafted child anchor transaction, must meet.
575                 package_target_feerate_sat_per_1000_weight: u32,
576                 /// The channel's commitment transaction to bump the fee of. This transaction should be
577                 /// broadcast along with the anchor transaction constructed as a result of consuming this
578                 /// event.
579                 commitment_tx: crate::c_types::Transaction,
580                 /// The absolute fee in satoshis of the commitment transaction. This can be used along the
581                 /// with weight of the commitment transaction to determine its feerate.
582                 commitment_tx_fee_satoshis: u64,
583                 /// The descriptor to sign the anchor input of the anchor transaction constructed as a
584                 /// result of consuming this event.
585                 anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor,
586                 /// The set of pending HTLCs on the commitment transaction that need to be resolved once the
587                 /// commitment transaction confirms.
588                 pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ,
589         },
590         /// Indicates that a channel featuring anchor outputs has unilaterally closed on-chain by a
591         /// holder commitment transaction and its HTLC(s) need to be resolved on-chain. With the
592         /// zero-HTLC-transaction-fee variant of anchor outputs, the pre-signed HTLC
593         /// transactions have a zero fee, thus requiring additional inputs and/or outputs to be attached
594         /// for a timely confirmation within the chain. These additional inputs and/or outputs must be
595         /// appended to the resulting HTLC transaction to meet the target feerate. Failure to meet the
596         /// target feerate decreases the confirmation odds of the transaction, possibly resulting in a
597         /// loss of funds. Once the transaction meets the target feerate, it must be signed for and
598         /// broadcast by the consumer of the event.
599         ///
600         /// The consumer should be able to sign for any of the non-HTLC inputs added to the resulting
601         /// HTLC transaction. To sign HTLC inputs, an [`EcdsaChannelSigner`] should be re-derived
602         /// through [`HTLCDescriptor::derive_channel_signer`]. Each HTLC input's signature can be
603         /// computed with [`EcdsaChannelSigner::sign_holder_htlc_transaction`], which can then be
604         /// provided to [`HTLCDescriptor::tx_input_witness`] to obtain the fully signed witness required
605         /// to spend.
606         ///
607         /// It is possible to receive more than one instance of this event if a valid HTLC transaction
608         /// is never broadcast or is but not with a sufficient fee to be mined. Care should be taken by
609         /// the consumer of the event to ensure any future iterations of the HTLC transaction adhere to
610         /// the [Replace-By-Fee
611         /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md)
612         /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of
613         /// these events is not user-controlled, users may ignore/drop the event if either they are no
614         /// longer able to commit external confirmed funds to the HTLC transaction or the fee committed
615         /// to the HTLC transaction is greater in value than the HTLCs being claimed.
616         ///
617         /// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner
618         /// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction
619         /// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness
620         HTLCResolution {
621                 /// The unique identifier for the claim of the HTLCs in the confirmed commitment
622                 /// transaction.
623                 ///
624                 /// The identifier must map to the set of external UTXOs assigned to the claim, such that
625                 /// they can be reused when a new claim with the same identifier needs to be made, resulting
626                 /// in a fee-bumping attempt.
627                 claim_id: crate::c_types::ThirtyTwoBytes,
628                 /// The target feerate that the resulting HTLC transaction must meet.
629                 target_feerate_sat_per_1000_weight: u32,
630                 /// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably
631                 /// by the same transaction.
632                 htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ,
633                 /// The locktime required for the resulting HTLC transaction.
634                 tx_lock_time: u32,
635         },
636 }
637 use lightning::events::bump_transaction::BumpTransactionEvent as BumpTransactionEventImport;
638 pub(crate) type nativeBumpTransactionEvent = BumpTransactionEventImport;
639
640 impl BumpTransactionEvent {
641         #[allow(unused)]
642         pub(crate) fn to_native(&self) -> nativeBumpTransactionEvent {
643                 match self {
644                         BumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => {
645                                 let mut claim_id_nonref = Clone::clone(claim_id);
646                                 let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight);
647                                 let mut commitment_tx_nonref = Clone::clone(commitment_tx);
648                                 let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis);
649                                 let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor);
650                                 let mut pending_htlcs_nonref = Clone::clone(pending_htlcs);
651                                 let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.into_rust().drain(..) { local_pending_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
652                                 nativeBumpTransactionEvent::ChannelClose {
653                                         claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data),
654                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref,
655                                         commitment_tx: commitment_tx_nonref.into_bitcoin(),
656                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref,
657                                         anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor_nonref.take_inner()) },
658                                         pending_htlcs: local_pending_htlcs_nonref,
659                                 }
660                         },
661                         BumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => {
662                                 let mut claim_id_nonref = Clone::clone(claim_id);
663                                 let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight);
664                                 let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors);
665                                 let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.into_rust().drain(..) { local_htlc_descriptors_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
666                                 let mut tx_lock_time_nonref = Clone::clone(tx_lock_time);
667                                 nativeBumpTransactionEvent::HTLCResolution {
668                                         claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data),
669                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref,
670                                         htlc_descriptors: local_htlc_descriptors_nonref,
671                                         tx_lock_time: ::bitcoin::PackedLockTime(tx_lock_time_nonref),
672                                 }
673                         },
674                 }
675         }
676         #[allow(unused)]
677         pub(crate) fn into_native(self) -> nativeBumpTransactionEvent {
678                 match self {
679                         BumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => {
680                                 let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.into_rust().drain(..) { local_pending_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
681                                 nativeBumpTransactionEvent::ChannelClose {
682                                         claim_id: ::lightning::chain::ClaimId(claim_id.data),
683                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight,
684                                         commitment_tx: commitment_tx.into_bitcoin(),
685                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis,
686                                         anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor.take_inner()) },
687                                         pending_htlcs: local_pending_htlcs,
688                                 }
689                         },
690                         BumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => {
691                                 let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.into_rust().drain(..) { local_htlc_descriptors.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
692                                 nativeBumpTransactionEvent::HTLCResolution {
693                                         claim_id: ::lightning::chain::ClaimId(claim_id.data),
694                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight,
695                                         htlc_descriptors: local_htlc_descriptors,
696                                         tx_lock_time: ::bitcoin::PackedLockTime(tx_lock_time),
697                                 }
698                         },
699                 }
700         }
701         #[allow(unused)]
702         pub(crate) fn from_native(native: &nativeBumpTransactionEvent) -> Self {
703                 match native {
704                         nativeBumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => {
705                                 let mut claim_id_nonref = Clone::clone(claim_id);
706                                 let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight);
707                                 let mut commitment_tx_nonref = Clone::clone(commitment_tx);
708                                 let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis);
709                                 let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor);
710                                 let mut pending_htlcs_nonref = Clone::clone(pending_htlcs);
711                                 let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.drain(..) { local_pending_htlcs_nonref.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
712                                 BumpTransactionEvent::ChannelClose {
713                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 },
714                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref,
715                                         commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx_nonref),
716                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref,
717                                         anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor_nonref), is_owned: true },
718                                         pending_htlcs: local_pending_htlcs_nonref.into(),
719                                 }
720                         },
721                         nativeBumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => {
722                                 let mut claim_id_nonref = Clone::clone(claim_id);
723                                 let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight);
724                                 let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors);
725                                 let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.drain(..) { local_htlc_descriptors_nonref.push( { crate::lightning::events::bump_transaction::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
726                                 let mut tx_lock_time_nonref = Clone::clone(tx_lock_time);
727                                 BumpTransactionEvent::HTLCResolution {
728                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 },
729                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref,
730                                         htlc_descriptors: local_htlc_descriptors_nonref.into(),
731                                         tx_lock_time: tx_lock_time_nonref.0,
732                                 }
733                         },
734                 }
735         }
736         #[allow(unused)]
737         pub(crate) fn native_into(native: nativeBumpTransactionEvent) -> Self {
738                 match native {
739                         nativeBumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => {
740                                 let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.drain(..) { local_pending_htlcs.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
741                                 BumpTransactionEvent::ChannelClose {
742                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 },
743                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight,
744                                         commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx),
745                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis,
746                                         anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor), is_owned: true },
747                                         pending_htlcs: local_pending_htlcs.into(),
748                                 }
749                         },
750                         nativeBumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => {
751                                 let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.drain(..) { local_htlc_descriptors.push( { crate::lightning::events::bump_transaction::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
752                                 BumpTransactionEvent::HTLCResolution {
753                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 },
754                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight,
755                                         htlc_descriptors: local_htlc_descriptors.into(),
756                                         tx_lock_time: tx_lock_time.0,
757                                 }
758                         },
759                 }
760         }
761 }
762 /// Frees any resources used by the BumpTransactionEvent
763 #[no_mangle]
764 pub extern "C" fn BumpTransactionEvent_free(this_ptr: BumpTransactionEvent) { }
765 /// Creates a copy of the BumpTransactionEvent
766 #[no_mangle]
767 pub extern "C" fn BumpTransactionEvent_clone(orig: &BumpTransactionEvent) -> BumpTransactionEvent {
768         orig.clone()
769 }
770 #[no_mangle]
771 /// Utility method to constructs a new ChannelClose-variant BumpTransactionEvent
772 pub extern "C" fn BumpTransactionEvent_channel_close(claim_id: crate::c_types::ThirtyTwoBytes, package_target_feerate_sat_per_1000_weight: u32, commitment_tx: crate::c_types::Transaction, commitment_tx_fee_satoshis: u64, anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor, pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> BumpTransactionEvent {
773         BumpTransactionEvent::ChannelClose {
774                 claim_id,
775                 package_target_feerate_sat_per_1000_weight,
776                 commitment_tx,
777                 commitment_tx_fee_satoshis,
778                 anchor_descriptor,
779                 pending_htlcs,
780         }
781 }
782 #[no_mangle]
783 /// Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent
784 pub extern "C" fn BumpTransactionEvent_htlcresolution(claim_id: crate::c_types::ThirtyTwoBytes, target_feerate_sat_per_1000_weight: u32, htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ, tx_lock_time: u32) -> BumpTransactionEvent {
785         BumpTransactionEvent::HTLCResolution {
786                 claim_id,
787                 target_feerate_sat_per_1000_weight,
788                 htlc_descriptors,
789                 tx_lock_time,
790         }
791 }
792 /// Checks if two BumpTransactionEvents contain equal inner contents.
793 /// This ignores pointers and is_owned flags and looks at the values in fields.
794 #[no_mangle]
795 pub extern "C" fn BumpTransactionEvent_eq(a: &BumpTransactionEvent, b: &BumpTransactionEvent) -> bool {
796         if &a.to_native() == &b.to_native() { true } else { false }
797 }
798
799 use lightning::events::bump_transaction::Input as nativeInputImport;
800 pub(crate) type nativeInput = nativeInputImport;
801
802 /// An input that must be included in a transaction when performing coin selection through
803 /// [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it
804 /// must have an empty [`TxIn::script_sig`] when spent.
805 #[must_use]
806 #[repr(C)]
807 pub struct Input {
808         /// A pointer to the opaque Rust object.
809
810         /// Nearly everywhere, inner must be non-null, however in places where
811         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
812         pub inner: *mut nativeInput,
813         /// Indicates that this is the only struct which contains the same pointer.
814
815         /// Rust functions which take ownership of an object provided via an argument require
816         /// this to be true and invalidate the object pointed to by inner.
817         pub is_owned: bool,
818 }
819
820 impl Drop for Input {
821         fn drop(&mut self) {
822                 if self.is_owned && !<*mut nativeInput>::is_null(self.inner) {
823                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
824                 }
825         }
826 }
827 /// Frees any resources used by the Input, if is_owned is set and inner is non-NULL.
828 #[no_mangle]
829 pub extern "C" fn Input_free(this_obj: Input) { }
830 #[allow(unused)]
831 /// Used only if an object of this type is returned as a trait impl by a method
832 pub(crate) extern "C" fn Input_free_void(this_ptr: *mut c_void) {
833         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInput) };
834 }
835 #[allow(unused)]
836 impl Input {
837         pub(crate) fn get_native_ref(&self) -> &'static nativeInput {
838                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
839         }
840         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInput {
841                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
842         }
843         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
844         pub(crate) fn take_inner(mut self) -> *mut nativeInput {
845                 assert!(self.is_owned);
846                 let ret = ObjOps::untweak_ptr(self.inner);
847                 self.inner = core::ptr::null_mut();
848                 ret
849         }
850 }
851 /// The unique identifier of the input.
852 #[no_mangle]
853 pub extern "C" fn Input_get_outpoint(this_ptr: &Input) -> crate::lightning::chain::transaction::OutPoint {
854         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
855         crate::c_types::bitcoin_to_C_outpoint(inner_val)
856 }
857 /// The unique identifier of the input.
858 #[no_mangle]
859 pub extern "C" fn Input_set_outpoint(this_ptr: &mut Input, mut val: crate::lightning::chain::transaction::OutPoint) {
860         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
861 }
862 /// The UTXO being spent by the input.
863 #[no_mangle]
864 pub extern "C" fn Input_get_previous_utxo(this_ptr: &Input) -> crate::c_types::TxOut {
865         let mut inner_val = &mut this_ptr.get_native_mut_ref().previous_utxo;
866         crate::c_types::TxOut::from_rust(inner_val)
867 }
868 /// The UTXO being spent by the input.
869 #[no_mangle]
870 pub extern "C" fn Input_set_previous_utxo(this_ptr: &mut Input, mut val: crate::c_types::TxOut) {
871         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previous_utxo = val.into_rust();
872 }
873 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
874 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
875 /// script.
876 #[no_mangle]
877 pub extern "C" fn Input_get_satisfaction_weight(this_ptr: &Input) -> u64 {
878         let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight;
879         *inner_val
880 }
881 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
882 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
883 /// script.
884 #[no_mangle]
885 pub extern "C" fn Input_set_satisfaction_weight(this_ptr: &mut Input, mut val: u64) {
886         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val;
887 }
888 /// Constructs a new Input given each field
889 #[must_use]
890 #[no_mangle]
891 pub extern "C" fn Input_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut previous_utxo_arg: crate::c_types::TxOut, mut satisfaction_weight_arg: u64) -> Input {
892         Input { inner: ObjOps::heap_alloc(nativeInput {
893                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
894                 previous_utxo: previous_utxo_arg.into_rust(),
895                 satisfaction_weight: satisfaction_weight_arg,
896         }), is_owned: true }
897 }
898 impl Clone for Input {
899         fn clone(&self) -> Self {
900                 Self {
901                         inner: if <*mut nativeInput>::is_null(self.inner) { core::ptr::null_mut() } else {
902                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
903                         is_owned: true,
904                 }
905         }
906 }
907 #[allow(unused)]
908 /// Used only if an object of this type is returned as a trait impl by a method
909 pub(crate) extern "C" fn Input_clone_void(this_ptr: *const c_void) -> *mut c_void {
910         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInput)).clone() })) as *mut c_void
911 }
912 #[no_mangle]
913 /// Creates a copy of the Input
914 pub extern "C" fn Input_clone(orig: &Input) -> Input {
915         orig.clone()
916 }
917 /// Generates a non-cryptographic 64-bit hash of the Input.
918 #[no_mangle]
919 pub extern "C" fn Input_hash(o: &Input) -> u64 {
920         if o.inner.is_null() { return 0; }
921         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
922         #[allow(deprecated)]
923         let mut hasher = core::hash::SipHasher::new();
924         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
925         core::hash::Hasher::finish(&hasher)
926 }
927 /// Checks if two Inputs contain equal inner contents.
928 /// This ignores pointers and is_owned flags and looks at the values in fields.
929 /// Two objects with NULL inner values will be considered "equal" here.
930 #[no_mangle]
931 pub extern "C" fn Input_eq(a: &Input, b: &Input) -> bool {
932         if a.inner == b.inner { return true; }
933         if a.inner.is_null() || b.inner.is_null() { return false; }
934         if a.get_native_ref() == b.get_native_ref() { true } else { false }
935 }
936
937 use lightning::events::bump_transaction::Utxo as nativeUtxoImport;
938 pub(crate) type nativeUtxo = nativeUtxoImport;
939
940 /// An unspent transaction output that is available to spend resulting from a successful
941 /// [`CoinSelection`] attempt.
942 #[must_use]
943 #[repr(C)]
944 pub struct Utxo {
945         /// A pointer to the opaque Rust object.
946
947         /// Nearly everywhere, inner must be non-null, however in places where
948         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
949         pub inner: *mut nativeUtxo,
950         /// Indicates that this is the only struct which contains the same pointer.
951
952         /// Rust functions which take ownership of an object provided via an argument require
953         /// this to be true and invalidate the object pointed to by inner.
954         pub is_owned: bool,
955 }
956
957 impl Drop for Utxo {
958         fn drop(&mut self) {
959                 if self.is_owned && !<*mut nativeUtxo>::is_null(self.inner) {
960                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
961                 }
962         }
963 }
964 /// Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL.
965 #[no_mangle]
966 pub extern "C" fn Utxo_free(this_obj: Utxo) { }
967 #[allow(unused)]
968 /// Used only if an object of this type is returned as a trait impl by a method
969 pub(crate) extern "C" fn Utxo_free_void(this_ptr: *mut c_void) {
970         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUtxo) };
971 }
972 #[allow(unused)]
973 impl Utxo {
974         pub(crate) fn get_native_ref(&self) -> &'static nativeUtxo {
975                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
976         }
977         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUtxo {
978                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
979         }
980         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
981         pub(crate) fn take_inner(mut self) -> *mut nativeUtxo {
982                 assert!(self.is_owned);
983                 let ret = ObjOps::untweak_ptr(self.inner);
984                 self.inner = core::ptr::null_mut();
985                 ret
986         }
987 }
988 /// The unique identifier of the output.
989 #[no_mangle]
990 pub extern "C" fn Utxo_get_outpoint(this_ptr: &Utxo) -> crate::lightning::chain::transaction::OutPoint {
991         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
992         crate::c_types::bitcoin_to_C_outpoint(inner_val)
993 }
994 /// The unique identifier of the output.
995 #[no_mangle]
996 pub extern "C" fn Utxo_set_outpoint(this_ptr: &mut Utxo, mut val: crate::lightning::chain::transaction::OutPoint) {
997         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
998 }
999 /// The output to spend.
1000 #[no_mangle]
1001 pub extern "C" fn Utxo_get_output(this_ptr: &Utxo) -> crate::c_types::TxOut {
1002         let mut inner_val = &mut this_ptr.get_native_mut_ref().output;
1003         crate::c_types::TxOut::from_rust(inner_val)
1004 }
1005 /// The output to spend.
1006 #[no_mangle]
1007 pub extern "C" fn Utxo_set_output(this_ptr: &mut Utxo, mut val: crate::c_types::TxOut) {
1008         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust();
1009 }
1010 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
1011 /// with their lengths included, required to satisfy the output's script. The weight consumed by
1012 /// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
1013 #[no_mangle]
1014 pub extern "C" fn Utxo_get_satisfaction_weight(this_ptr: &Utxo) -> u64 {
1015         let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight;
1016         *inner_val
1017 }
1018 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
1019 /// with their lengths included, required to satisfy the output's script. The weight consumed by
1020 /// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
1021 #[no_mangle]
1022 pub extern "C" fn Utxo_set_satisfaction_weight(this_ptr: &mut Utxo, mut val: u64) {
1023         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val;
1024 }
1025 /// Constructs a new Utxo given each field
1026 #[must_use]
1027 #[no_mangle]
1028 pub extern "C" fn Utxo_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut satisfaction_weight_arg: u64) -> Utxo {
1029         Utxo { inner: ObjOps::heap_alloc(nativeUtxo {
1030                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
1031                 output: output_arg.into_rust(),
1032                 satisfaction_weight: satisfaction_weight_arg,
1033         }), is_owned: true }
1034 }
1035 impl Clone for Utxo {
1036         fn clone(&self) -> Self {
1037                 Self {
1038                         inner: if <*mut nativeUtxo>::is_null(self.inner) { core::ptr::null_mut() } else {
1039                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1040                         is_owned: true,
1041                 }
1042         }
1043 }
1044 #[allow(unused)]
1045 /// Used only if an object of this type is returned as a trait impl by a method
1046 pub(crate) extern "C" fn Utxo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1047         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUtxo)).clone() })) as *mut c_void
1048 }
1049 #[no_mangle]
1050 /// Creates a copy of the Utxo
1051 pub extern "C" fn Utxo_clone(orig: &Utxo) -> Utxo {
1052         orig.clone()
1053 }
1054 /// Generates a non-cryptographic 64-bit hash of the Utxo.
1055 #[no_mangle]
1056 pub extern "C" fn Utxo_hash(o: &Utxo) -> u64 {
1057         if o.inner.is_null() { return 0; }
1058         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1059         #[allow(deprecated)]
1060         let mut hasher = core::hash::SipHasher::new();
1061         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1062         core::hash::Hasher::finish(&hasher)
1063 }
1064 /// Checks if two Utxos contain equal inner contents.
1065 /// This ignores pointers and is_owned flags and looks at the values in fields.
1066 /// Two objects with NULL inner values will be considered "equal" here.
1067 #[no_mangle]
1068 pub extern "C" fn Utxo_eq(a: &Utxo, b: &Utxo) -> bool {
1069         if a.inner == b.inner { return true; }
1070         if a.inner.is_null() || b.inner.is_null() { return false; }
1071         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1072 }
1073 /// Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output.
1074 #[must_use]
1075 #[no_mangle]
1076 pub extern "C" fn Utxo_new_p2pkh(mut outpoint: crate::lightning::chain::transaction::OutPoint, mut value: u64, pubkey_hash: *const [u8; 20]) -> crate::lightning::events::bump_transaction::Utxo {
1077         let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), value, &bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(unsafe { *pubkey_hash }.clone())));
1078         crate::lightning::events::bump_transaction::Utxo { inner: ObjOps::heap_alloc(ret), is_owned: true }
1079 }
1080
1081
1082 use lightning::events::bump_transaction::CoinSelection as nativeCoinSelectionImport;
1083 pub(crate) type nativeCoinSelection = nativeCoinSelectionImport;
1084
1085 /// The result of a successful coin selection attempt for a transaction requiring additional UTXOs
1086 /// to cover its fees.
1087 #[must_use]
1088 #[repr(C)]
1089 pub struct CoinSelection {
1090         /// A pointer to the opaque Rust object.
1091
1092         /// Nearly everywhere, inner must be non-null, however in places where
1093         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1094         pub inner: *mut nativeCoinSelection,
1095         /// Indicates that this is the only struct which contains the same pointer.
1096
1097         /// Rust functions which take ownership of an object provided via an argument require
1098         /// this to be true and invalidate the object pointed to by inner.
1099         pub is_owned: bool,
1100 }
1101
1102 impl Drop for CoinSelection {
1103         fn drop(&mut self) {
1104                 if self.is_owned && !<*mut nativeCoinSelection>::is_null(self.inner) {
1105                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1106                 }
1107         }
1108 }
1109 /// Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL.
1110 #[no_mangle]
1111 pub extern "C" fn CoinSelection_free(this_obj: CoinSelection) { }
1112 #[allow(unused)]
1113 /// Used only if an object of this type is returned as a trait impl by a method
1114 pub(crate) extern "C" fn CoinSelection_free_void(this_ptr: *mut c_void) {
1115         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCoinSelection) };
1116 }
1117 #[allow(unused)]
1118 impl CoinSelection {
1119         pub(crate) fn get_native_ref(&self) -> &'static nativeCoinSelection {
1120                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1121         }
1122         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCoinSelection {
1123                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1124         }
1125         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1126         pub(crate) fn take_inner(mut self) -> *mut nativeCoinSelection {
1127                 assert!(self.is_owned);
1128                 let ret = ObjOps::untweak_ptr(self.inner);
1129                 self.inner = core::ptr::null_mut();
1130                 ret
1131         }
1132 }
1133 /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
1134 /// requiring additional fees.
1135 #[no_mangle]
1136 pub extern "C" fn CoinSelection_get_confirmed_utxos(this_ptr: &CoinSelection) -> crate::c_types::derived::CVec_UtxoZ {
1137         let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmed_utxos;
1138         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::events::bump_transaction::Utxo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::events::bump_transaction::Utxo<>) as *mut _) }, is_owned: false } }); };
1139         local_inner_val.into()
1140 }
1141 /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
1142 /// requiring additional fees.
1143 #[no_mangle]
1144 pub extern "C" fn CoinSelection_set_confirmed_utxos(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::CVec_UtxoZ) {
1145         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1146         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmed_utxos = local_val;
1147 }
1148 /// An additional output tracking whether any change remained after coin selection. This output
1149 /// should always have a value above dust for its given `script_pubkey`. It should not be
1150 /// spent until the transaction it belongs to confirms to ensure mempool descendant limits are
1151 /// not met. This implies no other party should be able to spend it except us.
1152 #[no_mangle]
1153 pub extern "C" fn CoinSelection_get_change_output(this_ptr: &CoinSelection) -> crate::c_types::derived::COption_TxOutZ {
1154         let mut inner_val = &mut this_ptr.get_native_mut_ref().change_output;
1155         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxOutZ::None } else { crate::c_types::derived::COption_TxOutZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::TxOut::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) };
1156         local_inner_val
1157 }
1158 /// An additional output tracking whether any change remained after coin selection. This output
1159 /// should always have a value above dust for its given `script_pubkey`. It should not be
1160 /// spent until the transaction it belongs to confirms to ensure mempool descendant limits are
1161 /// not met. This implies no other party should be able to spend it except us.
1162 #[no_mangle]
1163 pub extern "C" fn CoinSelection_set_change_output(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::COption_TxOutZ) {
1164         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} };
1165         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.change_output = local_val;
1166 }
1167 /// Constructs a new CoinSelection given each field
1168 #[must_use]
1169 #[no_mangle]
1170 pub extern "C" fn CoinSelection_new(mut confirmed_utxos_arg: crate::c_types::derived::CVec_UtxoZ, mut change_output_arg: crate::c_types::derived::COption_TxOutZ) -> CoinSelection {
1171         let mut local_confirmed_utxos_arg = Vec::new(); for mut item in confirmed_utxos_arg.into_rust().drain(..) { local_confirmed_utxos_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1172         let mut local_change_output_arg = { /*change_output_arg*/ let change_output_arg_opt = change_output_arg; if change_output_arg_opt.is_none() { None } else { Some({ { { change_output_arg_opt.take() }.into_rust() }})} };
1173         CoinSelection { inner: ObjOps::heap_alloc(nativeCoinSelection {
1174                 confirmed_utxos: local_confirmed_utxos_arg,
1175                 change_output: local_change_output_arg,
1176         }), is_owned: true }
1177 }
1178 impl Clone for CoinSelection {
1179         fn clone(&self) -> Self {
1180                 Self {
1181                         inner: if <*mut nativeCoinSelection>::is_null(self.inner) { core::ptr::null_mut() } else {
1182                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1183                         is_owned: true,
1184                 }
1185         }
1186 }
1187 #[allow(unused)]
1188 /// Used only if an object of this type is returned as a trait impl by a method
1189 pub(crate) extern "C" fn CoinSelection_clone_void(this_ptr: *const c_void) -> *mut c_void {
1190         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCoinSelection)).clone() })) as *mut c_void
1191 }
1192 #[no_mangle]
1193 /// Creates a copy of the CoinSelection
1194 pub extern "C" fn CoinSelection_clone(orig: &CoinSelection) -> CoinSelection {
1195         orig.clone()
1196 }
1197 /// An abstraction over a bitcoin wallet that can perform coin selection over a set of UTXOs and can
1198 /// sign for them. The coin selection method aims to mimic Bitcoin Core's `fundrawtransaction` RPC,
1199 /// which most wallets should be able to satisfy. Otherwise, consider implementing [`WalletSource`],
1200 /// which can provide a default implementation of this trait when used with [`Wallet`].
1201 #[repr(C)]
1202 pub struct CoinSelectionSource {
1203         /// An opaque pointer which is passed to your function implementations as an argument.
1204         /// This has no meaning in the LDK, and can be NULL or any other value.
1205         pub this_arg: *mut c_void,
1206         /// Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are
1207         /// available to spend. Implementations are free to pick their coin selection algorithm of
1208         /// choice, as long as the following requirements are met:
1209         ///
1210         /// 1. `must_spend` contains a set of [`Input`]s that must be included in the transaction
1211         ///    throughout coin selection, but must not be returned as part of the result.
1212         /// 2. `must_pay_to` contains a set of [`TxOut`]s that must be included in the transaction
1213         ///    throughout coin selection. In some cases, like when funding an anchor transaction, this
1214         ///    set is empty. Implementations should ensure they handle this correctly on their end,
1215         ///    e.g., Bitcoin Core's `fundrawtransaction` RPC requires at least one output to be
1216         ///    provided, in which case a zero-value empty OP_RETURN output can be used instead.
1217         /// 3. Enough inputs must be selected/contributed for the resulting transaction (including the
1218         ///    inputs and outputs noted above) to meet `target_feerate_sat_per_1000_weight`.
1219         ///
1220         /// Implementations must take note that [`Input::satisfaction_weight`] only tracks the weight of
1221         /// the input's `script_sig` and `witness`. Some wallets, like Bitcoin Core's, may require
1222         /// providing the full input weight. Failing to do so may lead to underestimating fee bumps and
1223         /// delaying block inclusion.
1224         ///
1225         /// The `claim_id` must map to the set of external UTXOs assigned to the claim, such that they
1226         /// can be re-used within new fee-bumped iterations of the original claiming transaction,
1227         /// ensuring that claims don't double spend each other. If a specific `claim_id` has never had a
1228         /// transaction associated with it, and all of the available UTXOs have already been assigned to
1229         /// other claims, implementations must be willing to double spend their UTXOs. The choice of
1230         /// which UTXOs to double spend is left to the implementation, but it must strive to keep the
1231         /// set of other claims being double spent to a minimum.
1232         pub select_confirmed_utxos: extern "C" fn (this_arg: *const c_void, claim_id: crate::c_types::ThirtyTwoBytes, must_spend: crate::c_types::derived::CVec_InputZ, must_pay_to: crate::c_types::derived::CVec_TxOutZ, target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ,
1233         /// Signs and provides the full witness for all inputs within the transaction known to the
1234         /// trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]).
1235         pub sign_tx: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ,
1236         /// Frees any resources associated with this object given its this_arg pointer.
1237         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1238         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1239 }
1240 unsafe impl Send for CoinSelectionSource {}
1241 unsafe impl Sync for CoinSelectionSource {}
1242 #[no_mangle]
1243 pub(crate) extern "C" fn CoinSelectionSource_clone_fields(orig: &CoinSelectionSource) -> CoinSelectionSource {
1244         CoinSelectionSource {
1245                 this_arg: orig.this_arg,
1246                 select_confirmed_utxos: Clone::clone(&orig.select_confirmed_utxos),
1247                 sign_tx: Clone::clone(&orig.sign_tx),
1248                 free: Clone::clone(&orig.free),
1249         }
1250 }
1251
1252 use lightning::events::bump_transaction::CoinSelectionSource as rustCoinSelectionSource;
1253 impl rustCoinSelectionSource for CoinSelectionSource {
1254         fn select_confirmed_utxos(&self, mut claim_id: lightning::chain::ClaimId, mut must_spend: Vec<lightning::events::bump_transaction::Input>, mut must_pay_to: &[bitcoin::TxOut], mut target_feerate_sat_per_1000_weight: u32) -> Result<lightning::events::bump_transaction::CoinSelection, ()> {
1255                 let mut local_must_spend = Vec::new(); for mut item in must_spend.drain(..) { local_must_spend.push( { crate::lightning::events::bump_transaction::Input { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1256                 let mut local_must_pay_to_clone = Vec::new(); local_must_pay_to_clone.extend_from_slice(must_pay_to); let mut must_pay_to = local_must_pay_to_clone; let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.drain(..) { local_must_pay_to.push( { crate::c_types::TxOut::from_rust(&item) }); };
1257                 let mut ret = (self.select_confirmed_utxos)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, local_must_spend.into(), local_must_pay_to.into(), target_feerate_sat_per_1000_weight);
1258                 let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1259                 local_ret
1260         }
1261         fn sign_tx(&self, mut tx: bitcoin::Transaction) -> Result<bitcoin::Transaction, ()> {
1262                 let mut ret = (self.sign_tx)(self.this_arg, crate::c_types::Transaction::from_bitcoin(&tx));
1263                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1264                 local_ret
1265         }
1266 }
1267
1268 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1269 // directly as a Deref trait in higher-level structs:
1270 impl core::ops::Deref for CoinSelectionSource {
1271         type Target = Self;
1272         fn deref(&self) -> &Self {
1273                 self
1274         }
1275 }
1276 /// Calls the free function if one is set
1277 #[no_mangle]
1278 pub extern "C" fn CoinSelectionSource_free(this_ptr: CoinSelectionSource) { }
1279 impl Drop for CoinSelectionSource {
1280         fn drop(&mut self) {
1281                 if let Some(f) = self.free {
1282                         f(self.this_arg);
1283                 }
1284         }
1285 }
1286 /// An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
1287 /// provide a default implementation to [`CoinSelectionSource`].
1288 #[repr(C)]
1289 pub struct WalletSource {
1290         /// An opaque pointer which is passed to your function implementations as an argument.
1291         /// This has no meaning in the LDK, and can be NULL or any other value.
1292         pub this_arg: *mut c_void,
1293         /// Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
1294         pub list_confirmed_utxos: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_UtxoZNoneZ,
1295         /// Returns a script to use for change above dust resulting from a successful coin selection
1296         /// attempt.
1297         pub get_change_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_ScriptNoneZ,
1298         /// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
1299         /// the transaction known to the wallet (i.e., any provided via
1300         /// [`WalletSource::list_confirmed_utxos`]).
1301         pub sign_tx: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ,
1302         /// Frees any resources associated with this object given its this_arg pointer.
1303         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1304         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1305 }
1306 unsafe impl Send for WalletSource {}
1307 unsafe impl Sync for WalletSource {}
1308 #[no_mangle]
1309 pub(crate) extern "C" fn WalletSource_clone_fields(orig: &WalletSource) -> WalletSource {
1310         WalletSource {
1311                 this_arg: orig.this_arg,
1312                 list_confirmed_utxos: Clone::clone(&orig.list_confirmed_utxos),
1313                 get_change_script: Clone::clone(&orig.get_change_script),
1314                 sign_tx: Clone::clone(&orig.sign_tx),
1315                 free: Clone::clone(&orig.free),
1316         }
1317 }
1318
1319 use lightning::events::bump_transaction::WalletSource as rustWalletSource;
1320 impl rustWalletSource for WalletSource {
1321         fn list_confirmed_utxos(&self) -> Result<Vec<lightning::events::bump_transaction::Utxo>, ()> {
1322                 let mut ret = (self.list_confirmed_utxos)(self.this_arg);
1323                 let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1324                 local_ret
1325         }
1326         fn get_change_script(&self) -> Result<bitcoin::Script, ()> {
1327                 let mut ret = (self.get_change_script)(self.this_arg);
1328                 let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::Script::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1329                 local_ret
1330         }
1331         fn sign_tx(&self, mut tx: bitcoin::Transaction) -> Result<bitcoin::Transaction, ()> {
1332                 let mut ret = (self.sign_tx)(self.this_arg, crate::c_types::Transaction::from_bitcoin(&tx));
1333                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
1334                 local_ret
1335         }
1336 }
1337
1338 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1339 // directly as a Deref trait in higher-level structs:
1340 impl core::ops::Deref for WalletSource {
1341         type Target = Self;
1342         fn deref(&self) -> &Self {
1343                 self
1344         }
1345 }
1346 /// Calls the free function if one is set
1347 #[no_mangle]
1348 pub extern "C" fn WalletSource_free(this_ptr: WalletSource) { }
1349 impl Drop for WalletSource {
1350         fn drop(&mut self) {
1351                 if let Some(f) = self.free {
1352                         f(self.this_arg);
1353                 }
1354         }
1355 }
1356
1357 use lightning::events::bump_transaction::Wallet as nativeWalletImport;
1358 pub(crate) type nativeWallet = nativeWalletImport<crate::lightning::events::bump_transaction::WalletSource, crate::lightning::util::logger::Logger>;
1359
1360 /// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would
1361 /// avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double
1362 /// spends may happen.
1363 #[must_use]
1364 #[repr(C)]
1365 pub struct Wallet {
1366         /// A pointer to the opaque Rust object.
1367
1368         /// Nearly everywhere, inner must be non-null, however in places where
1369         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1370         pub inner: *mut nativeWallet,
1371         /// Indicates that this is the only struct which contains the same pointer.
1372
1373         /// Rust functions which take ownership of an object provided via an argument require
1374         /// this to be true and invalidate the object pointed to by inner.
1375         pub is_owned: bool,
1376 }
1377
1378 impl Drop for Wallet {
1379         fn drop(&mut self) {
1380                 if self.is_owned && !<*mut nativeWallet>::is_null(self.inner) {
1381                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1382                 }
1383         }
1384 }
1385 /// Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL.
1386 #[no_mangle]
1387 pub extern "C" fn Wallet_free(this_obj: Wallet) { }
1388 #[allow(unused)]
1389 /// Used only if an object of this type is returned as a trait impl by a method
1390 pub(crate) extern "C" fn Wallet_free_void(this_ptr: *mut c_void) {
1391         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWallet) };
1392 }
1393 #[allow(unused)]
1394 impl Wallet {
1395         pub(crate) fn get_native_ref(&self) -> &'static nativeWallet {
1396                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1397         }
1398         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWallet {
1399                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1400         }
1401         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1402         pub(crate) fn take_inner(mut self) -> *mut nativeWallet {
1403                 assert!(self.is_owned);
1404                 let ret = ObjOps::untweak_ptr(self.inner);
1405                 self.inner = core::ptr::null_mut();
1406                 ret
1407         }
1408 }
1409 /// Returns a new instance backed by the given [`WalletSource`] that serves as an implementation
1410 /// of [`CoinSelectionSource`].
1411 #[must_use]
1412 #[no_mangle]
1413 pub extern "C" fn Wallet_new(mut source: crate::lightning::events::bump_transaction::WalletSource, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::events::bump_transaction::Wallet {
1414         let mut ret = lightning::events::bump_transaction::Wallet::new(source, logger);
1415         crate::lightning::events::bump_transaction::Wallet { inner: ObjOps::heap_alloc(ret), is_owned: true }
1416 }
1417
1418 impl From<nativeWallet> for crate::lightning::events::bump_transaction::CoinSelectionSource {
1419         fn from(obj: nativeWallet) -> Self {
1420                 let mut rust_obj = Wallet { inner: ObjOps::heap_alloc(obj), is_owned: true };
1421                 let mut ret = Wallet_as_CoinSelectionSource(&rust_obj);
1422                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
1423                 rust_obj.inner = core::ptr::null_mut();
1424                 ret.free = Some(Wallet_free_void);
1425                 ret
1426         }
1427 }
1428 /// Constructs a new CoinSelectionSource which calls the relevant methods on this_arg.
1429 /// This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is
1430 #[no_mangle]
1431 pub extern "C" fn Wallet_as_CoinSelectionSource(this_arg: &Wallet) -> crate::lightning::events::bump_transaction::CoinSelectionSource {
1432         crate::lightning::events::bump_transaction::CoinSelectionSource {
1433                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
1434                 free: None,
1435                 select_confirmed_utxos: Wallet_CoinSelectionSource_select_confirmed_utxos,
1436                 sign_tx: Wallet_CoinSelectionSource_sign_tx,
1437         }
1438 }
1439
1440 #[must_use]
1441 extern "C" fn Wallet_CoinSelectionSource_select_confirmed_utxos(this_arg: *const c_void, mut claim_id: crate::c_types::ThirtyTwoBytes, mut must_spend: crate::c_types::derived::CVec_InputZ, mut must_pay_to: crate::c_types::derived::CVec_TxOutZ, mut target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ {
1442         let mut local_must_spend = Vec::new(); for mut item in must_spend.into_rust().drain(..) { local_must_spend.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1443         let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.into_rust().drain(..) { local_must_pay_to.push( { item.into_rust() }); };
1444         let mut ret = <nativeWallet as lightning::events::bump_transaction::CoinSelectionSource<>>::select_confirmed_utxos(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::lightning::chain::ClaimId(claim_id.data), local_must_spend, &local_must_pay_to[..], target_feerate_sat_per_1000_weight);
1445         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::bump_transaction::CoinSelection { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1446         local_ret
1447 }
1448 #[must_use]
1449 extern "C" fn Wallet_CoinSelectionSource_sign_tx(this_arg: *const c_void, mut tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ {
1450         let mut ret = <nativeWallet as lightning::events::bump_transaction::CoinSelectionSource<>>::sign_tx(unsafe { &mut *(this_arg as *mut nativeWallet) }, tx.into_bitcoin());
1451         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1452         local_ret
1453 }
1454
1455
1456 use lightning::events::bump_transaction::BumpTransactionEventHandler as nativeBumpTransactionEventHandlerImport;
1457 pub(crate) type nativeBumpTransactionEventHandler = nativeBumpTransactionEventHandlerImport<crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::events::bump_transaction::CoinSelectionSource, crate::lightning::sign::SignerProvider, crate::lightning::util::logger::Logger>;
1458
1459 /// A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a
1460 /// [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or
1461 /// Replace-By-Fee (RBF).
1462 ///
1463 /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
1464 #[must_use]
1465 #[repr(C)]
1466 pub struct BumpTransactionEventHandler {
1467         /// A pointer to the opaque Rust object.
1468
1469         /// Nearly everywhere, inner must be non-null, however in places where
1470         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1471         pub inner: *mut nativeBumpTransactionEventHandler,
1472         /// Indicates that this is the only struct which contains the same pointer.
1473
1474         /// Rust functions which take ownership of an object provided via an argument require
1475         /// this to be true and invalidate the object pointed to by inner.
1476         pub is_owned: bool,
1477 }
1478
1479 impl Drop for BumpTransactionEventHandler {
1480         fn drop(&mut self) {
1481                 if self.is_owned && !<*mut nativeBumpTransactionEventHandler>::is_null(self.inner) {
1482                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1483                 }
1484         }
1485 }
1486 /// Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL.
1487 #[no_mangle]
1488 pub extern "C" fn BumpTransactionEventHandler_free(this_obj: BumpTransactionEventHandler) { }
1489 #[allow(unused)]
1490 /// Used only if an object of this type is returned as a trait impl by a method
1491 pub(crate) extern "C" fn BumpTransactionEventHandler_free_void(this_ptr: *mut c_void) {
1492         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBumpTransactionEventHandler) };
1493 }
1494 #[allow(unused)]
1495 impl BumpTransactionEventHandler {
1496         pub(crate) fn get_native_ref(&self) -> &'static nativeBumpTransactionEventHandler {
1497                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1498         }
1499         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBumpTransactionEventHandler {
1500                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1501         }
1502         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1503         pub(crate) fn take_inner(mut self) -> *mut nativeBumpTransactionEventHandler {
1504                 assert!(self.is_owned);
1505                 let ret = ObjOps::untweak_ptr(self.inner);
1506                 self.inner = core::ptr::null_mut();
1507                 ret
1508         }
1509 }
1510 /// Returns a new instance capable of handling [`Event::BumpTransaction`] events.
1511 ///
1512 /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
1513 #[must_use]
1514 #[no_mangle]
1515 pub extern "C" fn BumpTransactionEventHandler_new(mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut utxo_source: crate::lightning::events::bump_transaction::CoinSelectionSource, mut signer_provider: crate::lightning::sign::SignerProvider, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::events::bump_transaction::BumpTransactionEventHandler {
1516         let mut ret = lightning::events::bump_transaction::BumpTransactionEventHandler::new(broadcaster, utxo_source, signer_provider, logger);
1517         crate::lightning::events::bump_transaction::BumpTransactionEventHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
1518 }
1519
1520 /// Handles all variants of [`BumpTransactionEvent`].
1521 #[no_mangle]
1522 pub extern "C" fn BumpTransactionEventHandler_handle_event(this_arg: &crate::lightning::events::bump_transaction::BumpTransactionEventHandler, event: &crate::lightning::events::bump_transaction::BumpTransactionEvent) {
1523         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_event(&event.to_native())
1524 }
1525