Merge pull request #17 from TheBlueMatt/2021-04-upstream-confirm
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / chan_utils.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 //! Various utilities for building scripts and deriving keys related to channels. These are
10 //! largely of interest for those implementing chain::keysinterface::Sign message signing by hand.
11
12 use std::ffi::c_void;
13 use bitcoin::hashes::Hash;
14 use crate::c_types::*;
15
16 /// Build the commitment secret from the seed and the commitment number
17 #[no_mangle]
18 pub extern "C" fn build_commitment_secret(commitment_seed: *const [u8; 32], mut idx: u64) -> crate::c_types::ThirtyTwoBytes {
19         let mut ret = lightning::ln::chan_utils::build_commitment_secret(unsafe { &*commitment_seed}, idx);
20         crate::c_types::ThirtyTwoBytes { data: ret }
21 }
22
23 /// Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
24 /// from the base secret and the per_commitment_point.
25 ///
26 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
27 /// generated (ie our own).
28 #[no_mangle]
29 pub extern "C" fn derive_private_key(mut per_commitment_point: crate::c_types::PublicKey, base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeyErrorZ {
30         let mut ret = lightning::ln::chan_utils::derive_private_key(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *base_secret}[..]).unwrap());
31         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SecretKey::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
32         local_ret
33 }
34
35 /// Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
36 /// from the base point and the per_commitment_key. This is the public equivalent of
37 /// derive_private_key - using only public keys to derive a public key instead of private keys.
38 ///
39 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
40 /// generated (ie our own).
41 #[no_mangle]
42 pub extern "C" fn derive_public_key(mut per_commitment_point: crate::c_types::PublicKey, mut base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeyErrorZ {
43         let mut ret = lightning::ln::chan_utils::derive_public_key(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &base_point.into_rust());
44         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
45         local_ret
46 }
47
48 /// Derives a per-commitment-transaction revocation key from its constituent parts.
49 ///
50 /// Only the cheating participant owns a valid witness to propagate a revoked 
51 /// commitment transaction, thus per_commitment_secret always come from cheater
52 /// and revocation_base_secret always come from punisher, which is the broadcaster
53 /// of the transaction spending with this key knowledge.
54 ///
55 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
56 /// generated (ie our own).
57 #[no_mangle]
58 pub extern "C" fn derive_private_revocation_key(per_commitment_secret: *const [u8; 32], countersignatory_revocation_base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeyErrorZ {
59         let mut ret = lightning::ln::chan_utils::derive_private_revocation_key(secp256k1::SECP256K1, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_secret}[..]).unwrap(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *countersignatory_revocation_base_secret}[..]).unwrap());
60         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SecretKey::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
61         local_ret
62 }
63
64 /// Derives a per-commitment-transaction revocation public key from its constituent parts. This is
65 /// the public equivalend of derive_private_revocation_key - using only public keys to derive a
66 /// public key instead of private keys.
67 ///
68 /// Only the cheating participant owns a valid witness to propagate a revoked 
69 /// commitment transaction, thus per_commitment_point always come from cheater
70 /// and revocation_base_point always come from punisher, which is the broadcaster
71 /// of the transaction spending with this key knowledge.
72 ///
73 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
74 /// generated (ie our own).
75 #[no_mangle]
76 pub extern "C" fn derive_public_revocation_key(mut per_commitment_point: crate::c_types::PublicKey, mut countersignatory_revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeyErrorZ {
77         let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &countersignatory_revocation_base_point.into_rust());
78         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
79         local_ret
80 }
81
82
83 use lightning::ln::chan_utils::TxCreationKeys as nativeTxCreationKeysImport;
84 type nativeTxCreationKeys = nativeTxCreationKeysImport;
85
86 /// The set of public keys which are used in the creation of one commitment transaction.
87 /// These are derived from the channel base keys and per-commitment data.
88 ///
89 /// A broadcaster key is provided from potential broadcaster of the computed transaction.
90 /// A countersignatory key is coming from a protocol participant unable to broadcast the
91 /// transaction.
92 ///
93 /// These keys are assumed to be good, either because the code derived them from
94 /// channel basepoints via the new function, or they were obtained via
95 /// CommitmentTransaction.trust().keys() because we trusted the source of the
96 /// pre-calculated keys.
97 #[must_use]
98 #[repr(C)]
99 pub struct TxCreationKeys {
100         /// A pointer to the opaque Rust object.
101
102         /// Nearly everywhere, inner must be non-null, however in places where
103         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
104         pub inner: *mut nativeTxCreationKeys,
105         /// Indicates that this is the only struct which contains the same pointer.
106
107         /// Rust functions which take ownership of an object provided via an argument require
108         /// this to be true and invalidate the object pointed to by inner.
109         pub is_owned: bool,
110 }
111
112 impl Drop for TxCreationKeys {
113         fn drop(&mut self) {
114                 if self.is_owned && !<*mut nativeTxCreationKeys>::is_null(self.inner) {
115                         let _ = unsafe { Box::from_raw(self.inner) };
116                 }
117         }
118 }
119 /// Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL.
120 #[no_mangle]
121 pub extern "C" fn TxCreationKeys_free(this_obj: TxCreationKeys) { }
122 #[allow(unused)]
123 /// Used only if an object of this type is returned as a trait impl by a method
124 extern "C" fn TxCreationKeys_free_void(this_ptr: *mut c_void) {
125         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTxCreationKeys); }
126 }
127 #[allow(unused)]
128 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
129 impl TxCreationKeys {
130         pub(crate) fn take_inner(mut self) -> *mut nativeTxCreationKeys {
131                 assert!(self.is_owned);
132                 let ret = self.inner;
133                 self.inner = std::ptr::null_mut();
134                 ret
135         }
136 }
137 /// The broadcaster's per-commitment public key which was used to derive the other keys.
138 #[no_mangle]
139 pub extern "C" fn TxCreationKeys_get_per_commitment_point(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
140         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point;
141         crate::c_types::PublicKey::from_rust(&inner_val)
142 }
143 /// The broadcaster's per-commitment public key which was used to derive the other keys.
144 #[no_mangle]
145 pub extern "C" fn TxCreationKeys_set_per_commitment_point(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
146         unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust();
147 }
148 /// The revocation key which is used to allow the broadcaster of the commitment
149 /// transaction to provide their counterparty the ability to punish them if they broadcast
150 /// an old state.
151 #[no_mangle]
152 pub extern "C" fn TxCreationKeys_get_revocation_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
153         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_key;
154         crate::c_types::PublicKey::from_rust(&inner_val)
155 }
156 /// The revocation key which is used to allow the broadcaster of the commitment
157 /// transaction to provide their counterparty the ability to punish them if they broadcast
158 /// an old state.
159 #[no_mangle]
160 pub extern "C" fn TxCreationKeys_set_revocation_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
161         unsafe { &mut *this_ptr.inner }.revocation_key = val.into_rust();
162 }
163 /// Broadcaster's HTLC Key
164 #[no_mangle]
165 pub extern "C" fn TxCreationKeys_get_broadcaster_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
166         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key;
167         crate::c_types::PublicKey::from_rust(&inner_val)
168 }
169 /// Broadcaster's HTLC Key
170 #[no_mangle]
171 pub extern "C" fn TxCreationKeys_set_broadcaster_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
172         unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key = val.into_rust();
173 }
174 /// Countersignatory's HTLC Key
175 #[no_mangle]
176 pub extern "C" fn TxCreationKeys_get_countersignatory_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
177         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key;
178         crate::c_types::PublicKey::from_rust(&inner_val)
179 }
180 /// Countersignatory's HTLC Key
181 #[no_mangle]
182 pub extern "C" fn TxCreationKeys_set_countersignatory_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
183         unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key = val.into_rust();
184 }
185 /// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
186 #[no_mangle]
187 pub extern "C" fn TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
188         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key;
189         crate::c_types::PublicKey::from_rust(&inner_val)
190 }
191 /// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
192 #[no_mangle]
193 pub extern "C" fn TxCreationKeys_set_broadcaster_delayed_payment_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
194         unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key = val.into_rust();
195 }
196 /// Constructs a new TxCreationKeys given each field
197 #[must_use]
198 #[no_mangle]
199 pub extern "C" fn TxCreationKeys_new(mut per_commitment_point_arg: crate::c_types::PublicKey, mut revocation_key_arg: crate::c_types::PublicKey, mut broadcaster_htlc_key_arg: crate::c_types::PublicKey, mut countersignatory_htlc_key_arg: crate::c_types::PublicKey, mut broadcaster_delayed_payment_key_arg: crate::c_types::PublicKey) -> TxCreationKeys {
200         TxCreationKeys { inner: Box::into_raw(Box::new(nativeTxCreationKeys {
201                 per_commitment_point: per_commitment_point_arg.into_rust(),
202                 revocation_key: revocation_key_arg.into_rust(),
203                 broadcaster_htlc_key: broadcaster_htlc_key_arg.into_rust(),
204                 countersignatory_htlc_key: countersignatory_htlc_key_arg.into_rust(),
205                 broadcaster_delayed_payment_key: broadcaster_delayed_payment_key_arg.into_rust(),
206         })), is_owned: true }
207 }
208 impl Clone for TxCreationKeys {
209         fn clone(&self) -> Self {
210                 Self {
211                         inner: if <*mut nativeTxCreationKeys>::is_null(self.inner) { std::ptr::null_mut() } else {
212                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
213                         is_owned: true,
214                 }
215         }
216 }
217 #[allow(unused)]
218 /// Used only if an object of this type is returned as a trait impl by a method
219 pub(crate) extern "C" fn TxCreationKeys_clone_void(this_ptr: *const c_void) -> *mut c_void {
220         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxCreationKeys)).clone() })) as *mut c_void
221 }
222 #[no_mangle]
223 /// Creates a copy of the TxCreationKeys
224 pub extern "C" fn TxCreationKeys_clone(orig: &TxCreationKeys) -> TxCreationKeys {
225         orig.clone()
226 }
227 #[no_mangle]
228 /// Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
229 pub extern "C" fn TxCreationKeys_write(obj: &TxCreationKeys) -> crate::c_types::derived::CVec_u8Z {
230         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
231 }
232 #[no_mangle]
233 pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
234         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxCreationKeys) })
235 }
236 #[no_mangle]
237 /// Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
238 pub extern "C" fn TxCreationKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCreationKeysDecodeErrorZ {
239         let res = crate::c_types::deserialize_obj(ser);
240         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
241         local_res
242 }
243
244 use lightning::ln::chan_utils::ChannelPublicKeys as nativeChannelPublicKeysImport;
245 type nativeChannelPublicKeys = nativeChannelPublicKeysImport;
246
247 /// One counterparty's public keys which do not change over the life of a channel.
248 #[must_use]
249 #[repr(C)]
250 pub struct ChannelPublicKeys {
251         /// A pointer to the opaque Rust object.
252
253         /// Nearly everywhere, inner must be non-null, however in places where
254         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
255         pub inner: *mut nativeChannelPublicKeys,
256         /// Indicates that this is the only struct which contains the same pointer.
257
258         /// Rust functions which take ownership of an object provided via an argument require
259         /// this to be true and invalidate the object pointed to by inner.
260         pub is_owned: bool,
261 }
262
263 impl Drop for ChannelPublicKeys {
264         fn drop(&mut self) {
265                 if self.is_owned && !<*mut nativeChannelPublicKeys>::is_null(self.inner) {
266                         let _ = unsafe { Box::from_raw(self.inner) };
267                 }
268         }
269 }
270 /// Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL.
271 #[no_mangle]
272 pub extern "C" fn ChannelPublicKeys_free(this_obj: ChannelPublicKeys) { }
273 #[allow(unused)]
274 /// Used only if an object of this type is returned as a trait impl by a method
275 extern "C" fn ChannelPublicKeys_free_void(this_ptr: *mut c_void) {
276         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelPublicKeys); }
277 }
278 #[allow(unused)]
279 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
280 impl ChannelPublicKeys {
281         pub(crate) fn take_inner(mut self) -> *mut nativeChannelPublicKeys {
282                 assert!(self.is_owned);
283                 let ret = self.inner;
284                 self.inner = std::ptr::null_mut();
285                 ret
286         }
287 }
288 /// The public key which is used to sign all commitment transactions, as it appears in the
289 /// on-chain channel lock-in 2-of-2 multisig output.
290 #[no_mangle]
291 pub extern "C" fn ChannelPublicKeys_get_funding_pubkey(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
292         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
293         crate::c_types::PublicKey::from_rust(&inner_val)
294 }
295 /// The public key which is used to sign all commitment transactions, as it appears in the
296 /// on-chain channel lock-in 2-of-2 multisig output.
297 #[no_mangle]
298 pub extern "C" fn ChannelPublicKeys_set_funding_pubkey(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
299         unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
300 }
301 /// The base point which is used (with derive_public_revocation_key) to derive per-commitment
302 /// revocation keys. This is combined with the per-commitment-secret generated by the
303 /// counterparty to create a secret which the counterparty can reveal to revoke previous
304 /// states.
305 #[no_mangle]
306 pub extern "C" fn ChannelPublicKeys_get_revocation_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
307         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
308         crate::c_types::PublicKey::from_rust(&inner_val)
309 }
310 /// The base point which is used (with derive_public_revocation_key) to derive per-commitment
311 /// revocation keys. This is combined with the per-commitment-secret generated by the
312 /// counterparty to create a secret which the counterparty can reveal to revoke previous
313 /// states.
314 #[no_mangle]
315 pub extern "C" fn ChannelPublicKeys_set_revocation_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
316         unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
317 }
318 /// The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
319 /// spendable primary channel balance on the broadcaster's commitment transaction. This key is
320 /// static across every commitment transaction.
321 #[no_mangle]
322 pub extern "C" fn ChannelPublicKeys_get_payment_point(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
323         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
324         crate::c_types::PublicKey::from_rust(&inner_val)
325 }
326 /// The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
327 /// spendable primary channel balance on the broadcaster's commitment transaction. This key is
328 /// static across every commitment transaction.
329 #[no_mangle]
330 pub extern "C" fn ChannelPublicKeys_set_payment_point(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
331         unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
332 }
333 /// The base point which is used (with derive_public_key) to derive a per-commitment payment
334 /// public key which receives non-HTLC-encumbered funds which are only available for spending
335 /// after some delay (or can be claimed via the revocation path).
336 #[no_mangle]
337 pub extern "C" fn ChannelPublicKeys_get_delayed_payment_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
338         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
339         crate::c_types::PublicKey::from_rust(&inner_val)
340 }
341 /// The base point which is used (with derive_public_key) to derive a per-commitment payment
342 /// public key which receives non-HTLC-encumbered funds which are only available for spending
343 /// after some delay (or can be claimed via the revocation path).
344 #[no_mangle]
345 pub extern "C" fn ChannelPublicKeys_set_delayed_payment_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
346         unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
347 }
348 /// The base point which is used (with derive_public_key) to derive a per-commitment public key
349 /// which is used to encumber HTLC-in-flight outputs.
350 #[no_mangle]
351 pub extern "C" fn ChannelPublicKeys_get_htlc_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
352         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
353         crate::c_types::PublicKey::from_rust(&inner_val)
354 }
355 /// The base point which is used (with derive_public_key) to derive a per-commitment public key
356 /// which is used to encumber HTLC-in-flight outputs.
357 #[no_mangle]
358 pub extern "C" fn ChannelPublicKeys_set_htlc_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
359         unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
360 }
361 /// Constructs a new ChannelPublicKeys given each field
362 #[must_use]
363 #[no_mangle]
364 pub extern "C" fn ChannelPublicKeys_new(mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey) -> ChannelPublicKeys {
365         ChannelPublicKeys { inner: Box::into_raw(Box::new(nativeChannelPublicKeys {
366                 funding_pubkey: funding_pubkey_arg.into_rust(),
367                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
368                 payment_point: payment_point_arg.into_rust(),
369                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
370                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
371         })), is_owned: true }
372 }
373 impl Clone for ChannelPublicKeys {
374         fn clone(&self) -> Self {
375                 Self {
376                         inner: if <*mut nativeChannelPublicKeys>::is_null(self.inner) { std::ptr::null_mut() } else {
377                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
378                         is_owned: true,
379                 }
380         }
381 }
382 #[allow(unused)]
383 /// Used only if an object of this type is returned as a trait impl by a method
384 pub(crate) extern "C" fn ChannelPublicKeys_clone_void(this_ptr: *const c_void) -> *mut c_void {
385         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelPublicKeys)).clone() })) as *mut c_void
386 }
387 #[no_mangle]
388 /// Creates a copy of the ChannelPublicKeys
389 pub extern "C" fn ChannelPublicKeys_clone(orig: &ChannelPublicKeys) -> ChannelPublicKeys {
390         orig.clone()
391 }
392 #[no_mangle]
393 /// Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
394 pub extern "C" fn ChannelPublicKeys_write(obj: &ChannelPublicKeys) -> crate::c_types::derived::CVec_u8Z {
395         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
396 }
397 #[no_mangle]
398 pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
399         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelPublicKeys) })
400 }
401 #[no_mangle]
402 /// Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
403 pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelPublicKeysDecodeErrorZ {
404         let res = crate::c_types::deserialize_obj(ser);
405         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
406         local_res
407 }
408 /// Create per-state keys from channel base points and the per-commitment point.
409 /// Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
410 #[must_use]
411 #[no_mangle]
412 pub extern "C" fn TxCreationKeys_derive_new(mut per_commitment_point: crate::c_types::PublicKey, mut broadcaster_delayed_payment_base: crate::c_types::PublicKey, mut broadcaster_htlc_base: crate::c_types::PublicKey, mut countersignatory_revocation_base: crate::c_types::PublicKey, mut countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysErrorZ {
413         let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &broadcaster_delayed_payment_base.into_rust(), &broadcaster_htlc_base.into_rust(), &countersignatory_revocation_base.into_rust(), &countersignatory_htlc_base.into_rust());
414         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
415         local_ret
416 }
417
418 /// Generate per-state keys from channel static keys.
419 /// Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
420 #[must_use]
421 #[no_mangle]
422 pub extern "C" fn TxCreationKeys_from_channel_static_keys(mut per_commitment_point: crate::c_types::PublicKey, broadcaster_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TxCreationKeysErrorZ {
423         let mut ret = lightning::ln::chan_utils::TxCreationKeys::from_channel_static_keys(&per_commitment_point.into_rust(), unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, secp256k1::SECP256K1);
424         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
425         local_ret
426 }
427
428 /// The maximum length of a script returned by get_revokeable_redeemscript.
429
430 #[no_mangle]
431 pub static REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH: usize = lightning::ln::chan_utils::REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH;
432 /// A script either spendable by the revocation
433 /// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
434 /// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
435 #[no_mangle]
436 pub extern "C" fn get_revokeable_redeemscript(mut revocation_key: crate::c_types::PublicKey, mut contest_delay: u16, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
437         let mut ret = lightning::ln::chan_utils::get_revokeable_redeemscript(&revocation_key.into_rust(), contest_delay, &broadcaster_delayed_payment_key.into_rust());
438         ret.into_bytes().into()
439 }
440
441
442 use lightning::ln::chan_utils::HTLCOutputInCommitment as nativeHTLCOutputInCommitmentImport;
443 type nativeHTLCOutputInCommitment = nativeHTLCOutputInCommitmentImport;
444
445 /// Information about an HTLC as it appears in a commitment transaction
446 #[must_use]
447 #[repr(C)]
448 pub struct HTLCOutputInCommitment {
449         /// A pointer to the opaque Rust object.
450
451         /// Nearly everywhere, inner must be non-null, however in places where
452         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
453         pub inner: *mut nativeHTLCOutputInCommitment,
454         /// Indicates that this is the only struct which contains the same pointer.
455
456         /// Rust functions which take ownership of an object provided via an argument require
457         /// this to be true and invalidate the object pointed to by inner.
458         pub is_owned: bool,
459 }
460
461 impl Drop for HTLCOutputInCommitment {
462         fn drop(&mut self) {
463                 if self.is_owned && !<*mut nativeHTLCOutputInCommitment>::is_null(self.inner) {
464                         let _ = unsafe { Box::from_raw(self.inner) };
465                 }
466         }
467 }
468 /// Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL.
469 #[no_mangle]
470 pub extern "C" fn HTLCOutputInCommitment_free(this_obj: HTLCOutputInCommitment) { }
471 #[allow(unused)]
472 /// Used only if an object of this type is returned as a trait impl by a method
473 extern "C" fn HTLCOutputInCommitment_free_void(this_ptr: *mut c_void) {
474         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCOutputInCommitment); }
475 }
476 #[allow(unused)]
477 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
478 impl HTLCOutputInCommitment {
479         pub(crate) fn take_inner(mut self) -> *mut nativeHTLCOutputInCommitment {
480                 assert!(self.is_owned);
481                 let ret = self.inner;
482                 self.inner = std::ptr::null_mut();
483                 ret
484         }
485 }
486 /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
487 /// Note that this is not the same as whether it is ountbound *from us*. To determine that you
488 /// need to compare this value to whether the commitment transaction in question is that of
489 /// the counterparty or our own.
490 #[no_mangle]
491 pub extern "C" fn HTLCOutputInCommitment_get_offered(this_ptr: &HTLCOutputInCommitment) -> bool {
492         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.offered;
493         *inner_val
494 }
495 /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
496 /// Note that this is not the same as whether it is ountbound *from us*. To determine that you
497 /// need to compare this value to whether the commitment transaction in question is that of
498 /// the counterparty or our own.
499 #[no_mangle]
500 pub extern "C" fn HTLCOutputInCommitment_set_offered(this_ptr: &mut HTLCOutputInCommitment, mut val: bool) {
501         unsafe { &mut *this_ptr.inner }.offered = val;
502 }
503 /// The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
504 /// this divided by 1000.
505 #[no_mangle]
506 pub extern "C" fn HTLCOutputInCommitment_get_amount_msat(this_ptr: &HTLCOutputInCommitment) -> u64 {
507         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
508         *inner_val
509 }
510 /// The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
511 /// this divided by 1000.
512 #[no_mangle]
513 pub extern "C" fn HTLCOutputInCommitment_set_amount_msat(this_ptr: &mut HTLCOutputInCommitment, mut val: u64) {
514         unsafe { &mut *this_ptr.inner }.amount_msat = val;
515 }
516 /// The CLTV lock-time at which this HTLC expires.
517 #[no_mangle]
518 pub extern "C" fn HTLCOutputInCommitment_get_cltv_expiry(this_ptr: &HTLCOutputInCommitment) -> u32 {
519         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
520         *inner_val
521 }
522 /// The CLTV lock-time at which this HTLC expires.
523 #[no_mangle]
524 pub extern "C" fn HTLCOutputInCommitment_set_cltv_expiry(this_ptr: &mut HTLCOutputInCommitment, mut val: u32) {
525         unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
526 }
527 /// The hash of the preimage which unlocks this HTLC.
528 #[no_mangle]
529 pub extern "C" fn HTLCOutputInCommitment_get_payment_hash(this_ptr: &HTLCOutputInCommitment) -> *const [u8; 32] {
530         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
531         &inner_val.0
532 }
533 /// The hash of the preimage which unlocks this HTLC.
534 #[no_mangle]
535 pub extern "C" fn HTLCOutputInCommitment_set_payment_hash(this_ptr: &mut HTLCOutputInCommitment, mut val: crate::c_types::ThirtyTwoBytes) {
536         unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
537 }
538 /// The position within the commitment transactions' outputs. This may be None if the value is
539 /// below the dust limit (in which case no output appears in the commitment transaction and the
540 /// value is spent to additional transaction fees).
541 #[no_mangle]
542 pub extern "C" fn HTLCOutputInCommitment_get_transaction_output_index(this_ptr: &HTLCOutputInCommitment) -> crate::c_types::derived::COption_u32Z {
543         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction_output_index;
544         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else {  { crate::c_types::derived::COption_u32Z::Some(inner_val.unwrap()) } };
545         local_inner_val
546 }
547 /// The position within the commitment transactions' outputs. This may be None if the value is
548 /// below the dust limit (in which case no output appears in the commitment transaction and the
549 /// value is spent to additional transaction fees).
550 #[no_mangle]
551 pub extern "C" fn HTLCOutputInCommitment_set_transaction_output_index(this_ptr: &mut HTLCOutputInCommitment, mut val: crate::c_types::derived::COption_u32Z) {
552         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
553         unsafe { &mut *this_ptr.inner }.transaction_output_index = local_val;
554 }
555 /// Constructs a new HTLCOutputInCommitment given each field
556 #[must_use]
557 #[no_mangle]
558 pub extern "C" fn HTLCOutputInCommitment_new(mut offered_arg: bool, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut transaction_output_index_arg: crate::c_types::derived::COption_u32Z) -> HTLCOutputInCommitment {
559         let mut local_transaction_output_index_arg = if transaction_output_index_arg.is_some() { Some( { transaction_output_index_arg.take() }) } else { None };
560         HTLCOutputInCommitment { inner: Box::into_raw(Box::new(nativeHTLCOutputInCommitment {
561                 offered: offered_arg,
562                 amount_msat: amount_msat_arg,
563                 cltv_expiry: cltv_expiry_arg,
564                 payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_arg.data),
565                 transaction_output_index: local_transaction_output_index_arg,
566         })), is_owned: true }
567 }
568 impl Clone for HTLCOutputInCommitment {
569         fn clone(&self) -> Self {
570                 Self {
571                         inner: if <*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { std::ptr::null_mut() } else {
572                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
573                         is_owned: true,
574                 }
575         }
576 }
577 #[allow(unused)]
578 /// Used only if an object of this type is returned as a trait impl by a method
579 pub(crate) extern "C" fn HTLCOutputInCommitment_clone_void(this_ptr: *const c_void) -> *mut c_void {
580         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCOutputInCommitment)).clone() })) as *mut c_void
581 }
582 #[no_mangle]
583 /// Creates a copy of the HTLCOutputInCommitment
584 pub extern "C" fn HTLCOutputInCommitment_clone(orig: &HTLCOutputInCommitment) -> HTLCOutputInCommitment {
585         orig.clone()
586 }
587 #[no_mangle]
588 /// Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read
589 pub extern "C" fn HTLCOutputInCommitment_write(obj: &HTLCOutputInCommitment) -> crate::c_types::derived::CVec_u8Z {
590         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
591 }
592 #[no_mangle]
593 pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
594         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCOutputInCommitment) })
595 }
596 #[no_mangle]
597 /// Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write
598 pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCOutputInCommitmentDecodeErrorZ {
599         let res = crate::c_types::deserialize_obj(ser);
600         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
601         local_res
602 }
603 /// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
604 /// does not need to have its previous_output_index filled.
605 #[no_mangle]
606 pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z {
607         let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(unsafe { &*htlc.inner }, unsafe { &*keys.inner });
608         ret.into_bytes().into()
609 }
610
611 /// Gets the redeemscript for a funding output from the two funding public keys.
612 /// Note that the order of funding public keys does not matter.
613 #[no_mangle]
614 pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::PublicKey, mut countersignatory: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
615         let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&broadcaster.into_rust(), &countersignatory.into_rust());
616         ret.into_bytes().into()
617 }
618
619 /// panics if htlc.transaction_output_index.is_none()!
620 #[no_mangle]
621 pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction {
622         let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust());
623         crate::c_types::Transaction::from_bitcoin(&ret)
624 }
625
626
627 use lightning::ln::chan_utils::ChannelTransactionParameters as nativeChannelTransactionParametersImport;
628 type nativeChannelTransactionParameters = nativeChannelTransactionParametersImport;
629
630 /// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
631 /// The fields are organized by holder/counterparty.
632 ///
633 /// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
634 /// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
635 #[must_use]
636 #[repr(C)]
637 pub struct ChannelTransactionParameters {
638         /// A pointer to the opaque Rust object.
639
640         /// Nearly everywhere, inner must be non-null, however in places where
641         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
642         pub inner: *mut nativeChannelTransactionParameters,
643         /// Indicates that this is the only struct which contains the same pointer.
644
645         /// Rust functions which take ownership of an object provided via an argument require
646         /// this to be true and invalidate the object pointed to by inner.
647         pub is_owned: bool,
648 }
649
650 impl Drop for ChannelTransactionParameters {
651         fn drop(&mut self) {
652                 if self.is_owned && !<*mut nativeChannelTransactionParameters>::is_null(self.inner) {
653                         let _ = unsafe { Box::from_raw(self.inner) };
654                 }
655         }
656 }
657 /// Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL.
658 #[no_mangle]
659 pub extern "C" fn ChannelTransactionParameters_free(this_obj: ChannelTransactionParameters) { }
660 #[allow(unused)]
661 /// Used only if an object of this type is returned as a trait impl by a method
662 extern "C" fn ChannelTransactionParameters_free_void(this_ptr: *mut c_void) {
663         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelTransactionParameters); }
664 }
665 #[allow(unused)]
666 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
667 impl ChannelTransactionParameters {
668         pub(crate) fn take_inner(mut self) -> *mut nativeChannelTransactionParameters {
669                 assert!(self.is_owned);
670                 let ret = self.inner;
671                 self.inner = std::ptr::null_mut();
672                 ret
673         }
674 }
675 /// Holder public keys
676 #[no_mangle]
677 pub extern "C" fn ChannelTransactionParameters_get_holder_pubkeys(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
678         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_pubkeys;
679         crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
680 }
681 /// Holder public keys
682 #[no_mangle]
683 pub extern "C" fn ChannelTransactionParameters_set_holder_pubkeys(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::chan_utils::ChannelPublicKeys) {
684         unsafe { &mut *this_ptr.inner }.holder_pubkeys = *unsafe { Box::from_raw(val.take_inner()) };
685 }
686 /// The contest delay selected by the holder, which applies to counterparty-broadcast transactions
687 #[no_mangle]
688 pub extern "C" fn ChannelTransactionParameters_get_holder_selected_contest_delay(this_ptr: &ChannelTransactionParameters) -> u16 {
689         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay;
690         *inner_val
691 }
692 /// The contest delay selected by the holder, which applies to counterparty-broadcast transactions
693 #[no_mangle]
694 pub extern "C" fn ChannelTransactionParameters_set_holder_selected_contest_delay(this_ptr: &mut ChannelTransactionParameters, mut val: u16) {
695         unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay = val;
696 }
697 /// Whether the holder is the initiator of this channel.
698 /// This is an input to the commitment number obscure factor computation.
699 #[no_mangle]
700 pub extern "C" fn ChannelTransactionParameters_get_is_outbound_from_holder(this_ptr: &ChannelTransactionParameters) -> bool {
701         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound_from_holder;
702         *inner_val
703 }
704 /// Whether the holder is the initiator of this channel.
705 /// This is an input to the commitment number obscure factor computation.
706 #[no_mangle]
707 pub extern "C" fn ChannelTransactionParameters_set_is_outbound_from_holder(this_ptr: &mut ChannelTransactionParameters, mut val: bool) {
708         unsafe { &mut *this_ptr.inner }.is_outbound_from_holder = val;
709 }
710 /// The late-bound counterparty channel transaction parameters.
711 /// These parameters are populated at the point in the protocol where the counterparty provides them.
712 #[no_mangle]
713 pub extern "C" fn ChannelTransactionParameters_get_counterparty_parameters(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters {
714         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_parameters;
715         let mut local_inner_val = crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
716         local_inner_val
717 }
718 /// The late-bound counterparty channel transaction parameters.
719 /// These parameters are populated at the point in the protocol where the counterparty provides them.
720 #[no_mangle]
721 pub extern "C" fn ChannelTransactionParameters_set_counterparty_parameters(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) {
722         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
723         unsafe { &mut *this_ptr.inner }.counterparty_parameters = local_val;
724 }
725 /// The late-bound funding outpoint
726 #[no_mangle]
727 pub extern "C" fn ChannelTransactionParameters_get_funding_outpoint(this_ptr: &ChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint {
728         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_outpoint;
729         let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
730         local_inner_val
731 }
732 /// The late-bound funding outpoint
733 #[no_mangle]
734 pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::chain::transaction::OutPoint) {
735         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
736         unsafe { &mut *this_ptr.inner }.funding_outpoint = local_val;
737 }
738 /// Constructs a new ChannelTransactionParameters given each field
739 #[must_use]
740 #[no_mangle]
741 pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint) -> ChannelTransactionParameters {
742         let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) };
743         let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) };
744         ChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeChannelTransactionParameters {
745                 holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) },
746                 holder_selected_contest_delay: holder_selected_contest_delay_arg,
747                 is_outbound_from_holder: is_outbound_from_holder_arg,
748                 counterparty_parameters: local_counterparty_parameters_arg,
749                 funding_outpoint: local_funding_outpoint_arg,
750         })), is_owned: true }
751 }
752 impl Clone for ChannelTransactionParameters {
753         fn clone(&self) -> Self {
754                 Self {
755                         inner: if <*mut nativeChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
756                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
757                         is_owned: true,
758                 }
759         }
760 }
761 #[allow(unused)]
762 /// Used only if an object of this type is returned as a trait impl by a method
763 pub(crate) extern "C" fn ChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
764         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelTransactionParameters)).clone() })) as *mut c_void
765 }
766 #[no_mangle]
767 /// Creates a copy of the ChannelTransactionParameters
768 pub extern "C" fn ChannelTransactionParameters_clone(orig: &ChannelTransactionParameters) -> ChannelTransactionParameters {
769         orig.clone()
770 }
771
772 use lightning::ln::chan_utils::CounterpartyChannelTransactionParameters as nativeCounterpartyChannelTransactionParametersImport;
773 type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelTransactionParametersImport;
774
775 /// Late-bound per-channel counterparty data used to build transactions.
776 #[must_use]
777 #[repr(C)]
778 pub struct CounterpartyChannelTransactionParameters {
779         /// A pointer to the opaque Rust object.
780
781         /// Nearly everywhere, inner must be non-null, however in places where
782         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
783         pub inner: *mut nativeCounterpartyChannelTransactionParameters,
784         /// Indicates that this is the only struct which contains the same pointer.
785
786         /// Rust functions which take ownership of an object provided via an argument require
787         /// this to be true and invalidate the object pointed to by inner.
788         pub is_owned: bool,
789 }
790
791 impl Drop for CounterpartyChannelTransactionParameters {
792         fn drop(&mut self) {
793                 if self.is_owned && !<*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) {
794                         let _ = unsafe { Box::from_raw(self.inner) };
795                 }
796         }
797 }
798 /// Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL.
799 #[no_mangle]
800 pub extern "C" fn CounterpartyChannelTransactionParameters_free(this_obj: CounterpartyChannelTransactionParameters) { }
801 #[allow(unused)]
802 /// Used only if an object of this type is returned as a trait impl by a method
803 extern "C" fn CounterpartyChannelTransactionParameters_free_void(this_ptr: *mut c_void) {
804         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCounterpartyChannelTransactionParameters); }
805 }
806 #[allow(unused)]
807 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
808 impl CounterpartyChannelTransactionParameters {
809         pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyChannelTransactionParameters {
810                 assert!(self.is_owned);
811                 let ret = self.inner;
812                 self.inner = std::ptr::null_mut();
813                 ret
814         }
815 }
816 /// Counter-party public keys
817 #[no_mangle]
818 pub extern "C" fn CounterpartyChannelTransactionParameters_get_pubkeys(this_ptr: &CounterpartyChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
819         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkeys;
820         crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
821 }
822 /// Counter-party public keys
823 #[no_mangle]
824 pub extern "C" fn CounterpartyChannelTransactionParameters_set_pubkeys(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: crate::lightning::ln::chan_utils::ChannelPublicKeys) {
825         unsafe { &mut *this_ptr.inner }.pubkeys = *unsafe { Box::from_raw(val.take_inner()) };
826 }
827 /// The contest delay selected by the counterparty, which applies to holder-broadcast transactions
828 #[no_mangle]
829 pub extern "C" fn CounterpartyChannelTransactionParameters_get_selected_contest_delay(this_ptr: &CounterpartyChannelTransactionParameters) -> u16 {
830         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.selected_contest_delay;
831         *inner_val
832 }
833 /// The contest delay selected by the counterparty, which applies to holder-broadcast transactions
834 #[no_mangle]
835 pub extern "C" fn CounterpartyChannelTransactionParameters_set_selected_contest_delay(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: u16) {
836         unsafe { &mut *this_ptr.inner }.selected_contest_delay = val;
837 }
838 /// Constructs a new CounterpartyChannelTransactionParameters given each field
839 #[must_use]
840 #[no_mangle]
841 pub extern "C" fn CounterpartyChannelTransactionParameters_new(mut pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut selected_contest_delay_arg: u16) -> CounterpartyChannelTransactionParameters {
842         CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeCounterpartyChannelTransactionParameters {
843                 pubkeys: *unsafe { Box::from_raw(pubkeys_arg.take_inner()) },
844                 selected_contest_delay: selected_contest_delay_arg,
845         })), is_owned: true }
846 }
847 impl Clone for CounterpartyChannelTransactionParameters {
848         fn clone(&self) -> Self {
849                 Self {
850                         inner: if <*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
851                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
852                         is_owned: true,
853                 }
854         }
855 }
856 #[allow(unused)]
857 /// Used only if an object of this type is returned as a trait impl by a method
858 pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
859         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyChannelTransactionParameters)).clone() })) as *mut c_void
860 }
861 #[no_mangle]
862 /// Creates a copy of the CounterpartyChannelTransactionParameters
863 pub extern "C" fn CounterpartyChannelTransactionParameters_clone(orig: &CounterpartyChannelTransactionParameters) -> CounterpartyChannelTransactionParameters {
864         orig.clone()
865 }
866 /// Whether the late bound parameters are populated.
867 #[must_use]
868 #[no_mangle]
869 pub extern "C" fn ChannelTransactionParameters_is_populated(this_arg: &ChannelTransactionParameters) -> bool {
870         let mut ret = unsafe { &*this_arg.inner }.is_populated();
871         ret
872 }
873
874 /// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
875 /// given that the holder is the broadcaster.
876 ///
877 /// self.is_populated() must be true before calling this function.
878 #[must_use]
879 #[no_mangle]
880 pub extern "C" fn ChannelTransactionParameters_as_holder_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters {
881         let mut ret = unsafe { &*this_arg.inner }.as_holder_broadcastable();
882         crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true }
883 }
884
885 /// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
886 /// given that the counterparty is the broadcaster.
887 ///
888 /// self.is_populated() must be true before calling this function.
889 #[must_use]
890 #[no_mangle]
891 pub extern "C" fn ChannelTransactionParameters_as_counterparty_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters {
892         let mut ret = unsafe { &*this_arg.inner }.as_counterparty_broadcastable();
893         crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true }
894 }
895
896 #[no_mangle]
897 /// Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read
898 pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: &CounterpartyChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z {
899         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
900 }
901 #[no_mangle]
902 pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
903         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) })
904 }
905 #[no_mangle]
906 /// Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write
907 pub extern "C" fn CounterpartyChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyChannelTransactionParametersDecodeErrorZ {
908         let res = crate::c_types::deserialize_obj(ser);
909         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
910         local_res
911 }
912 #[no_mangle]
913 /// Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
914 pub extern "C" fn ChannelTransactionParameters_write(obj: &ChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z {
915         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
916 }
917 #[no_mangle]
918 pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
919         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) })
920 }
921 #[no_mangle]
922 /// Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
923 pub extern "C" fn ChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelTransactionParametersDecodeErrorZ {
924         let res = crate::c_types::deserialize_obj(ser);
925         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
926         local_res
927 }
928
929 use lightning::ln::chan_utils::DirectedChannelTransactionParameters as nativeDirectedChannelTransactionParametersImport;
930 type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static>;
931
932 /// Static channel fields used to build transactions given per-commitment fields, organized by
933 /// broadcaster/countersignatory.
934 ///
935 /// This is derived from the holder/counterparty-organized ChannelTransactionParameters via the
936 /// as_holder_broadcastable and as_counterparty_broadcastable functions.
937 #[must_use]
938 #[repr(C)]
939 pub struct DirectedChannelTransactionParameters {
940         /// A pointer to the opaque Rust object.
941
942         /// Nearly everywhere, inner must be non-null, however in places where
943         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
944         pub inner: *mut nativeDirectedChannelTransactionParameters,
945         /// Indicates that this is the only struct which contains the same pointer.
946
947         /// Rust functions which take ownership of an object provided via an argument require
948         /// this to be true and invalidate the object pointed to by inner.
949         pub is_owned: bool,
950 }
951
952 impl Drop for DirectedChannelTransactionParameters {
953         fn drop(&mut self) {
954                 if self.is_owned && !<*mut nativeDirectedChannelTransactionParameters>::is_null(self.inner) {
955                         let _ = unsafe { Box::from_raw(self.inner) };
956                 }
957         }
958 }
959 /// Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL.
960 #[no_mangle]
961 pub extern "C" fn DirectedChannelTransactionParameters_free(this_obj: DirectedChannelTransactionParameters) { }
962 #[allow(unused)]
963 /// Used only if an object of this type is returned as a trait impl by a method
964 extern "C" fn DirectedChannelTransactionParameters_free_void(this_ptr: *mut c_void) {
965         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelTransactionParameters); }
966 }
967 #[allow(unused)]
968 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
969 impl DirectedChannelTransactionParameters {
970         pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelTransactionParameters {
971                 assert!(self.is_owned);
972                 let ret = self.inner;
973                 self.inner = std::ptr::null_mut();
974                 ret
975         }
976 }
977 /// Get the channel pubkeys for the broadcaster
978 #[must_use]
979 #[no_mangle]
980 pub extern "C" fn DirectedChannelTransactionParameters_broadcaster_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
981         let mut ret = unsafe { &*this_arg.inner }.broadcaster_pubkeys();
982         crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
983 }
984
985 /// Get the channel pubkeys for the countersignatory
986 #[must_use]
987 #[no_mangle]
988 pub extern "C" fn DirectedChannelTransactionParameters_countersignatory_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
989         let mut ret = unsafe { &*this_arg.inner }.countersignatory_pubkeys();
990         crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
991 }
992
993 /// Get the contest delay applicable to the transactions.
994 /// Note that the contest delay was selected by the countersignatory.
995 #[must_use]
996 #[no_mangle]
997 pub extern "C" fn DirectedChannelTransactionParameters_contest_delay(this_arg: &DirectedChannelTransactionParameters) -> u16 {
998         let mut ret = unsafe { &*this_arg.inner }.contest_delay();
999         ret
1000 }
1001
1002 /// Whether the channel is outbound from the broadcaster.
1003 ///
1004 /// The boolean representing the side that initiated the channel is
1005 /// an input to the commitment number obscure factor computation.
1006 #[must_use]
1007 #[no_mangle]
1008 pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &DirectedChannelTransactionParameters) -> bool {
1009         let mut ret = unsafe { &*this_arg.inner }.is_outbound();
1010         ret
1011 }
1012
1013 /// The funding outpoint
1014 #[must_use]
1015 #[no_mangle]
1016 pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &DirectedChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint {
1017         let mut ret = unsafe { &*this_arg.inner }.funding_outpoint();
1018         crate::c_types::bitcoin_to_C_outpoint(ret)
1019 }
1020
1021
1022 use lightning::ln::chan_utils::HolderCommitmentTransaction as nativeHolderCommitmentTransactionImport;
1023 type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport;
1024
1025 /// Information needed to build and sign a holder's commitment transaction.
1026 ///
1027 /// The transaction is only signed once we are ready to broadcast.
1028 #[must_use]
1029 #[repr(C)]
1030 pub struct HolderCommitmentTransaction {
1031         /// A pointer to the opaque Rust object.
1032
1033         /// Nearly everywhere, inner must be non-null, however in places where
1034         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1035         pub inner: *mut nativeHolderCommitmentTransaction,
1036         /// Indicates that this is the only struct which contains the same pointer.
1037
1038         /// Rust functions which take ownership of an object provided via an argument require
1039         /// this to be true and invalidate the object pointed to by inner.
1040         pub is_owned: bool,
1041 }
1042
1043 impl Drop for HolderCommitmentTransaction {
1044         fn drop(&mut self) {
1045                 if self.is_owned && !<*mut nativeHolderCommitmentTransaction>::is_null(self.inner) {
1046                         let _ = unsafe { Box::from_raw(self.inner) };
1047                 }
1048         }
1049 }
1050 /// Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL.
1051 #[no_mangle]
1052 pub extern "C" fn HolderCommitmentTransaction_free(this_obj: HolderCommitmentTransaction) { }
1053 #[allow(unused)]
1054 /// Used only if an object of this type is returned as a trait impl by a method
1055 extern "C" fn HolderCommitmentTransaction_free_void(this_ptr: *mut c_void) {
1056         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHolderCommitmentTransaction); }
1057 }
1058 #[allow(unused)]
1059 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1060 impl HolderCommitmentTransaction {
1061         pub(crate) fn take_inner(mut self) -> *mut nativeHolderCommitmentTransaction {
1062                 assert!(self.is_owned);
1063                 let ret = self.inner;
1064                 self.inner = std::ptr::null_mut();
1065                 ret
1066         }
1067 }
1068 /// Our counterparty's signature for the transaction
1069 #[no_mangle]
1070 pub extern "C" fn HolderCommitmentTransaction_get_counterparty_sig(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Signature {
1071         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_sig;
1072         crate::c_types::Signature::from_rust(&inner_val)
1073 }
1074 /// Our counterparty's signature for the transaction
1075 #[no_mangle]
1076 pub extern "C" fn HolderCommitmentTransaction_set_counterparty_sig(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Signature) {
1077         unsafe { &mut *this_ptr.inner }.counterparty_sig = val.into_rust();
1078 }
1079 /// All non-dust counterparty HTLC signatures, in the order they appear in the transaction
1080 #[no_mangle]
1081 pub extern "C" fn HolderCommitmentTransaction_set_counterparty_htlc_sigs(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::derived::CVec_SignatureZ) {
1082         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
1083         unsafe { &mut *this_ptr.inner }.counterparty_htlc_sigs = local_val;
1084 }
1085 impl Clone for HolderCommitmentTransaction {
1086         fn clone(&self) -> Self {
1087                 Self {
1088                         inner: if <*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
1089                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1090                         is_owned: true,
1091                 }
1092         }
1093 }
1094 #[allow(unused)]
1095 /// Used only if an object of this type is returned as a trait impl by a method
1096 pub(crate) extern "C" fn HolderCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void {
1097         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHolderCommitmentTransaction)).clone() })) as *mut c_void
1098 }
1099 #[no_mangle]
1100 /// Creates a copy of the HolderCommitmentTransaction
1101 pub extern "C" fn HolderCommitmentTransaction_clone(orig: &HolderCommitmentTransaction) -> HolderCommitmentTransaction {
1102         orig.clone()
1103 }
1104 #[no_mangle]
1105 /// Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read
1106 pub extern "C" fn HolderCommitmentTransaction_write(obj: &HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
1107         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1108 }
1109 #[no_mangle]
1110 pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1111         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) })
1112 }
1113 #[no_mangle]
1114 /// Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write
1115 pub extern "C" fn HolderCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HolderCommitmentTransactionDecodeErrorZ {
1116         let res = crate::c_types::deserialize_obj(ser);
1117         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1118         local_res
1119 }
1120 /// Create a new holder transaction with the given counterparty signatures.
1121 /// The funding keys are used to figure out which signature should go first when building the transaction for broadcast.
1122 #[must_use]
1123 #[no_mangle]
1124 pub extern "C" fn HolderCommitmentTransaction_new(mut commitment_tx: crate::lightning::ln::chan_utils::CommitmentTransaction, mut counterparty_sig: crate::c_types::Signature, mut counterparty_htlc_sigs: crate::c_types::derived::CVec_SignatureZ, mut holder_funding_key: crate::c_types::PublicKey, mut counterparty_funding_key: crate::c_types::PublicKey) -> HolderCommitmentTransaction {
1125         let mut local_counterparty_htlc_sigs = Vec::new(); for mut item in counterparty_htlc_sigs.into_rust().drain(..) { local_counterparty_htlc_sigs.push( { item.into_rust() }); };
1126         let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new(*unsafe { Box::from_raw(commitment_tx.take_inner()) }, counterparty_sig.into_rust(), local_counterparty_htlc_sigs, &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust());
1127         HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1128 }
1129
1130
1131 use lightning::ln::chan_utils::BuiltCommitmentTransaction as nativeBuiltCommitmentTransactionImport;
1132 type nativeBuiltCommitmentTransaction = nativeBuiltCommitmentTransactionImport;
1133
1134 /// A pre-built Bitcoin commitment transaction and its txid.
1135 #[must_use]
1136 #[repr(C)]
1137 pub struct BuiltCommitmentTransaction {
1138         /// A pointer to the opaque Rust object.
1139
1140         /// Nearly everywhere, inner must be non-null, however in places where
1141         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1142         pub inner: *mut nativeBuiltCommitmentTransaction,
1143         /// Indicates that this is the only struct which contains the same pointer.
1144
1145         /// Rust functions which take ownership of an object provided via an argument require
1146         /// this to be true and invalidate the object pointed to by inner.
1147         pub is_owned: bool,
1148 }
1149
1150 impl Drop for BuiltCommitmentTransaction {
1151         fn drop(&mut self) {
1152                 if self.is_owned && !<*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) {
1153                         let _ = unsafe { Box::from_raw(self.inner) };
1154                 }
1155         }
1156 }
1157 /// Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL.
1158 #[no_mangle]
1159 pub extern "C" fn BuiltCommitmentTransaction_free(this_obj: BuiltCommitmentTransaction) { }
1160 #[allow(unused)]
1161 /// Used only if an object of this type is returned as a trait impl by a method
1162 extern "C" fn BuiltCommitmentTransaction_free_void(this_ptr: *mut c_void) {
1163         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBuiltCommitmentTransaction); }
1164 }
1165 #[allow(unused)]
1166 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1167 impl BuiltCommitmentTransaction {
1168         pub(crate) fn take_inner(mut self) -> *mut nativeBuiltCommitmentTransaction {
1169                 assert!(self.is_owned);
1170                 let ret = self.inner;
1171                 self.inner = std::ptr::null_mut();
1172                 ret
1173         }
1174 }
1175 /// The commitment transaction
1176 #[no_mangle]
1177 pub extern "C" fn BuiltCommitmentTransaction_get_transaction(this_ptr: &BuiltCommitmentTransaction) -> crate::c_types::Transaction {
1178         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction;
1179         crate::c_types::Transaction::from_bitcoin(inner_val)
1180 }
1181 /// The commitment transaction
1182 #[no_mangle]
1183 pub extern "C" fn BuiltCommitmentTransaction_set_transaction(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::Transaction) {
1184         unsafe { &mut *this_ptr.inner }.transaction = val.into_bitcoin();
1185 }
1186 /// The txid for the commitment transaction.
1187 ///
1188 /// This is provided as a performance optimization, instead of calling transaction.txid()
1189 /// multiple times.
1190 #[no_mangle]
1191 pub extern "C" fn BuiltCommitmentTransaction_get_txid(this_ptr: &BuiltCommitmentTransaction) -> *const [u8; 32] {
1192         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid;
1193         inner_val.as_inner()
1194 }
1195 /// The txid for the commitment transaction.
1196 ///
1197 /// This is provided as a performance optimization, instead of calling transaction.txid()
1198 /// multiple times.
1199 #[no_mangle]
1200 pub extern "C" fn BuiltCommitmentTransaction_set_txid(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::ThirtyTwoBytes) {
1201         unsafe { &mut *this_ptr.inner }.txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1202 }
1203 /// Constructs a new BuiltCommitmentTransaction given each field
1204 #[must_use]
1205 #[no_mangle]
1206 pub extern "C" fn BuiltCommitmentTransaction_new(mut transaction_arg: crate::c_types::Transaction, mut txid_arg: crate::c_types::ThirtyTwoBytes) -> BuiltCommitmentTransaction {
1207         BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(nativeBuiltCommitmentTransaction {
1208                 transaction: transaction_arg.into_bitcoin(),
1209                 txid: ::bitcoin::hash_types::Txid::from_slice(&txid_arg.data[..]).unwrap(),
1210         })), is_owned: true }
1211 }
1212 impl Clone for BuiltCommitmentTransaction {
1213         fn clone(&self) -> Self {
1214                 Self {
1215                         inner: if <*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
1216                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1217                         is_owned: true,
1218                 }
1219         }
1220 }
1221 #[allow(unused)]
1222 /// Used only if an object of this type is returned as a trait impl by a method
1223 pub(crate) extern "C" fn BuiltCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void {
1224         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBuiltCommitmentTransaction)).clone() })) as *mut c_void
1225 }
1226 #[no_mangle]
1227 /// Creates a copy of the BuiltCommitmentTransaction
1228 pub extern "C" fn BuiltCommitmentTransaction_clone(orig: &BuiltCommitmentTransaction) -> BuiltCommitmentTransaction {
1229         orig.clone()
1230 }
1231 #[no_mangle]
1232 /// Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
1233 pub extern "C" fn BuiltCommitmentTransaction_write(obj: &BuiltCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
1234         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1235 }
1236 #[no_mangle]
1237 pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1238         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) })
1239 }
1240 #[no_mangle]
1241 /// Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
1242 pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BuiltCommitmentTransactionDecodeErrorZ {
1243         let res = crate::c_types::deserialize_obj(ser);
1244         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1245         local_res
1246 }
1247 /// Get the SIGHASH_ALL sighash value of the transaction.
1248 ///
1249 /// This can be used to verify a signature.
1250 #[must_use]
1251 #[no_mangle]
1252 pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes {
1253         let mut ret = unsafe { &*this_arg.inner }.get_sighash_all(&::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis);
1254         crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() }
1255 }
1256
1257 /// Sign a transaction, either because we are counter-signing the counterparty's transaction or
1258 /// because we are about to broadcast a holder transaction.
1259 #[must_use]
1260 #[no_mangle]
1261 pub extern "C" fn BuiltCommitmentTransaction_sign(this_arg: &BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature {
1262         let mut ret = unsafe { &*this_arg.inner }.sign(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, secp256k1::SECP256K1);
1263         crate::c_types::Signature::from_rust(&ret)
1264 }
1265
1266
1267 use lightning::ln::chan_utils::CommitmentTransaction as nativeCommitmentTransactionImport;
1268 type nativeCommitmentTransaction = nativeCommitmentTransactionImport;
1269
1270 /// This class tracks the per-transaction information needed to build a commitment transaction and to
1271 /// actually build it and sign.  It is used for holder transactions that we sign only when needed
1272 /// and for transactions we sign for the counterparty.
1273 ///
1274 /// This class can be used inside a signer implementation to generate a signature given the relevant
1275 /// secret key.
1276 #[must_use]
1277 #[repr(C)]
1278 pub struct CommitmentTransaction {
1279         /// A pointer to the opaque Rust object.
1280
1281         /// Nearly everywhere, inner must be non-null, however in places where
1282         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1283         pub inner: *mut nativeCommitmentTransaction,
1284         /// Indicates that this is the only struct which contains the same pointer.
1285
1286         /// Rust functions which take ownership of an object provided via an argument require
1287         /// this to be true and invalidate the object pointed to by inner.
1288         pub is_owned: bool,
1289 }
1290
1291 impl Drop for CommitmentTransaction {
1292         fn drop(&mut self) {
1293                 if self.is_owned && !<*mut nativeCommitmentTransaction>::is_null(self.inner) {
1294                         let _ = unsafe { Box::from_raw(self.inner) };
1295                 }
1296         }
1297 }
1298 /// Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL.
1299 #[no_mangle]
1300 pub extern "C" fn CommitmentTransaction_free(this_obj: CommitmentTransaction) { }
1301 #[allow(unused)]
1302 /// Used only if an object of this type is returned as a trait impl by a method
1303 extern "C" fn CommitmentTransaction_free_void(this_ptr: *mut c_void) {
1304         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentTransaction); }
1305 }
1306 #[allow(unused)]
1307 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1308 impl CommitmentTransaction {
1309         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentTransaction {
1310                 assert!(self.is_owned);
1311                 let ret = self.inner;
1312                 self.inner = std::ptr::null_mut();
1313                 ret
1314         }
1315 }
1316 impl Clone for CommitmentTransaction {
1317         fn clone(&self) -> Self {
1318                 Self {
1319                         inner: if <*mut nativeCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
1320                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1321                         is_owned: true,
1322                 }
1323         }
1324 }
1325 #[allow(unused)]
1326 /// Used only if an object of this type is returned as a trait impl by a method
1327 pub(crate) extern "C" fn CommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void {
1328         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentTransaction)).clone() })) as *mut c_void
1329 }
1330 #[no_mangle]
1331 /// Creates a copy of the CommitmentTransaction
1332 pub extern "C" fn CommitmentTransaction_clone(orig: &CommitmentTransaction) -> CommitmentTransaction {
1333         orig.clone()
1334 }
1335 #[no_mangle]
1336 /// Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read
1337 pub extern "C" fn CommitmentTransaction_write(obj: &CommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
1338         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1339 }
1340 #[no_mangle]
1341 pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1342         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentTransaction) })
1343 }
1344 #[no_mangle]
1345 /// Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write
1346 pub extern "C" fn CommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentTransactionDecodeErrorZ {
1347         let res = crate::c_types::deserialize_obj(ser);
1348         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::CommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1349         local_res
1350 }
1351 /// The backwards-counting commitment number
1352 #[must_use]
1353 #[no_mangle]
1354 pub extern "C" fn CommitmentTransaction_commitment_number(this_arg: &CommitmentTransaction) -> u64 {
1355         let mut ret = unsafe { &*this_arg.inner }.commitment_number();
1356         ret
1357 }
1358
1359 /// The value to be sent to the broadcaster
1360 #[must_use]
1361 #[no_mangle]
1362 pub extern "C" fn CommitmentTransaction_to_broadcaster_value_sat(this_arg: &CommitmentTransaction) -> u64 {
1363         let mut ret = unsafe { &*this_arg.inner }.to_broadcaster_value_sat();
1364         ret
1365 }
1366
1367 /// The value to be sent to the counterparty
1368 #[must_use]
1369 #[no_mangle]
1370 pub extern "C" fn CommitmentTransaction_to_countersignatory_value_sat(this_arg: &CommitmentTransaction) -> u64 {
1371         let mut ret = unsafe { &*this_arg.inner }.to_countersignatory_value_sat();
1372         ret
1373 }
1374
1375 /// The feerate paid per 1000-weight-unit in this commitment transaction.
1376 #[must_use]
1377 #[no_mangle]
1378 pub extern "C" fn CommitmentTransaction_feerate_per_kw(this_arg: &CommitmentTransaction) -> u32 {
1379         let mut ret = unsafe { &*this_arg.inner }.feerate_per_kw();
1380         ret
1381 }
1382
1383 /// Trust our pre-built transaction and derived transaction creation public keys.
1384 ///
1385 /// Applies a wrapper which allows access to these fields.
1386 ///
1387 /// This should only be used if you fully trust the builder of this object.  It should not
1388 ///\tbe used by an external signer - instead use the verify function.
1389 #[must_use]
1390 #[no_mangle]
1391 pub extern "C" fn CommitmentTransaction_trust(this_arg: &CommitmentTransaction) -> crate::lightning::ln::chan_utils::TrustedCommitmentTransaction {
1392         let mut ret = unsafe { &*this_arg.inner }.trust();
1393         crate::lightning::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1394 }
1395
1396 /// Verify our pre-built transaction and derived transaction creation public keys.
1397 ///
1398 /// Applies a wrapper which allows access to these fields.
1399 ///
1400 /// An external validating signer must call this method before signing
1401 /// or using the built transaction.
1402 #[must_use]
1403 #[no_mangle]
1404 pub extern "C" fn CommitmentTransaction_verify(this_arg: &CommitmentTransaction, channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, broadcaster_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TrustedCommitmentTransactionNoneZ {
1405         let mut ret = unsafe { &*this_arg.inner }.verify(unsafe { &*channel_parameters.inner }, unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, secp256k1::SECP256K1);
1406         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
1407         local_ret
1408 }
1409
1410
1411 use lightning::ln::chan_utils::TrustedCommitmentTransaction as nativeTrustedCommitmentTransactionImport;
1412 type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImport<'static>;
1413
1414 /// A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin
1415 /// transaction and the transaction creation keys) are trusted.
1416 ///
1417 /// See trust() and verify() functions on CommitmentTransaction.
1418 ///
1419 /// This structure implements Deref.
1420 #[must_use]
1421 #[repr(C)]
1422 pub struct TrustedCommitmentTransaction {
1423         /// A pointer to the opaque Rust object.
1424
1425         /// Nearly everywhere, inner must be non-null, however in places where
1426         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1427         pub inner: *mut nativeTrustedCommitmentTransaction,
1428         /// Indicates that this is the only struct which contains the same pointer.
1429
1430         /// Rust functions which take ownership of an object provided via an argument require
1431         /// this to be true and invalidate the object pointed to by inner.
1432         pub is_owned: bool,
1433 }
1434
1435 impl Drop for TrustedCommitmentTransaction {
1436         fn drop(&mut self) {
1437                 if self.is_owned && !<*mut nativeTrustedCommitmentTransaction>::is_null(self.inner) {
1438                         let _ = unsafe { Box::from_raw(self.inner) };
1439                 }
1440         }
1441 }
1442 /// Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL.
1443 #[no_mangle]
1444 pub extern "C" fn TrustedCommitmentTransaction_free(this_obj: TrustedCommitmentTransaction) { }
1445 #[allow(unused)]
1446 /// Used only if an object of this type is returned as a trait impl by a method
1447 extern "C" fn TrustedCommitmentTransaction_free_void(this_ptr: *mut c_void) {
1448         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTrustedCommitmentTransaction); }
1449 }
1450 #[allow(unused)]
1451 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1452 impl TrustedCommitmentTransaction {
1453         pub(crate) fn take_inner(mut self) -> *mut nativeTrustedCommitmentTransaction {
1454                 assert!(self.is_owned);
1455                 let ret = self.inner;
1456                 self.inner = std::ptr::null_mut();
1457                 ret
1458         }
1459 }
1460 /// The transaction ID of the built Bitcoin transaction
1461 #[must_use]
1462 #[no_mangle]
1463 pub extern "C" fn TrustedCommitmentTransaction_txid(this_arg: &TrustedCommitmentTransaction) -> crate::c_types::ThirtyTwoBytes {
1464         let mut ret = unsafe { &*this_arg.inner }.txid();
1465         crate::c_types::ThirtyTwoBytes { data: ret.into_inner() }
1466 }
1467
1468 /// The pre-built Bitcoin commitment transaction
1469 #[must_use]
1470 #[no_mangle]
1471 pub extern "C" fn TrustedCommitmentTransaction_built_transaction(this_arg: &TrustedCommitmentTransaction) -> crate::lightning::ln::chan_utils::BuiltCommitmentTransaction {
1472         let mut ret = unsafe { &*this_arg.inner }.built_transaction();
1473         crate::lightning::ln::chan_utils::BuiltCommitmentTransaction { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
1474 }
1475
1476 /// The pre-calculated transaction creation public keys.
1477 #[must_use]
1478 #[no_mangle]
1479 pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &TrustedCommitmentTransaction) -> crate::lightning::ln::chan_utils::TxCreationKeys {
1480         let mut ret = unsafe { &*this_arg.inner }.keys();
1481         crate::lightning::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
1482 }
1483
1484 /// Get a signature for each HTLC which was included in the commitment transaction (ie for
1485 /// which HTLCOutputInCommitment::transaction_output_index.is_some()).
1486 ///
1487 /// The returned Vec has one entry for each HTLC, and in the same order.
1488 #[must_use]
1489 #[no_mangle]
1490 pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
1491         let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), unsafe { &*channel_parameters.inner }, secp256k1::SECP256K1);
1492         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
1493         local_ret
1494 }
1495
1496 /// Get the transaction number obscure factor
1497 #[no_mangle]
1498 pub extern "C" fn get_commitment_transaction_number_obscure_factor(mut broadcaster_payment_basepoint: crate::c_types::PublicKey, mut countersignatory_payment_basepoint: crate::c_types::PublicKey, mut outbound_from_broadcaster: bool) -> u64 {
1499         let mut ret = lightning::ln::chan_utils::get_commitment_transaction_number_obscure_factor(&broadcaster_payment_basepoint.into_rust(), &countersignatory_payment_basepoint.into_rust(), outbound_from_broadcaster);
1500         ret
1501 }
1502