Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully encapsulate bitcoinconsensus #2278

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions bitcoin/src/consensus/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ pub fn verify_script_with_flags<F: Into<u32>>(
spending_tx: &[u8],
flags: F,
) -> Result<(), BitcoinconsensusError> {
Ok(bitcoinconsensus::verify_with_flags(
bitcoinconsensus::verify_with_flags(
script.as_bytes(),
amount.to_sat(),
spending_tx,
index,
flags.into(),
)?)
).map_err(BitcoinconsensusError)
}

/// Verifies that this transaction is able to spend its inputs.
Expand Down Expand Up @@ -198,10 +198,6 @@ impl std::error::Error for BitcoinconsensusError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
}

impl From<bitcoinconsensus::Error> for BitcoinconsensusError {
fn from(e: bitcoinconsensus::Error) -> Self { Self(e) }
}

/// An error during transaction validation.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
Expand Down
4 changes: 2 additions & 2 deletions bitcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ pub extern crate base64;
/// Encodes and decodes the Bech32 forrmat.
pub extern crate bech32;

#[cfg(feature = "bitcoinconsensus")]
/// Bitcoin's libbitcoinconsensus with Rust binding.
pub extern crate bitcoinconsensus;
#[cfg(feature = "bitcoinconsensus")]
extern crate bitcoinconsensus;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed at all now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought, but didn't check. (In Rust post-2018 non-pub extern crates are no-ops, I believe.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub are not no-ops (they are reexports) but non-pub are.


/// Rust implementation of cryptographic hash function algorithems.
pub extern crate hashes;
Expand Down