Update auto-generated bindings to LDK 0.0.121
[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 alloc::string::String;
15 use core::ffi::c_void;
16 use core::convert::Infallible;
17 use bitcoin::hashes::Hash;
18 use crate::c_types::*;
19 #[cfg(feature="no-std")]
20 use alloc::{vec::Vec, boxed::Box};
21
22
23 use lightning::events::bump_transaction::AnchorDescriptor as nativeAnchorDescriptorImport;
24 pub(crate) type nativeAnchorDescriptor = nativeAnchorDescriptorImport;
25
26 /// A descriptor used to sign for a commitment transaction's anchor output.
27 #[must_use]
28 #[repr(C)]
29 pub struct AnchorDescriptor {
30         /// A pointer to the opaque Rust object.
31
32         /// Nearly everywhere, inner must be non-null, however in places where
33         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
34         pub inner: *mut nativeAnchorDescriptor,
35         /// Indicates that this is the only struct which contains the same pointer.
36
37         /// Rust functions which take ownership of an object provided via an argument require
38         /// this to be true and invalidate the object pointed to by inner.
39         pub is_owned: bool,
40 }
41
42 impl Drop for AnchorDescriptor {
43         fn drop(&mut self) {
44                 if self.is_owned && !<*mut nativeAnchorDescriptor>::is_null(self.inner) {
45                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
46                 }
47         }
48 }
49 /// Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL.
50 #[no_mangle]
51 pub extern "C" fn AnchorDescriptor_free(this_obj: AnchorDescriptor) { }
52 #[allow(unused)]
53 /// Used only if an object of this type is returned as a trait impl by a method
54 pub(crate) extern "C" fn AnchorDescriptor_free_void(this_ptr: *mut c_void) {
55         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnchorDescriptor) };
56 }
57 #[allow(unused)]
58 impl AnchorDescriptor {
59         pub(crate) fn get_native_ref(&self) -> &'static nativeAnchorDescriptor {
60                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
61         }
62         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnchorDescriptor {
63                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
64         }
65         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
66         pub(crate) fn take_inner(mut self) -> *mut nativeAnchorDescriptor {
67                 assert!(self.is_owned);
68                 let ret = ObjOps::untweak_ptr(self.inner);
69                 self.inner = core::ptr::null_mut();
70                 ret
71         }
72 }
73 /// The parameters required to derive the signer for the anchor input.
74 #[no_mangle]
75 pub extern "C" fn AnchorDescriptor_get_channel_derivation_parameters(this_ptr: &AnchorDescriptor) -> crate::lightning::sign::ChannelDerivationParameters {
76         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters;
77         crate::lightning::sign::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::sign::ChannelDerivationParameters<>) as *mut _) }, is_owned: false }
78 }
79 /// The parameters required to derive the signer for the anchor input.
80 #[no_mangle]
81 pub extern "C" fn AnchorDescriptor_set_channel_derivation_parameters(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::sign::ChannelDerivationParameters) {
82         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) };
83 }
84 /// The transaction input's outpoint corresponding to the commitment transaction's anchor
85 /// output.
86 #[no_mangle]
87 pub extern "C" fn AnchorDescriptor_get_outpoint(this_ptr: &AnchorDescriptor) -> crate::lightning::chain::transaction::OutPoint {
88         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
89         crate::c_types::bitcoin_to_C_outpoint(inner_val)
90 }
91 /// The transaction input's outpoint corresponding to the commitment transaction's anchor
92 /// output.
93 #[no_mangle]
94 pub extern "C" fn AnchorDescriptor_set_outpoint(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) {
95         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
96 }
97 /// Constructs a new AnchorDescriptor given each field
98 #[must_use]
99 #[no_mangle]
100 pub extern "C" fn AnchorDescriptor_new(mut channel_derivation_parameters_arg: crate::lightning::sign::ChannelDerivationParameters, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint) -> AnchorDescriptor {
101         AnchorDescriptor { inner: ObjOps::heap_alloc(nativeAnchorDescriptor {
102                 channel_derivation_parameters: *unsafe { Box::from_raw(channel_derivation_parameters_arg.take_inner()) },
103                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
104         }), is_owned: true }
105 }
106 impl Clone for AnchorDescriptor {
107         fn clone(&self) -> Self {
108                 Self {
109                         inner: if <*mut nativeAnchorDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
110                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
111                         is_owned: true,
112                 }
113         }
114 }
115 #[allow(unused)]
116 /// Used only if an object of this type is returned as a trait impl by a method
117 pub(crate) extern "C" fn AnchorDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
118         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnchorDescriptor)).clone() })) as *mut c_void
119 }
120 #[no_mangle]
121 /// Creates a copy of the AnchorDescriptor
122 pub extern "C" fn AnchorDescriptor_clone(orig: &AnchorDescriptor) -> AnchorDescriptor {
123         orig.clone()
124 }
125 /// Get a string which allows debug introspection of a AnchorDescriptor object
126 pub extern "C" fn AnchorDescriptor_debug_str_void(o: *const c_void) -> Str {
127         alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::bump_transaction::AnchorDescriptor }).into()}
128 /// Checks if two AnchorDescriptors contain equal inner contents.
129 /// This ignores pointers and is_owned flags and looks at the values in fields.
130 /// Two objects with NULL inner values will be considered "equal" here.
131 #[no_mangle]
132 pub extern "C" fn AnchorDescriptor_eq(a: &AnchorDescriptor, b: &AnchorDescriptor) -> bool {
133         if a.inner == b.inner { return true; }
134         if a.inner.is_null() || b.inner.is_null() { return false; }
135         if a.get_native_ref() == b.get_native_ref() { true } else { false }
136 }
137 /// Returns the UTXO to be spent by the anchor input, which can be obtained via
138 /// [`Self::unsigned_tx_input`].
139 #[must_use]
140 #[no_mangle]
141 pub extern "C" fn AnchorDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxOut {
142         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo();
143         crate::c_types::TxOut::from_rust(&ret)
144 }
145
146 /// Returns the unsigned transaction input spending the anchor output in the commitment
147 /// transaction.
148 #[must_use]
149 #[no_mangle]
150 pub extern "C" fn AnchorDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxIn {
151         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input();
152         crate::c_types::TxIn::from_rust(&ret)
153 }
154
155 /// Returns the witness script of the anchor output in the commitment transaction.
156 #[must_use]
157 #[no_mangle]
158 pub extern "C" fn AnchorDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::derived::CVec_u8Z {
159         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script();
160         ret.to_bytes().into()
161 }
162
163 /// Returns the fully signed witness required to spend the anchor output in the commitment
164 /// transaction.
165 #[must_use]
166 #[no_mangle]
167 pub extern "C" fn AnchorDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, mut signature: crate::c_types::ECDSASignature) -> crate::c_types::Witness {
168         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust());
169         crate::c_types::Witness::from_bitcoin(&ret)
170 }
171
172 /// Derives the channel signer required to sign the anchor input.
173 #[must_use]
174 #[no_mangle]
175 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::ecdsa::WriteableEcdsaChannelSigner {
176         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider);
177         Into::into(ret)
178 }
179
180 /// Represents the different types of transactions, originating from LDK, to be bumped.
181 #[derive(Clone)]
182 #[must_use]
183 #[repr(C)]
184 pub enum BumpTransactionEvent {
185         /// Indicates that a channel featuring anchor outputs is to be closed by broadcasting the local
186         /// commitment transaction. Since commitment transactions have a static feerate pre-agreed upon,
187         /// they may need additional fees to be attached through a child transaction using the popular
188         /// [Child-Pays-For-Parent](https://bitcoinops.org/en/topics/cpfp) fee bumping technique. This
189         /// child transaction must include the anchor input described within `anchor_descriptor` along
190         /// with additional inputs to meet the target feerate. Failure to meet the target feerate
191         /// decreases the confirmation odds of the transaction package (which includes the commitment
192         /// and child anchor transactions), possibly resulting in a loss of funds. Once the transaction
193         /// is constructed, it must be fully signed for and broadcast by the consumer of the event
194         /// along with the `commitment_tx` enclosed. Note that the `commitment_tx` must always be
195         /// broadcast first, as the child anchor transaction depends on it.
196         ///
197         /// The consumer should be able to sign for any of the additional inputs included within the
198         /// child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be
199         /// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature
200         /// can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be
201         /// provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the
202         /// full witness required to spend.
203         ///
204         /// It is possible to receive more than one instance of this event if a valid child anchor
205         /// transaction is never broadcast or is but not with a sufficient fee to be mined. Care should
206         /// be taken by the consumer of the event to ensure any future iterations of the child anchor
207         /// transaction adhere to the [Replace-By-Fee
208         /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md)
209         /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of
210         /// these events is not user-controlled, users may ignore/drop the event if they are no longer
211         /// able to commit external confirmed funds to the child anchor transaction.
212         ///
213         /// The set of `pending_htlcs` on the commitment transaction to be broadcast can be inspected to
214         /// determine whether a significant portion of the channel's funds are allocated to HTLCs,
215         /// enabling users to make their own decisions regarding the importance of the commitment
216         /// transaction's confirmation. Note that this is not required, but simply exists as an option
217         /// for users to override LDK's behavior. On commitments with no HTLCs (indicated by those with
218         /// an empty `pending_htlcs`), confirmation of the commitment transaction can be considered to
219         /// be not urgent.
220         ///
221         /// [`EcdsaChannelSigner`]: crate::sign::ecdsa::EcdsaChannelSigner
222         /// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::ecdsa::EcdsaChannelSigner::sign_holder_anchor_input
223         /// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness
224         ChannelClose {
225                 /// The unique identifier for the claim of the anchor output in the commitment transaction.
226                 ///
227                 /// The identifier must map to the set of external UTXOs assigned to the claim, such that
228                 /// they can be reused when a new claim with the same identifier needs to be made, resulting
229                 /// in a fee-bumping attempt.
230                 claim_id: crate::c_types::ThirtyTwoBytes,
231                 /// The target feerate that the transaction package, which consists of the commitment
232                 /// transaction and the to-be-crafted child anchor transaction, must meet.
233                 package_target_feerate_sat_per_1000_weight: u32,
234                 /// The channel's commitment transaction to bump the fee of. This transaction should be
235                 /// broadcast along with the anchor transaction constructed as a result of consuming this
236                 /// event.
237                 commitment_tx: crate::c_types::Transaction,
238                 /// The absolute fee in satoshis of the commitment transaction. This can be used along the
239                 /// with weight of the commitment transaction to determine its feerate.
240                 commitment_tx_fee_satoshis: u64,
241                 /// The descriptor to sign the anchor input of the anchor transaction constructed as a
242                 /// result of consuming this event.
243                 anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor,
244                 /// The set of pending HTLCs on the commitment transaction that need to be resolved once the
245                 /// commitment transaction confirms.
246                 pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ,
247         },
248         /// Indicates that a channel featuring anchor outputs has unilaterally closed on-chain by a
249         /// holder commitment transaction and its HTLC(s) need to be resolved on-chain. With the
250         /// zero-HTLC-transaction-fee variant of anchor outputs, the pre-signed HTLC
251         /// transactions have a zero fee, thus requiring additional inputs and/or outputs to be attached
252         /// for a timely confirmation within the chain. These additional inputs and/or outputs must be
253         /// appended to the resulting HTLC transaction to meet the target feerate. Failure to meet the
254         /// target feerate decreases the confirmation odds of the transaction, possibly resulting in a
255         /// loss of funds. Once the transaction meets the target feerate, it must be signed for and
256         /// broadcast by the consumer of the event.
257         ///
258         /// The consumer should be able to sign for any of the non-HTLC inputs added to the resulting
259         /// HTLC transaction. To sign HTLC inputs, an [`EcdsaChannelSigner`] should be re-derived
260         /// through [`HTLCDescriptor::derive_channel_signer`]. Each HTLC input's signature can be
261         /// computed with [`EcdsaChannelSigner::sign_holder_htlc_transaction`], which can then be
262         /// provided to [`HTLCDescriptor::tx_input_witness`] to obtain the fully signed witness required
263         /// to spend.
264         ///
265         /// It is possible to receive more than one instance of this event if a valid HTLC transaction
266         /// is never broadcast or is but not with a sufficient fee to be mined. Care should be taken by
267         /// the consumer of the event to ensure any future iterations of the HTLC transaction adhere to
268         /// the [Replace-By-Fee
269         /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md)
270         /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of
271         /// these events is not user-controlled, users may ignore/drop the event if either they are no
272         /// longer able to commit external confirmed funds to the HTLC transaction or the fee committed
273         /// to the HTLC transaction is greater in value than the HTLCs being claimed.
274         ///
275         /// [`EcdsaChannelSigner`]: crate::sign::ecdsa::EcdsaChannelSigner
276         /// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::ecdsa::EcdsaChannelSigner::sign_holder_htlc_transaction
277         HTLCResolution {
278                 /// The unique identifier for the claim of the HTLCs in the confirmed commitment
279                 /// transaction.
280                 ///
281                 /// The identifier must map to the set of external UTXOs assigned to the claim, such that
282                 /// they can be reused when a new claim with the same identifier needs to be made, resulting
283                 /// in a fee-bumping attempt.
284                 claim_id: crate::c_types::ThirtyTwoBytes,
285                 /// The target feerate that the resulting HTLC transaction must meet.
286                 target_feerate_sat_per_1000_weight: u32,
287                 /// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably
288                 /// by the same transaction.
289                 htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ,
290                 /// The locktime required for the resulting HTLC transaction.
291                 tx_lock_time: u32,
292         },
293 }
294 use lightning::events::bump_transaction::BumpTransactionEvent as BumpTransactionEventImport;
295 pub(crate) type nativeBumpTransactionEvent = BumpTransactionEventImport;
296
297 impl BumpTransactionEvent {
298         #[allow(unused)]
299         pub(crate) fn to_native(&self) -> nativeBumpTransactionEvent {
300                 match self {
301                         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, } => {
302                                 let mut claim_id_nonref = Clone::clone(claim_id);
303                                 let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight);
304                                 let mut commitment_tx_nonref = Clone::clone(commitment_tx);
305                                 let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis);
306                                 let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor);
307                                 let mut pending_htlcs_nonref = Clone::clone(pending_htlcs);
308                                 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()) } }); };
309                                 nativeBumpTransactionEvent::ChannelClose {
310                                         claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data),
311                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref,
312                                         commitment_tx: commitment_tx_nonref.into_bitcoin(),
313                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref,
314                                         anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor_nonref.take_inner()) },
315                                         pending_htlcs: local_pending_htlcs_nonref,
316                                 }
317                         },
318                         BumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => {
319                                 let mut claim_id_nonref = Clone::clone(claim_id);
320                                 let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight);
321                                 let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors);
322                                 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()) } }); };
323                                 let mut tx_lock_time_nonref = Clone::clone(tx_lock_time);
324                                 nativeBumpTransactionEvent::HTLCResolution {
325                                         claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data),
326                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref,
327                                         htlc_descriptors: local_htlc_descriptors_nonref,
328                                         tx_lock_time: ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus(tx_lock_time_nonref),
329                                 }
330                         },
331                 }
332         }
333         #[allow(unused)]
334         pub(crate) fn into_native(self) -> nativeBumpTransactionEvent {
335                 match self {
336                         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, } => {
337                                 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()) } }); };
338                                 nativeBumpTransactionEvent::ChannelClose {
339                                         claim_id: ::lightning::chain::ClaimId(claim_id.data),
340                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight,
341                                         commitment_tx: commitment_tx.into_bitcoin(),
342                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis,
343                                         anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor.take_inner()) },
344                                         pending_htlcs: local_pending_htlcs,
345                                 }
346                         },
347                         BumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => {
348                                 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()) } }); };
349                                 nativeBumpTransactionEvent::HTLCResolution {
350                                         claim_id: ::lightning::chain::ClaimId(claim_id.data),
351                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight,
352                                         htlc_descriptors: local_htlc_descriptors,
353                                         tx_lock_time: ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus(tx_lock_time),
354                                 }
355                         },
356                 }
357         }
358         #[allow(unused)]
359         pub(crate) fn from_native(native: &BumpTransactionEventImport) -> Self {
360                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBumpTransactionEvent) };
361                 match native {
362                         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, } => {
363                                 let mut claim_id_nonref = Clone::clone(claim_id);
364                                 let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight);
365                                 let mut commitment_tx_nonref = Clone::clone(commitment_tx);
366                                 let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis);
367                                 let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor);
368                                 let mut pending_htlcs_nonref = Clone::clone(pending_htlcs);
369                                 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 } }); };
370                                 BumpTransactionEvent::ChannelClose {
371                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 },
372                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref,
373                                         commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx_nonref),
374                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref,
375                                         anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor_nonref), is_owned: true },
376                                         pending_htlcs: local_pending_htlcs_nonref.into(),
377                                 }
378                         },
379                         nativeBumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => {
380                                 let mut claim_id_nonref = Clone::clone(claim_id);
381                                 let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight);
382                                 let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors);
383                                 let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.drain(..) { local_htlc_descriptors_nonref.push( { crate::lightning::sign::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
384                                 let mut tx_lock_time_nonref = Clone::clone(tx_lock_time);
385                                 BumpTransactionEvent::HTLCResolution {
386                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 },
387                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref,
388                                         htlc_descriptors: local_htlc_descriptors_nonref.into(),
389                                         tx_lock_time: tx_lock_time_nonref.to_consensus_u32(),
390                                 }
391                         },
392                 }
393         }
394         #[allow(unused)]
395         pub(crate) fn native_into(native: nativeBumpTransactionEvent) -> Self {
396                 match native {
397                         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, } => {
398                                 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 } }); };
399                                 BumpTransactionEvent::ChannelClose {
400                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 },
401                                         package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight,
402                                         commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx),
403                                         commitment_tx_fee_satoshis: commitment_tx_fee_satoshis,
404                                         anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor), is_owned: true },
405                                         pending_htlcs: local_pending_htlcs.into(),
406                                 }
407                         },
408                         nativeBumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => {
409                                 let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.drain(..) { local_htlc_descriptors.push( { crate::lightning::sign::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
410                                 BumpTransactionEvent::HTLCResolution {
411                                         claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 },
412                                         target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight,
413                                         htlc_descriptors: local_htlc_descriptors.into(),
414                                         tx_lock_time: tx_lock_time.to_consensus_u32(),
415                                 }
416                         },
417                 }
418         }
419 }
420 /// Frees any resources used by the BumpTransactionEvent
421 #[no_mangle]
422 pub extern "C" fn BumpTransactionEvent_free(this_ptr: BumpTransactionEvent) { }
423 /// Creates a copy of the BumpTransactionEvent
424 #[no_mangle]
425 pub extern "C" fn BumpTransactionEvent_clone(orig: &BumpTransactionEvent) -> BumpTransactionEvent {
426         orig.clone()
427 }
428 #[allow(unused)]
429 /// Used only if an object of this type is returned as a trait impl by a method
430 pub(crate) extern "C" fn BumpTransactionEvent_clone_void(this_ptr: *const c_void) -> *mut c_void {
431         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const BumpTransactionEvent)).clone() })) as *mut c_void
432 }
433 #[allow(unused)]
434 /// Used only if an object of this type is returned as a trait impl by a method
435 pub(crate) extern "C" fn BumpTransactionEvent_free_void(this_ptr: *mut c_void) {
436         let _ = unsafe { Box::from_raw(this_ptr as *mut BumpTransactionEvent) };
437 }
438 #[no_mangle]
439 /// Utility method to constructs a new ChannelClose-variant BumpTransactionEvent
440 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 {
441         BumpTransactionEvent::ChannelClose {
442                 claim_id,
443                 package_target_feerate_sat_per_1000_weight,
444                 commitment_tx,
445                 commitment_tx_fee_satoshis,
446                 anchor_descriptor,
447                 pending_htlcs,
448         }
449 }
450 #[no_mangle]
451 /// Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent
452 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 {
453         BumpTransactionEvent::HTLCResolution {
454                 claim_id,
455                 target_feerate_sat_per_1000_weight,
456                 htlc_descriptors,
457                 tx_lock_time,
458         }
459 }
460 /// Get a string which allows debug introspection of a BumpTransactionEvent object
461 pub extern "C" fn BumpTransactionEvent_debug_str_void(o: *const c_void) -> Str {
462         alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::bump_transaction::BumpTransactionEvent }).into()}
463 /// Checks if two BumpTransactionEvents contain equal inner contents.
464 /// This ignores pointers and is_owned flags and looks at the values in fields.
465 #[no_mangle]
466 pub extern "C" fn BumpTransactionEvent_eq(a: &BumpTransactionEvent, b: &BumpTransactionEvent) -> bool {
467         if &a.to_native() == &b.to_native() { true } else { false }
468 }
469
470 use lightning::events::bump_transaction::Input as nativeInputImport;
471 pub(crate) type nativeInput = nativeInputImport;
472
473 /// An input that must be included in a transaction when performing coin selection through
474 /// [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it
475 /// must have an empty [`TxIn::script_sig`] when spent.
476 #[must_use]
477 #[repr(C)]
478 pub struct Input {
479         /// A pointer to the opaque Rust object.
480
481         /// Nearly everywhere, inner must be non-null, however in places where
482         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
483         pub inner: *mut nativeInput,
484         /// Indicates that this is the only struct which contains the same pointer.
485
486         /// Rust functions which take ownership of an object provided via an argument require
487         /// this to be true and invalidate the object pointed to by inner.
488         pub is_owned: bool,
489 }
490
491 impl Drop for Input {
492         fn drop(&mut self) {
493                 if self.is_owned && !<*mut nativeInput>::is_null(self.inner) {
494                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
495                 }
496         }
497 }
498 /// Frees any resources used by the Input, if is_owned is set and inner is non-NULL.
499 #[no_mangle]
500 pub extern "C" fn Input_free(this_obj: Input) { }
501 #[allow(unused)]
502 /// Used only if an object of this type is returned as a trait impl by a method
503 pub(crate) extern "C" fn Input_free_void(this_ptr: *mut c_void) {
504         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInput) };
505 }
506 #[allow(unused)]
507 impl Input {
508         pub(crate) fn get_native_ref(&self) -> &'static nativeInput {
509                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
510         }
511         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInput {
512                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
513         }
514         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
515         pub(crate) fn take_inner(mut self) -> *mut nativeInput {
516                 assert!(self.is_owned);
517                 let ret = ObjOps::untweak_ptr(self.inner);
518                 self.inner = core::ptr::null_mut();
519                 ret
520         }
521 }
522 /// The unique identifier of the input.
523 #[no_mangle]
524 pub extern "C" fn Input_get_outpoint(this_ptr: &Input) -> crate::lightning::chain::transaction::OutPoint {
525         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
526         crate::c_types::bitcoin_to_C_outpoint(inner_val)
527 }
528 /// The unique identifier of the input.
529 #[no_mangle]
530 pub extern "C" fn Input_set_outpoint(this_ptr: &mut Input, mut val: crate::lightning::chain::transaction::OutPoint) {
531         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
532 }
533 /// The UTXO being spent by the input.
534 #[no_mangle]
535 pub extern "C" fn Input_get_previous_utxo(this_ptr: &Input) -> crate::c_types::TxOut {
536         let mut inner_val = &mut this_ptr.get_native_mut_ref().previous_utxo;
537         crate::c_types::TxOut::from_rust(inner_val)
538 }
539 /// The UTXO being spent by the input.
540 #[no_mangle]
541 pub extern "C" fn Input_set_previous_utxo(this_ptr: &mut Input, mut val: crate::c_types::TxOut) {
542         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previous_utxo = val.into_rust();
543 }
544 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
545 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
546 /// script.
547 #[no_mangle]
548 pub extern "C" fn Input_get_satisfaction_weight(this_ptr: &Input) -> u64 {
549         let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight;
550         *inner_val
551 }
552 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
553 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
554 /// script.
555 #[no_mangle]
556 pub extern "C" fn Input_set_satisfaction_weight(this_ptr: &mut Input, mut val: u64) {
557         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val;
558 }
559 /// Constructs a new Input given each field
560 #[must_use]
561 #[no_mangle]
562 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 {
563         Input { inner: ObjOps::heap_alloc(nativeInput {
564                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
565                 previous_utxo: previous_utxo_arg.into_rust(),
566                 satisfaction_weight: satisfaction_weight_arg,
567         }), is_owned: true }
568 }
569 impl Clone for Input {
570         fn clone(&self) -> Self {
571                 Self {
572                         inner: if <*mut nativeInput>::is_null(self.inner) { core::ptr::null_mut() } else {
573                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
574                         is_owned: true,
575                 }
576         }
577 }
578 #[allow(unused)]
579 /// Used only if an object of this type is returned as a trait impl by a method
580 pub(crate) extern "C" fn Input_clone_void(this_ptr: *const c_void) -> *mut c_void {
581         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInput)).clone() })) as *mut c_void
582 }
583 #[no_mangle]
584 /// Creates a copy of the Input
585 pub extern "C" fn Input_clone(orig: &Input) -> Input {
586         orig.clone()
587 }
588 /// Get a string which allows debug introspection of a Input object
589 pub extern "C" fn Input_debug_str_void(o: *const c_void) -> Str {
590         alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::bump_transaction::Input }).into()}
591 /// Generates a non-cryptographic 64-bit hash of the Input.
592 #[no_mangle]
593 pub extern "C" fn Input_hash(o: &Input) -> u64 {
594         if o.inner.is_null() { return 0; }
595         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
596         #[allow(deprecated)]
597         let mut hasher = core::hash::SipHasher::new();
598         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
599         core::hash::Hasher::finish(&hasher)
600 }
601 /// Checks if two Inputs contain equal inner contents.
602 /// This ignores pointers and is_owned flags and looks at the values in fields.
603 /// Two objects with NULL inner values will be considered "equal" here.
604 #[no_mangle]
605 pub extern "C" fn Input_eq(a: &Input, b: &Input) -> bool {
606         if a.inner == b.inner { return true; }
607         if a.inner.is_null() || b.inner.is_null() { return false; }
608         if a.get_native_ref() == b.get_native_ref() { true } else { false }
609 }
610
611 use lightning::events::bump_transaction::Utxo as nativeUtxoImport;
612 pub(crate) type nativeUtxo = nativeUtxoImport;
613
614 /// An unspent transaction output that is available to spend resulting from a successful
615 /// [`CoinSelection`] attempt.
616 #[must_use]
617 #[repr(C)]
618 pub struct Utxo {
619         /// A pointer to the opaque Rust object.
620
621         /// Nearly everywhere, inner must be non-null, however in places where
622         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
623         pub inner: *mut nativeUtxo,
624         /// Indicates that this is the only struct which contains the same pointer.
625
626         /// Rust functions which take ownership of an object provided via an argument require
627         /// this to be true and invalidate the object pointed to by inner.
628         pub is_owned: bool,
629 }
630
631 impl Drop for Utxo {
632         fn drop(&mut self) {
633                 if self.is_owned && !<*mut nativeUtxo>::is_null(self.inner) {
634                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
635                 }
636         }
637 }
638 /// Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL.
639 #[no_mangle]
640 pub extern "C" fn Utxo_free(this_obj: Utxo) { }
641 #[allow(unused)]
642 /// Used only if an object of this type is returned as a trait impl by a method
643 pub(crate) extern "C" fn Utxo_free_void(this_ptr: *mut c_void) {
644         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUtxo) };
645 }
646 #[allow(unused)]
647 impl Utxo {
648         pub(crate) fn get_native_ref(&self) -> &'static nativeUtxo {
649                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
650         }
651         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUtxo {
652                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
653         }
654         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
655         pub(crate) fn take_inner(mut self) -> *mut nativeUtxo {
656                 assert!(self.is_owned);
657                 let ret = ObjOps::untweak_ptr(self.inner);
658                 self.inner = core::ptr::null_mut();
659                 ret
660         }
661 }
662 /// The unique identifier of the output.
663 #[no_mangle]
664 pub extern "C" fn Utxo_get_outpoint(this_ptr: &Utxo) -> crate::lightning::chain::transaction::OutPoint {
665         let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint;
666         crate::c_types::bitcoin_to_C_outpoint(inner_val)
667 }
668 /// The unique identifier of the output.
669 #[no_mangle]
670 pub extern "C" fn Utxo_set_outpoint(this_ptr: &mut Utxo, mut val: crate::lightning::chain::transaction::OutPoint) {
671         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val);
672 }
673 /// The output to spend.
674 #[no_mangle]
675 pub extern "C" fn Utxo_get_output(this_ptr: &Utxo) -> crate::c_types::TxOut {
676         let mut inner_val = &mut this_ptr.get_native_mut_ref().output;
677         crate::c_types::TxOut::from_rust(inner_val)
678 }
679 /// The output to spend.
680 #[no_mangle]
681 pub extern "C" fn Utxo_set_output(this_ptr: &mut Utxo, mut val: crate::c_types::TxOut) {
682         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust();
683 }
684 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
685 /// with their lengths included, required to satisfy the output's script. The weight consumed by
686 /// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
687 #[no_mangle]
688 pub extern "C" fn Utxo_get_satisfaction_weight(this_ptr: &Utxo) -> u64 {
689         let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight;
690         *inner_val
691 }
692 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
693 /// with their lengths included, required to satisfy the output's script. The weight consumed by
694 /// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
695 #[no_mangle]
696 pub extern "C" fn Utxo_set_satisfaction_weight(this_ptr: &mut Utxo, mut val: u64) {
697         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val;
698 }
699 /// Constructs a new Utxo given each field
700 #[must_use]
701 #[no_mangle]
702 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 {
703         Utxo { inner: ObjOps::heap_alloc(nativeUtxo {
704                 outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg),
705                 output: output_arg.into_rust(),
706                 satisfaction_weight: satisfaction_weight_arg,
707         }), is_owned: true }
708 }
709 impl Clone for Utxo {
710         fn clone(&self) -> Self {
711                 Self {
712                         inner: if <*mut nativeUtxo>::is_null(self.inner) { core::ptr::null_mut() } else {
713                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
714                         is_owned: true,
715                 }
716         }
717 }
718 #[allow(unused)]
719 /// Used only if an object of this type is returned as a trait impl by a method
720 pub(crate) extern "C" fn Utxo_clone_void(this_ptr: *const c_void) -> *mut c_void {
721         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUtxo)).clone() })) as *mut c_void
722 }
723 #[no_mangle]
724 /// Creates a copy of the Utxo
725 pub extern "C" fn Utxo_clone(orig: &Utxo) -> Utxo {
726         orig.clone()
727 }
728 /// Get a string which allows debug introspection of a Utxo object
729 pub extern "C" fn Utxo_debug_str_void(o: *const c_void) -> Str {
730         alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::bump_transaction::Utxo }).into()}
731 /// Generates a non-cryptographic 64-bit hash of the Utxo.
732 #[no_mangle]
733 pub extern "C" fn Utxo_hash(o: &Utxo) -> u64 {
734         if o.inner.is_null() { return 0; }
735         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
736         #[allow(deprecated)]
737         let mut hasher = core::hash::SipHasher::new();
738         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
739         core::hash::Hasher::finish(&hasher)
740 }
741 /// Checks if two Utxos contain equal inner contents.
742 /// This ignores pointers and is_owned flags and looks at the values in fields.
743 /// Two objects with NULL inner values will be considered "equal" here.
744 #[no_mangle]
745 pub extern "C" fn Utxo_eq(a: &Utxo, b: &Utxo) -> bool {
746         if a.inner == b.inner { return true; }
747         if a.inner.is_null() || b.inner.is_null() { return false; }
748         if a.get_native_ref() == b.get_native_ref() { true } else { false }
749 }
750 /// Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output.
751 #[must_use]
752 #[no_mangle]
753 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 {
754         let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), value, &bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone())));
755         crate::lightning::events::bump_transaction::Utxo { inner: ObjOps::heap_alloc(ret), is_owned: true }
756 }
757
758
759 use lightning::events::bump_transaction::CoinSelection as nativeCoinSelectionImport;
760 pub(crate) type nativeCoinSelection = nativeCoinSelectionImport;
761
762 /// The result of a successful coin selection attempt for a transaction requiring additional UTXOs
763 /// to cover its fees.
764 #[must_use]
765 #[repr(C)]
766 pub struct CoinSelection {
767         /// A pointer to the opaque Rust object.
768
769         /// Nearly everywhere, inner must be non-null, however in places where
770         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
771         pub inner: *mut nativeCoinSelection,
772         /// Indicates that this is the only struct which contains the same pointer.
773
774         /// Rust functions which take ownership of an object provided via an argument require
775         /// this to be true and invalidate the object pointed to by inner.
776         pub is_owned: bool,
777 }
778
779 impl Drop for CoinSelection {
780         fn drop(&mut self) {
781                 if self.is_owned && !<*mut nativeCoinSelection>::is_null(self.inner) {
782                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
783                 }
784         }
785 }
786 /// Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL.
787 #[no_mangle]
788 pub extern "C" fn CoinSelection_free(this_obj: CoinSelection) { }
789 #[allow(unused)]
790 /// Used only if an object of this type is returned as a trait impl by a method
791 pub(crate) extern "C" fn CoinSelection_free_void(this_ptr: *mut c_void) {
792         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCoinSelection) };
793 }
794 #[allow(unused)]
795 impl CoinSelection {
796         pub(crate) fn get_native_ref(&self) -> &'static nativeCoinSelection {
797                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
798         }
799         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCoinSelection {
800                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
801         }
802         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
803         pub(crate) fn take_inner(mut self) -> *mut nativeCoinSelection {
804                 assert!(self.is_owned);
805                 let ret = ObjOps::untweak_ptr(self.inner);
806                 self.inner = core::ptr::null_mut();
807                 ret
808         }
809 }
810 /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
811 /// requiring additional fees.
812 #[no_mangle]
813 pub extern "C" fn CoinSelection_get_confirmed_utxos(this_ptr: &CoinSelection) -> crate::c_types::derived::CVec_UtxoZ {
814         let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmed_utxos;
815         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 } }); };
816         local_inner_val.into()
817 }
818 /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
819 /// requiring additional fees.
820 #[no_mangle]
821 pub extern "C" fn CoinSelection_set_confirmed_utxos(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::CVec_UtxoZ) {
822         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmed_utxos = local_val;
824 }
825 /// An additional output tracking whether any change remained after coin selection. This output
826 /// should always have a value above dust for its given `script_pubkey`. It should not be
827 /// spent until the transaction it belongs to confirms to ensure mempool descendant limits are
828 /// not met. This implies no other party should be able to spend it except us.
829 #[no_mangle]
830 pub extern "C" fn CoinSelection_get_change_output(this_ptr: &CoinSelection) -> crate::c_types::derived::COption_TxOutZ {
831         let mut inner_val = &mut this_ptr.get_native_mut_ref().change_output;
832         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()) }) };
833         local_inner_val
834 }
835 /// An additional output tracking whether any change remained after coin selection. This output
836 /// should always have a value above dust for its given `script_pubkey`. It should not be
837 /// spent until the transaction it belongs to confirms to ensure mempool descendant limits are
838 /// not met. This implies no other party should be able to spend it except us.
839 #[no_mangle]
840 pub extern "C" fn CoinSelection_set_change_output(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::COption_TxOutZ) {
841         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} };
842         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.change_output = local_val;
843 }
844 /// Constructs a new CoinSelection given each field
845 #[must_use]
846 #[no_mangle]
847 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 {
848         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()) } }); };
849         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() }})} };
850         CoinSelection { inner: ObjOps::heap_alloc(nativeCoinSelection {
851                 confirmed_utxos: local_confirmed_utxos_arg,
852                 change_output: local_change_output_arg,
853         }), is_owned: true }
854 }
855 impl Clone for CoinSelection {
856         fn clone(&self) -> Self {
857                 Self {
858                         inner: if <*mut nativeCoinSelection>::is_null(self.inner) { core::ptr::null_mut() } else {
859                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
860                         is_owned: true,
861                 }
862         }
863 }
864 #[allow(unused)]
865 /// Used only if an object of this type is returned as a trait impl by a method
866 pub(crate) extern "C" fn CoinSelection_clone_void(this_ptr: *const c_void) -> *mut c_void {
867         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCoinSelection)).clone() })) as *mut c_void
868 }
869 #[no_mangle]
870 /// Creates a copy of the CoinSelection
871 pub extern "C" fn CoinSelection_clone(orig: &CoinSelection) -> CoinSelection {
872         orig.clone()
873 }
874 /// Get a string which allows debug introspection of a CoinSelection object
875 pub extern "C" fn CoinSelection_debug_str_void(o: *const c_void) -> Str {
876         alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::bump_transaction::CoinSelection }).into()}
877 /// An abstraction over a bitcoin wallet that can perform coin selection over a set of UTXOs and can
878 /// sign for them. The coin selection method aims to mimic Bitcoin Core's `fundrawtransaction` RPC,
879 /// which most wallets should be able to satisfy. Otherwise, consider implementing [`WalletSource`],
880 /// which can provide a default implementation of this trait when used with [`Wallet`].
881 #[repr(C)]
882 pub struct CoinSelectionSource {
883         /// An opaque pointer which is passed to your function implementations as an argument.
884         /// This has no meaning in the LDK, and can be NULL or any other value.
885         pub this_arg: *mut c_void,
886         /// Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are
887         /// available to spend. Implementations are free to pick their coin selection algorithm of
888         /// choice, as long as the following requirements are met:
889         ///
890         /// 1. `must_spend` contains a set of [`Input`]s that must be included in the transaction
891         ///    throughout coin selection, but must not be returned as part of the result.
892         /// 2. `must_pay_to` contains a set of [`TxOut`]s that must be included in the transaction
893         ///    throughout coin selection. In some cases, like when funding an anchor transaction, this
894         ///    set is empty. Implementations should ensure they handle this correctly on their end,
895         ///    e.g., Bitcoin Core's `fundrawtransaction` RPC requires at least one output to be
896         ///    provided, in which case a zero-value empty OP_RETURN output can be used instead.
897         /// 3. Enough inputs must be selected/contributed for the resulting transaction (including the
898         ///    inputs and outputs noted above) to meet `target_feerate_sat_per_1000_weight`.
899         ///
900         /// Implementations must take note that [`Input::satisfaction_weight`] only tracks the weight of
901         /// the input's `script_sig` and `witness`. Some wallets, like Bitcoin Core's, may require
902         /// providing the full input weight. Failing to do so may lead to underestimating fee bumps and
903         /// delaying block inclusion.
904         ///
905         /// The `claim_id` must map to the set of external UTXOs assigned to the claim, such that they
906         /// can be re-used within new fee-bumped iterations of the original claiming transaction,
907         /// ensuring that claims don't double spend each other. If a specific `claim_id` has never had a
908         /// transaction associated with it, and all of the available UTXOs have already been assigned to
909         /// other claims, implementations must be willing to double spend their UTXOs. The choice of
910         /// which UTXOs to double spend is left to the implementation, but it must strive to keep the
911         /// set of other claims being double spent to a minimum.
912         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,
913         /// Signs and provides the full witness for all inputs within the transaction known to the
914         /// trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]).
915         ///
916         /// If your wallet does not support signing PSBTs you can call `psbt.extract_tx()` to get the
917         /// unsigned transaction and then sign it with your wallet.
918         pub sign_psbt: extern "C" fn (this_arg: *const c_void, psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ,
919         /// Frees any resources associated with this object given its this_arg pointer.
920         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
921         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
922 }
923 unsafe impl Send for CoinSelectionSource {}
924 unsafe impl Sync for CoinSelectionSource {}
925 #[allow(unused)]
926 pub(crate) fn CoinSelectionSource_clone_fields(orig: &CoinSelectionSource) -> CoinSelectionSource {
927         CoinSelectionSource {
928                 this_arg: orig.this_arg,
929                 select_confirmed_utxos: Clone::clone(&orig.select_confirmed_utxos),
930                 sign_psbt: Clone::clone(&orig.sign_psbt),
931                 free: Clone::clone(&orig.free),
932         }
933 }
934
935 use lightning::events::bump_transaction::CoinSelectionSource as rustCoinSelectionSource;
936 impl rustCoinSelectionSource for CoinSelectionSource {
937         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, ()> {
938                 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 } }); };
939                 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) }); };
940                 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);
941                 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)) })*/ })};
942                 local_ret
943         }
944         fn sign_psbt(&self, mut psbt: bitcoin::psbt::PartiallySignedTransaction) -> Result<bitcoin::Transaction, ()> {
945                 let mut ret = (self.sign_psbt)(self.this_arg, psbt.serialize().into());
946                 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)) })*/ })};
947                 local_ret
948         }
949 }
950
951 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
952 // directly as a Deref trait in higher-level structs:
953 impl core::ops::Deref for CoinSelectionSource {
954         type Target = Self;
955         fn deref(&self) -> &Self {
956                 self
957         }
958 }
959 impl core::ops::DerefMut for CoinSelectionSource {
960         fn deref_mut(&mut self) -> &mut Self {
961                 self
962         }
963 }
964 /// Calls the free function if one is set
965 #[no_mangle]
966 pub extern "C" fn CoinSelectionSource_free(this_ptr: CoinSelectionSource) { }
967 impl Drop for CoinSelectionSource {
968         fn drop(&mut self) {
969                 if let Some(f) = self.free {
970                         f(self.this_arg);
971                 }
972         }
973 }
974 /// An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
975 /// provide a default implementation to [`CoinSelectionSource`].
976 #[repr(C)]
977 pub struct WalletSource {
978         /// An opaque pointer which is passed to your function implementations as an argument.
979         /// This has no meaning in the LDK, and can be NULL or any other value.
980         pub this_arg: *mut c_void,
981         /// Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
982         pub list_confirmed_utxos: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_UtxoZNoneZ,
983         /// Returns a script to use for change above dust resulting from a successful coin selection
984         /// attempt.
985         pub get_change_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ,
986         /// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
987         /// the transaction known to the wallet (i.e., any provided via
988         /// [`WalletSource::list_confirmed_utxos`]).
989         ///
990         /// If your wallet does not support signing PSBTs you can call `psbt.extract_tx()` to get the
991         /// unsigned transaction and then sign it with your wallet.
992         pub sign_psbt: extern "C" fn (this_arg: *const c_void, psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ,
993         /// Frees any resources associated with this object given its this_arg pointer.
994         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
995         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
996 }
997 unsafe impl Send for WalletSource {}
998 unsafe impl Sync for WalletSource {}
999 #[allow(unused)]
1000 pub(crate) fn WalletSource_clone_fields(orig: &WalletSource) -> WalletSource {
1001         WalletSource {
1002                 this_arg: orig.this_arg,
1003                 list_confirmed_utxos: Clone::clone(&orig.list_confirmed_utxos),
1004                 get_change_script: Clone::clone(&orig.get_change_script),
1005                 sign_psbt: Clone::clone(&orig.sign_psbt),
1006                 free: Clone::clone(&orig.free),
1007         }
1008 }
1009
1010 use lightning::events::bump_transaction::WalletSource as rustWalletSource;
1011 impl rustWalletSource for WalletSource {
1012         fn list_confirmed_utxos(&self) -> Result<Vec<lightning::events::bump_transaction::Utxo>, ()> {
1013                 let mut ret = (self.list_confirmed_utxos)(self.this_arg);
1014                 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)) })*/ })};
1015                 local_ret
1016         }
1017         fn get_change_script(&self) -> Result<bitcoin::ScriptBuf, ()> {
1018                 let mut ret = (self.get_change_script)(self.this_arg);
1019                 let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::ScriptBuf::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)) })*/ })};
1020                 local_ret
1021         }
1022         fn sign_psbt(&self, mut psbt: bitcoin::psbt::PartiallySignedTransaction) -> Result<bitcoin::Transaction, ()> {
1023                 let mut ret = (self.sign_psbt)(self.this_arg, psbt.serialize().into());
1024                 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)) })*/ })};
1025                 local_ret
1026         }
1027 }
1028
1029 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1030 // directly as a Deref trait in higher-level structs:
1031 impl core::ops::Deref for WalletSource {
1032         type Target = Self;
1033         fn deref(&self) -> &Self {
1034                 self
1035         }
1036 }
1037 impl core::ops::DerefMut for WalletSource {
1038         fn deref_mut(&mut self) -> &mut Self {
1039                 self
1040         }
1041 }
1042 /// Calls the free function if one is set
1043 #[no_mangle]
1044 pub extern "C" fn WalletSource_free(this_ptr: WalletSource) { }
1045 impl Drop for WalletSource {
1046         fn drop(&mut self) {
1047                 if let Some(f) = self.free {
1048                         f(self.this_arg);
1049                 }
1050         }
1051 }
1052
1053 use lightning::events::bump_transaction::Wallet as nativeWalletImport;
1054 pub(crate) type nativeWallet = nativeWalletImport<crate::lightning::events::bump_transaction::WalletSource, crate::lightning::util::logger::Logger>;
1055
1056 /// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would
1057 /// avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double
1058 /// spends may happen.
1059 #[must_use]
1060 #[repr(C)]
1061 pub struct Wallet {
1062         /// A pointer to the opaque Rust object.
1063
1064         /// Nearly everywhere, inner must be non-null, however in places where
1065         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1066         pub inner: *mut nativeWallet,
1067         /// Indicates that this is the only struct which contains the same pointer.
1068
1069         /// Rust functions which take ownership of an object provided via an argument require
1070         /// this to be true and invalidate the object pointed to by inner.
1071         pub is_owned: bool,
1072 }
1073
1074 impl Drop for Wallet {
1075         fn drop(&mut self) {
1076                 if self.is_owned && !<*mut nativeWallet>::is_null(self.inner) {
1077                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1078                 }
1079         }
1080 }
1081 /// Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL.
1082 #[no_mangle]
1083 pub extern "C" fn Wallet_free(this_obj: Wallet) { }
1084 #[allow(unused)]
1085 /// Used only if an object of this type is returned as a trait impl by a method
1086 pub(crate) extern "C" fn Wallet_free_void(this_ptr: *mut c_void) {
1087         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWallet) };
1088 }
1089 #[allow(unused)]
1090 impl Wallet {
1091         pub(crate) fn get_native_ref(&self) -> &'static nativeWallet {
1092                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1093         }
1094         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWallet {
1095                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1096         }
1097         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1098         pub(crate) fn take_inner(mut self) -> *mut nativeWallet {
1099                 assert!(self.is_owned);
1100                 let ret = ObjOps::untweak_ptr(self.inner);
1101                 self.inner = core::ptr::null_mut();
1102                 ret
1103         }
1104 }
1105 /// Returns a new instance backed by the given [`WalletSource`] that serves as an implementation
1106 /// of [`CoinSelectionSource`].
1107 #[must_use]
1108 #[no_mangle]
1109 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 {
1110         let mut ret = lightning::events::bump_transaction::Wallet::new(source, logger);
1111         crate::lightning::events::bump_transaction::Wallet { inner: ObjOps::heap_alloc(ret), is_owned: true }
1112 }
1113
1114 impl From<nativeWallet> for crate::lightning::events::bump_transaction::CoinSelectionSource {
1115         fn from(obj: nativeWallet) -> Self {
1116                 let rust_obj = crate::lightning::events::bump_transaction::Wallet { inner: ObjOps::heap_alloc(obj), is_owned: true };
1117                 let mut ret = Wallet_as_CoinSelectionSource(&rust_obj);
1118                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
1119                 core::mem::forget(rust_obj);
1120                 ret.free = Some(Wallet_free_void);
1121                 ret
1122         }
1123 }
1124 /// Constructs a new CoinSelectionSource which calls the relevant methods on this_arg.
1125 /// This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is
1126 #[no_mangle]
1127 pub extern "C" fn Wallet_as_CoinSelectionSource(this_arg: &Wallet) -> crate::lightning::events::bump_transaction::CoinSelectionSource {
1128         crate::lightning::events::bump_transaction::CoinSelectionSource {
1129                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
1130                 free: None,
1131                 select_confirmed_utxos: Wallet_CoinSelectionSource_select_confirmed_utxos,
1132                 sign_psbt: Wallet_CoinSelectionSource_sign_psbt,
1133         }
1134 }
1135
1136 #[must_use]
1137 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 {
1138         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()) } }); };
1139         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() }); };
1140         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);
1141         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() };
1142         local_ret
1143 }
1144 #[must_use]
1145 extern "C" fn Wallet_CoinSelectionSource_sign_psbt(this_arg: *const c_void, mut psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ {
1146         let mut ret = <nativeWallet as lightning::events::bump_transaction::CoinSelectionSource<>>::sign_psbt(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::bitcoin::psbt::PartiallySignedTransaction::deserialize(psbt.as_slice()).expect("Invalid PSBT format"));
1147         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() };
1148         local_ret
1149 }
1150
1151
1152 use lightning::events::bump_transaction::BumpTransactionEventHandler as nativeBumpTransactionEventHandlerImport;
1153 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>;
1154
1155 /// A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a
1156 /// [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or
1157 /// Replace-By-Fee (RBF).
1158 ///
1159 /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
1160 #[must_use]
1161 #[repr(C)]
1162 pub struct BumpTransactionEventHandler {
1163         /// A pointer to the opaque Rust object.
1164
1165         /// Nearly everywhere, inner must be non-null, however in places where
1166         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1167         pub inner: *mut nativeBumpTransactionEventHandler,
1168         /// Indicates that this is the only struct which contains the same pointer.
1169
1170         /// Rust functions which take ownership of an object provided via an argument require
1171         /// this to be true and invalidate the object pointed to by inner.
1172         pub is_owned: bool,
1173 }
1174
1175 impl Drop for BumpTransactionEventHandler {
1176         fn drop(&mut self) {
1177                 if self.is_owned && !<*mut nativeBumpTransactionEventHandler>::is_null(self.inner) {
1178                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1179                 }
1180         }
1181 }
1182 /// Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL.
1183 #[no_mangle]
1184 pub extern "C" fn BumpTransactionEventHandler_free(this_obj: BumpTransactionEventHandler) { }
1185 #[allow(unused)]
1186 /// Used only if an object of this type is returned as a trait impl by a method
1187 pub(crate) extern "C" fn BumpTransactionEventHandler_free_void(this_ptr: *mut c_void) {
1188         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBumpTransactionEventHandler) };
1189 }
1190 #[allow(unused)]
1191 impl BumpTransactionEventHandler {
1192         pub(crate) fn get_native_ref(&self) -> &'static nativeBumpTransactionEventHandler {
1193                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1194         }
1195         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBumpTransactionEventHandler {
1196                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1197         }
1198         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1199         pub(crate) fn take_inner(mut self) -> *mut nativeBumpTransactionEventHandler {
1200                 assert!(self.is_owned);
1201                 let ret = ObjOps::untweak_ptr(self.inner);
1202                 self.inner = core::ptr::null_mut();
1203                 ret
1204         }
1205 }
1206 /// Returns a new instance capable of handling [`Event::BumpTransaction`] events.
1207 ///
1208 /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
1209 #[must_use]
1210 #[no_mangle]
1211 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 {
1212         let mut ret = lightning::events::bump_transaction::BumpTransactionEventHandler::new(broadcaster, utxo_source, signer_provider, logger);
1213         crate::lightning::events::bump_transaction::BumpTransactionEventHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
1214 }
1215
1216 /// Handles all variants of [`BumpTransactionEvent`].
1217 #[no_mangle]
1218 pub extern "C" fn BumpTransactionEventHandler_handle_event(this_arg: &crate::lightning::events::bump_transaction::BumpTransactionEventHandler, event: &crate::lightning::events::bump_transaction::BumpTransactionEvent) {
1219         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_event(&event.to_native())
1220 }
1221