Skip to content

Commit 6d8c385

Browse files
committed
Merge #63: Improve crate
ddd61f0 Remove unnecessary section from manifest (Tobin C. Harding) 7a4fbbf Improve the library level rustdoc (Tobin C. Harding) 1b464ae Improve rustdocs on error type (Tobin C. Harding) 2bbfc28 Only derive Debug for error type (Tobin C. Harding) 07f80cc Remove unnecessary cast (Tobin C. Harding) 4922750 rustfmt: Use fn_params_layout (Tobin C. Harding) 1faa8f0 rustfmt: Remove required_version (Tobin C. Harding) Pull request description: Go through rust-bitcoin/rust-bitcoin#1649 and attempt to verify that we have every t crossed and i dotted. With this PR I believe we could consider stabilising the `bitcoinconsensus` crate, am I wrong? Are there any considerations re the semver number we are using or the fact that we are wrapping 0.20.0 Bitcoin Core? ACKs for top commit: apoelstra: ACK ddd61f0 Tree-SHA512: 794c7bc2c06e8418470b8b591bfb2d48e059bd3599793ee150bdc96918504a0cd7702f6e87fa878ef63d2f10fd917fc38d3f57ed1a52a92af31767efe3fb9ecf
2 parents 89336db + ddd61f0 commit 6d8c385

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ exclude = ["/depend/bitcoin/.github/**", "/depend/bitcoin/.tx/**", "/depend/bitc
1313
build = "build.rs"
1414
edition = "2018"
1515

16-
[lib]
17-
name = "bitcoinconsensus"
18-
path = "src/lib.rs"
19-
2016
[features]
2117
default = ["std"]
2218
std = []

rustfmt.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ enum_discrim_align_threshold = 0
5050
match_arm_blocks = false # Default true
5151
match_arm_leading_pipes = "Never"
5252
force_multiline_blocks = false
53-
fn_args_layout = "Tall"
53+
fn_params_layout = "Tall"
5454
brace_style = "SameLineWhere"
5555
control_brace_style = "AlwaysSameLine"
5656
trailing_semicolon = true
@@ -68,7 +68,6 @@ use_field_init_shorthand = false
6868
force_explicit_abi = true
6969
condense_wildcard_suffixes = false
7070
color = "Auto"
71-
required_version = "1.5.1"
7271
unstable_features = false
7372
disable_all_formatting = false
7473
skip_children = false

src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@
44
//! This project builds the `libbitcoinconsensus` library from Bitcoin's C++
55
//! sources using Cargo and provides Rust bindings to its API.
66
//!
7+
//! Quoting from [`bitcoin/doc/shared-libraries.md`]:
8+
//!
9+
//! > The purpose of this library is to make the verification functionality that is critical to
10+
//! > Bitcoin's consensus available to other applications, e.g. to language bindings.
11+
//!
12+
//! And that is exactly what this library is, the Rust bindings to `bitcoinconsensus`.
13+
//!
14+
//! [`bitcoin/doc/shared-libraries`]: <https://github.com/bitcoin/bitcoin/blob/master/doc/shared-libraries.md>
715
816
mod types;
917

1018
use core::fmt;
1119

1220
use crate::types::*;
1321

14-
/// Errors returned by `libbitcoinconsensus` (see github.com/bitcoin/bitcoin/doc/shared-libraries.md).
22+
/// Errors returned by [`libbitcoinconsensus`].
23+
///
24+
/// The error variant identifiers mimic those from `libbitcoinconsensus`.
25+
///
26+
/// [`libbitcoinconsensus`]: <https://github.com/bitcoin/bitcoin/blob/master/doc/shared-libraries.md#errors>
1527
#[allow(non_camel_case_types)]
16-
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
28+
#[derive(Debug)]
1729
#[repr(C)]
1830
pub enum Error {
1931
/// Default value, passed to `libbitcoinconsensus` as a return parameter.
@@ -118,7 +130,7 @@ pub fn height_to_flags(height: u32) -> u32 {
118130
flag |= VERIFY_NULLDUMMY | VERIFY_WITNESS
119131
}
120132

121-
flag as u32
133+
flag
122134
}
123135

124136
/// Returns `libbitcoinconsensus` version.
@@ -185,7 +197,7 @@ pub fn verify_with_flags(
185197
let ret = bitcoinconsensus_verify_script_with_amount(
186198
spent_output_script.as_ptr(),
187199
spent_output_script.len() as c_uint,
188-
amount as u64,
200+
amount,
189201
spending_transaction.as_ptr(),
190202
spending_transaction.len() as c_uint,
191203
input_index as c_uint,

0 commit comments

Comments
 (0)