9103429ada8e6210437c7539ae9c2f81194d7e00
[ldk-c-bindings] / lightning-c-bindings / src / lightning / util / invoice.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 //! Low level invoice utilities.
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 /// Construct the invoice's HRP and signatureless data into a preimage to be hashed.
20 #[no_mangle]
21 pub extern "C" fn construct_invoice_preimage(mut hrp_bytes: crate::c_types::u8slice, mut data_without_signature: crate::c_types::derived::CVec_u5Z) -> crate::c_types::derived::CVec_u8Z {
22         let mut local_data_without_signature = Vec::new(); for mut item in data_without_signature.into_rust().drain(..) { local_data_without_signature.push( { item.into() }); };
23         let mut ret = lightning::util::invoice::construct_invoice_preimage(hrp_bytes.to_slice(), &local_data_without_signature[..]);
24         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); };
25         local_ret.into()
26 }
27