Skip to content

Commit 01a48d1

Browse files
committed
Add public ffi module
In order to de-clutter the HTML docs add a public submodule `ffi` and put the C function definitions in it.
1 parent 6782fd1 commit 01a48d1

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/lib.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod types;
1717

1818
use core::fmt;
1919

20-
use crate::types::{c_int, c_uchar, c_uint};
20+
use crate::types::c_uint;
2121

2222
/// Do not enable any verification.
2323
pub const VERIFY_NONE: c_uint = 0;
@@ -65,7 +65,7 @@ pub fn height_to_flags(height: u32) -> u32 {
6565
}
6666

6767
/// Returns `libbitcoinconsensus` version.
68-
pub fn version() -> u32 { unsafe { bitcoinconsensus_version() as u32 } }
68+
pub fn version() -> u32 { unsafe { ffi::bitcoinconsensus_version() as u32 } }
6969

7070
/// Verifies a single spend (input) of a Bitcoin transaction.
7171
///
@@ -120,7 +120,7 @@ pub fn verify_with_flags(
120120
unsafe {
121121
let mut error = Error::ERR_SCRIPT;
122122

123-
let ret = bitcoinconsensus_verify_script_with_amount(
123+
let ret = ffi::bitcoinconsensus_verify_script_with_amount(
124124
spent_output_script.as_ptr(),
125125
spent_output_script.len() as c_uint,
126126
amount,
@@ -138,22 +138,27 @@ pub fn verify_with_flags(
138138
}
139139
}
140140

141-
extern "C" {
142-
/// Returns `libbitcoinconsensus` version.
143-
pub fn bitcoinconsensus_version() -> c_int;
141+
pub mod ffi {
142+
use crate::types::{c_int, c_uchar, c_uint};
143+
use crate::Error;
144144

145-
/// Verifies that the transaction input correctly spends the previous
146-
/// output, considering any additional constraints specified by flags.
147-
pub fn bitcoinconsensus_verify_script_with_amount(
148-
script_pubkey: *const c_uchar,
149-
script_pubkeylen: c_uint,
150-
amount: u64,
151-
tx_to: *const c_uchar,
152-
tx_tolen: c_uint,
153-
n_in: c_uint,
154-
flags: c_uint,
155-
err: *mut Error,
156-
) -> c_int;
145+
extern "C" {
146+
/// Returns `libbitcoinconsensus` version.
147+
pub fn bitcoinconsensus_version() -> c_int;
148+
149+
/// Verifies that the transaction input correctly spends the previous
150+
/// output, considering any additional constraints specified by flags.
151+
pub fn bitcoinconsensus_verify_script_with_amount(
152+
script_pubkey: *const c_uchar,
153+
script_pubkeylen: c_uint,
154+
amount: u64,
155+
tx_to: *const c_uchar,
156+
tx_tolen: c_uint,
157+
n_in: c_uint,
158+
flags: c_uint,
159+
err: *mut Error,
160+
) -> c_int;
161+
}
157162
}
158163

159164
/// Errors returned by [`libbitcoinconsensus`].

0 commit comments

Comments
 (0)