You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
01a48d1 Add public ffi module (Tobin C. Harding)
6782fd1 Remove travis config file (Tobin C. Harding)
a446115 Remove written by comment (Tobin C. Harding)
e8ff1a9 Shoosh C++ compiler (Tobin C. Harding)
8d21e3d Fix rustdoc link (Tobin C. Harding)
596e2ce Move extern C stuff to bottom of file (Tobin C. Harding)
7c1cb29 Remove wildcard import (Tobin C. Harding)
1d36f2c Move error code to bottom of file (Tobin C. Harding)
bed7cde Improve docs on verify function (Tobin C. Harding)
Pull request description:
This is #67 without the final version bump patch.
Do a bunch of cleanups then add an `ffi` module to encapsulate the FFI function declarations.
ACKs for top commit:
apoelstra:
ACK 01a48d1
Tree-SHA512: 5e951156498319c0559c5ba48da10810d3112f2372801d778b579e0ecf12bfe2c69d570c9837563d0de06272f4a8e76ae2d9a8afdc1f3a10733cbed96cc5e201
/// The (pseudo code) call: `verify(spent, 630482530, spending, 0)` should return `Ok(())`.
175
100
///
176
-
/// **Note** since the spent amount will only be checked for Segwit transactions and the above example is not segwit, `verify` will succeed with any amount.
101
+
/// **Note** since the spent amount will only be checked for Segwit transactions and the above
102
+
/// example is not segwit, `verify` will succeed with any amount.
177
103
pubfnverify(
178
104
spent_output:&[u8],
179
105
amount:u64,
@@ -194,7 +120,7 @@ pub fn verify_with_flags(
194
120
unsafe{
195
121
letmut error = Error::ERR_SCRIPT;
196
122
197
-
let ret = bitcoinconsensus_verify_script_with_amount(
123
+
let ret = ffi::bitcoinconsensus_verify_script_with_amount(
198
124
spent_output_script.as_ptr(),
199
125
spent_output_script.len()asc_uint,
200
126
amount,
@@ -212,6 +138,80 @@ pub fn verify_with_flags(
212
138
}
213
139
}
214
140
141
+
pubmod ffi {
142
+
usecrate::types::{c_int, c_uchar, c_uint};
143
+
usecrate::Error;
144
+
145
+
extern"C"{
146
+
/// Returns `libbitcoinconsensus` version.
147
+
pubfnbitcoinconsensus_version() -> c_int;
148
+
149
+
/// Verifies that the transaction input correctly spends the previous
150
+
/// output, considering any additional constraints specified by flags.
151
+
pubfnbitcoinconsensus_verify_script_with_amount(
152
+
script_pubkey:*constc_uchar,
153
+
script_pubkeylen:c_uint,
154
+
amount:u64,
155
+
tx_to:*constc_uchar,
156
+
tx_tolen:c_uint,
157
+
n_in:c_uint,
158
+
flags:c_uint,
159
+
err:*mutError,
160
+
) -> c_int;
161
+
}
162
+
}
163
+
164
+
/// Errors returned by [`libbitcoinconsensus`].
165
+
///
166
+
/// The error variant identifiers mimic those from `libbitcoinconsensus`.
0 commit comments