Merge pull request #68 from jkczyz/2022-03-ldk-0-0-106
[ldk-c-bindings] / lightning-c-bindings / src / lightning_invoice / 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 //! Convenient utilities to create an invoice.
10
11 use alloc::str::FromStr;
12 use core::ffi::c_void;
13 use core::convert::Infallible;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
16 #[cfg(feature="no-std")]
17 use alloc::{vec::Vec, boxed::Box};
18
19 /// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
20 /// See [`PhantomKeysManager`] for more information on phantom node payments.
21 ///
22 /// `phantom_route_hints` parameter:
23 /// * Contains channel info for all nodes participating in the phantom invoice
24 /// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
25 ///   participating node
26 /// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
27 ///   updated when a channel becomes disabled or closes
28 /// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
29 ///   may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
30 ///   down
31 ///
32 /// `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
33 /// [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
34 /// participating node.
35 ///
36 /// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
37 /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
38 /// requirement).
39 ///
40 /// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
41 /// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
42 /// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
43 #[no_mangle]
44 pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
45         let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
46         let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
47         let mut ret = lightning_invoice::utils::create_phantom_invoice::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::keysinterface::KeysInterface>(local_amt_msat, description.into_string(), ::lightning::ln::PaymentHash(payment_hash.data), ::lightning::ln::PaymentSecret(payment_secret.data), local_phantom_route_hints, keys_manager, network.into_native());
48         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
49         local_ret
50 }
51
52 /// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
53 /// See [`PhantomKeysManager`] for more information on phantom node payments.
54 ///
55 /// `phantom_route_hints` parameter:
56 /// * Contains channel info for all nodes participating in the phantom invoice
57 /// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
58 ///   participating node
59 /// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
60 ///   updated when a channel becomes disabled or closes
61 /// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
62 ///   may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
63 ///   down
64 ///
65 /// `description_hash` is a SHA-256 hash of the description text
66 ///
67 /// `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
68 /// [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
69 /// participating node.
70 ///
71 /// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
72 /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
73 /// requirement).
74 ///
75 /// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
76 /// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
77 /// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
78 #[no_mangle]
79 pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
80         let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
81         let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
82         let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::keysinterface::KeysInterface>(local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, ::lightning::ln::PaymentHash(payment_hash.data), ::lightning::ln::PaymentSecret(payment_secret.data), local_phantom_route_hints, keys_manager, network.into_native());
83         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
84         local_ret
85 }
86
87 /// Utility to construct an invoice. Generally, unless you want to do something like a custom
88 /// cltv_expiry, this is what you should be using to create an invoice. The reason being, this
89 /// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
90 /// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
91 /// that the payment secret is valid when the invoice is paid.
92 #[no_mangle]
93 pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
94         let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
95         let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, description.into_string());
96         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
97         local_ret
98 }
99
100 /// Utility to construct an invoice. Generally, unless you want to do something like a custom
101 /// cltv_expiry, this is what you should be using to create an invoice. The reason being, this
102 /// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
103 /// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
104 /// that the payment secret is valid when the invoice is paid.
105 /// Use this variant if you want to pass the `description_hash` to the invoice.
106 #[no_mangle]
107 pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
108         let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
109         let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) });
110         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
111         local_ret
112 }
113
114 /// See [`create_invoice_from_channelmanager_with_description_hash`]
115 /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
116 /// available and the current time is supplied by the caller.
117 #[no_mangle]
118 pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
119         let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
120         let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch));
121         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
122         local_ret
123 }
124
125 /// See [`create_invoice_from_channelmanager`]
126 /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
127 /// available and the current time is supplied by the caller.
128 #[no_mangle]
129 pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
130         let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
131         let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch));
132         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
133         local_ret
134 }
135
136
137 use lightning_invoice::utils::DefaultRouter as nativeDefaultRouterImport;
138 pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::network_graph::NetworkGraph, crate::lightning::util::logger::Logger>;
139
140 /// A [`Router`] implemented using [`find_route`].
141 #[must_use]
142 #[repr(C)]
143 pub struct DefaultRouter {
144         /// A pointer to the opaque Rust object.
145
146         /// Nearly everywhere, inner must be non-null, however in places where
147         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
148         pub inner: *mut nativeDefaultRouter,
149         /// Indicates that this is the only struct which contains the same pointer.
150
151         /// Rust functions which take ownership of an object provided via an argument require
152         /// this to be true and invalidate the object pointed to by inner.
153         pub is_owned: bool,
154 }
155
156 impl Drop for DefaultRouter {
157         fn drop(&mut self) {
158                 if self.is_owned && !<*mut nativeDefaultRouter>::is_null(self.inner) {
159                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
160                 }
161         }
162 }
163 /// Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL.
164 #[no_mangle]
165 pub extern "C" fn DefaultRouter_free(this_obj: DefaultRouter) { }
166 #[allow(unused)]
167 /// Used only if an object of this type is returned as a trait impl by a method
168 pub(crate) extern "C" fn DefaultRouter_free_void(this_ptr: *mut c_void) {
169         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDefaultRouter); }
170 }
171 #[allow(unused)]
172 impl DefaultRouter {
173         pub(crate) fn get_native_ref(&self) -> &'static nativeDefaultRouter {
174                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
175         }
176         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDefaultRouter {
177                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
178         }
179         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
180         pub(crate) fn take_inner(mut self) -> *mut nativeDefaultRouter {
181                 assert!(self.is_owned);
182                 let ret = ObjOps::untweak_ptr(self.inner);
183                 self.inner = core::ptr::null_mut();
184                 ret
185         }
186 }
187 /// Creates a new router using the given [`NetworkGraph`], a [`Logger`], and a randomness source
188 /// `random_seed_bytes`.
189 #[must_use]
190 #[no_mangle]
191 pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::network_graph::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes) -> DefaultRouter {
192         let mut ret = lightning_invoice::utils::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data);
193         DefaultRouter { inner: ObjOps::heap_alloc(ret), is_owned: true }
194 }
195
196 impl From<nativeDefaultRouter> for crate::lightning_invoice::payment::Router {
197         fn from(obj: nativeDefaultRouter) -> Self {
198                 let mut rust_obj = DefaultRouter { inner: ObjOps::heap_alloc(obj), is_owned: true };
199                 let mut ret = DefaultRouter_as_Router(&rust_obj);
200                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
201                 rust_obj.inner = core::ptr::null_mut();
202                 ret.free = Some(DefaultRouter_free_void);
203                 ret
204         }
205 }
206 /// Constructs a new Router which calls the relevant methods on this_arg.
207 /// This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is
208 #[no_mangle]
209 pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::lightning_invoice::payment::Router {
210         crate::lightning_invoice::payment::Router {
211                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
212                 free: None,
213                 find_route: DefaultRouter_Router_find_route,
214         }
215 }
216
217 #[must_use]
218 extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, params: &crate::lightning::routing::router::RouteParameters, _payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
219         let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
220         let mut ret = <nativeDefaultRouter as lightning_invoice::payment::Router<_>>::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), params.get_native_ref(), &::lightning::ln::PaymentHash(unsafe { *_payment_hash }), local_first_hops, scorer);
221         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
222         local_ret
223 }
224
225 use crate::lightning::ln::channelmanager::nativeChannelManager as nativeChannelManager;
226 use crate::lightning::ln::channelmanager::ChannelManager;
227 use crate::lightning::ln::channelmanager::ChannelManager_free_void;
228 impl From<nativeChannelManager> for crate::lightning_invoice::payment::Payer {
229         fn from(obj: nativeChannelManager) -> Self {
230                 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
231                 let mut ret = ChannelManager_as_Payer(&rust_obj);
232                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
233                 rust_obj.inner = core::ptr::null_mut();
234                 ret.free = Some(ChannelManager_free_void);
235                 ret
236         }
237 }
238 /// Constructs a new Payer which calls the relevant methods on this_arg.
239 /// This copies the `inner` pointer in this_arg and thus the returned Payer must be freed before this_arg is
240 #[no_mangle]
241 pub extern "C" fn ChannelManager_as_Payer(this_arg: &ChannelManager) -> crate::lightning_invoice::payment::Payer {
242         crate::lightning_invoice::payment::Payer {
243                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
244                 free: None,
245                 node_id: ChannelManager_Payer_node_id,
246                 first_hops: ChannelManager_Payer_first_hops,
247                 send_payment: ChannelManager_Payer_send_payment,
248                 send_spontaneous_payment: ChannelManager_Payer_send_spontaneous_payment,
249                 retry_payment: ChannelManager_Payer_retry_payment,
250                 abandon_payment: ChannelManager_Payer_abandon_payment,
251         }
252 }
253
254 #[must_use]
255 extern "C" fn ChannelManager_Payer_node_id(this_arg: *const c_void) -> crate::c_types::PublicKey {
256         let mut ret = <nativeChannelManager as lightning_invoice::payment::Payer<>>::node_id(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
257         crate::c_types::PublicKey::from_rust(&ret)
258 }
259 #[must_use]
260 extern "C" fn ChannelManager_Payer_first_hops(this_arg: *const c_void) -> crate::c_types::derived::CVec_ChannelDetailsZ {
261         let mut ret = <nativeChannelManager as lightning_invoice::payment::Payer<>>::first_hops(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
262         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
263         local_ret.into()
264 }
265 #[must_use]
266 extern "C" fn ChannelManager_Payer_send_payment(this_arg: *const c_void, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentIdPaymentSendFailureZ {
267         let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret.data) }) };
268         let mut ret = <nativeChannelManager as lightning_invoice::payment::Payer<>>::send_payment(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, route.get_native_ref(), ::lightning::ln::PaymentHash(payment_hash.data), &local_payment_secret);
269         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
270         local_ret
271 }
272 #[must_use]
273 extern "C" fn ChannelManager_Payer_send_spontaneous_payment(this_arg: *const c_void, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentIdPaymentSendFailureZ {
274         let mut ret = <nativeChannelManager as lightning_invoice::payment::Payer<>>::send_spontaneous_payment(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, route.get_native_ref(), ::lightning::ln::PaymentPreimage(payment_preimage.data));
275         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
276         local_ret
277 }
278 #[must_use]
279 extern "C" fn ChannelManager_Payer_retry_payment(this_arg: *const c_void, route: &crate::lightning::routing::router::Route, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
280         let mut ret = <nativeChannelManager as lightning_invoice::payment::Payer<>>::retry_payment(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, route.get_native_ref(), ::lightning::ln::channelmanager::PaymentId(payment_id.data));
281         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
282         local_ret
283 }
284 extern "C" fn ChannelManager_Payer_abandon_payment(this_arg: *const c_void, mut payment_id: crate::c_types::ThirtyTwoBytes) {
285         <nativeChannelManager as lightning_invoice::payment::Payer<>>::abandon_payment(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data))
286 }
287