Merge rust-bitcoin/rust-bitcoin#2278: Fully encapsulate bitcoinconsensus

43b1ed1b86 Fully encapsulate bitcoinconsensus (Tobin C. Harding)

Pull request description:

  The `bitcoinconsensus` crate is not fully under our control because it exposes code from Core, so we cannot guarantee its stability across versions. To make our semver compliance easier we can fully encapsulate the `bitcoinconsensus` crate so it does not appear in our public API.

  ### Please note that with this applied:

  - The `bitcoinconsenus` crate is no longer exported at the crate root
  - No `bitcoinconsensus` types appear in our public API

ACKs for top commit:
  Kixunil:
    ACK 43b1ed1b86
  apoelstra:
    ACK 43b1ed1b86

Tree-SHA512: 9fc4f01a35396562e980a647784b22667cbd289e45b5c122610d23a1f8bcf0fe8b9c27e33745f14ee010050d4c2d2669b679fb39c7a108e4e86d2c14fd60571a
This commit is contained in:
Andrew Poelstra 2023-12-13 14:52:45 +00:00
commit 6b9f927f7f
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
2 changed files with 4 additions and 8 deletions

View File

@ -51,13 +51,13 @@ pub fn verify_script_with_flags<F: Into<u32>>(
spending_tx: &[u8], spending_tx: &[u8],
flags: F, flags: F,
) -> Result<(), BitcoinconsensusError> { ) -> Result<(), BitcoinconsensusError> {
Ok(bitcoinconsensus::verify_with_flags( bitcoinconsensus::verify_with_flags(
script.as_bytes(), script.as_bytes(),
amount.to_sat(), amount.to_sat(),
spending_tx, spending_tx,
index, index,
flags.into(), flags.into(),
)?) ).map_err(BitcoinconsensusError)
} }
/// Verifies that this transaction is able to spend its inputs. /// Verifies that this transaction is able to spend its inputs.
@ -198,10 +198,6 @@ impl std::error::Error for BitcoinconsensusError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } 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. /// An error during transaction validation.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] #[non_exhaustive]

View File

@ -59,9 +59,9 @@ pub extern crate base64;
/// Encodes and decodes the Bech32 forrmat. /// Encodes and decodes the Bech32 forrmat.
pub extern crate bech32; pub extern crate bech32;
#[cfg(feature = "bitcoinconsensus")]
/// Bitcoin's libbitcoinconsensus with Rust binding. /// Bitcoin's libbitcoinconsensus with Rust binding.
pub extern crate bitcoinconsensus; #[cfg(feature = "bitcoinconsensus")]
extern crate bitcoinconsensus;
/// Rust implementation of cryptographic hash function algorithems. /// Rust implementation of cryptographic hash function algorithems.
pub extern crate hashes; pub extern crate hashes;