Update CI/Cargo.toml references to 0.0.122
[ldk-c-bindings] / lightning-c-bindings / src / lightning_invoice / payment.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 for paying Lightning invoices.
10
11 use alloc::str::FromStr;
12 use alloc::string::String;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
19
20 /// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
21 /// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
22 /// [`ChannelManager::send_preflight_probes`].
23 ///
24 /// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
25 /// same [`PaymentHash`] has never been paid before.
26 ///
27 /// Will always succeed unless the invoice has an amount specified, in which case
28 /// [`payment_parameters_from_invoice`] should be used.
29 ///
30 /// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
31 /// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
32 #[no_mangle]
33 pub extern "C" fn payment_parameters_from_zero_amount_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msat: u64) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ {
34         let mut ret = lightning_invoice::payment::payment_parameters_from_zero_amount_invoice(invoice.get_native_ref(), amount_msat);
35         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
36         local_ret
37 }
38
39 /// Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using
40 /// [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`].
41 ///
42 /// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
43 /// same [`PaymentHash`] has never been paid before.
44 ///
45 /// Will always succeed unless the invoice has no amount specified, in which case
46 /// [`payment_parameters_from_zero_amount_invoice`] should be used.
47 ///
48 /// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
49 /// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
50 #[no_mangle]
51 pub extern "C" fn payment_parameters_from_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ {
52         let mut ret = lightning_invoice::payment::payment_parameters_from_invoice(invoice.get_native_ref());
53         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
54         local_ret
55 }
56