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

Non-API breaking introduction of Schnorr keys #589

Merged
merged 3 commits into from Apr 29, 2021
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
2 changes: 1 addition & 1 deletion examples/bip32.rs
Expand Up @@ -4,7 +4,7 @@ use std::{env, process};
use std::str::FromStr;

use bitcoin::secp256k1::Secp256k1;
use bitcoin::util::key::PrivateKey;
use bitcoin::util::ecdsa::PrivateKey;
use bitcoin::util::bip32::ExtendedPrivKey;
use bitcoin::util::bip32::ExtendedPubKey;
use bitcoin::util::bip32::DerivationPath;
Expand Down
4 changes: 2 additions & 2 deletions src/blockdata/script.rs
Expand Up @@ -37,7 +37,7 @@ use hashes::{Hash, hex};
#[cfg(feature="bitcoinconsensus")] use std::convert;
#[cfg(feature="bitcoinconsensus")] use OutPoint;

use util::key::PublicKey;
use util::ecdsa::PublicKey;

#[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
/// A Bitcoin script
Expand Down Expand Up @@ -889,7 +889,7 @@ mod test {
use hashes::hex::{FromHex, ToHex};
use consensus::encode::{deserialize, serialize};
use blockdata::opcodes;
use util::key::PublicKey;
use util::ecdsa::PublicKey;
use util::psbt::serialize::Serialize;

#[test]
Expand Down
9 changes: 7 additions & 2 deletions src/lib.rs
Expand Up @@ -85,10 +85,15 @@ pub use util::address::AddressType;
pub use util::amount::Amount;
pub use util::amount::Denomination;
pub use util::amount::SignedAmount;
pub use util::key::PrivateKey;
pub use util::key::PublicKey;
pub use util::merkleblock::MerkleBlock;

pub use util::ecdsa;
pub use util::schnorr;
Comment on lines +90 to +91
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

This is a tiny step towards #525 where the util module was made private.

#[deprecated(since = "0.26.1", note = "Please use `ecdsa::PrivateKey` instead")]
pub use util::ecdsa::PrivateKey;
#[deprecated(since = "0.26.1", note = "Please use `ecdsa::PublicKey` instead")]
pub use util::ecdsa::PublicKey;

#[cfg(all(test, feature = "unstable"))] use tests::EmptyWrite;

#[cfg(all(test, feature = "unstable"))]
Expand Down
14 changes: 7 additions & 7 deletions src/util/address.rs
Expand Up @@ -21,13 +21,13 @@
//!
//! use bitcoin::network::constants::Network;
//! use bitcoin::util::address::Address;
//! use bitcoin::util::key;
//! use bitcoin::util::ecdsa;
//! use bitcoin::secp256k1::Secp256k1;
//! use bitcoin::secp256k1::rand::thread_rng;
//!
//! // Generate random key pair
//! let s = Secp256k1::new();
//! let public_key = key::PublicKey {
//! let public_key = ecdsa::PublicKey {
//! compressed: true,
//! key: s.generate_keypair(&mut thread_rng()).1,
//! };
Expand All @@ -46,7 +46,7 @@ use hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
use blockdata::script;
use network::constants::Network;
use util::base58;
use util::key;
use util::ecdsa;

/// Address error.
#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -220,7 +220,7 @@ impl Address {
/// Creates a pay to (compressed) public key hash address from a public key
/// This is the preferred non-witness type address
#[inline]
pub fn p2pkh(pk: &key::PublicKey, network: Network) -> Address {
pub fn p2pkh(pk: &ecdsa::PublicKey, network: Network) -> Address {
let mut hash_engine = PubkeyHash::engine();
pk.write_into(&mut hash_engine).expect("engines don't error");

Expand All @@ -244,7 +244,7 @@ impl Address {
/// This is the native segwit address type for an output redeemable with a single signature
///
/// Will only return an Error when an uncompressed public key is provided.
pub fn p2wpkh(pk: &key::PublicKey, network: Network) -> Result<Address, Error> {
pub fn p2wpkh(pk: &ecdsa::PublicKey, network: Network) -> Result<Address, Error> {
if !pk.compressed {
return Err(Error::UncompressedPubkey);
}
Expand All @@ -265,7 +265,7 @@ impl Address {
/// This is a segwit address type that looks familiar (as p2sh) to legacy clients
///
/// Will only return an Error when an uncompressed public key is provided.
pub fn p2shwpkh(pk: &key::PublicKey, network: Network) -> Result<Address, Error> {
pub fn p2shwpkh(pk: &ecdsa::PublicKey, network: Network) -> Result<Address, Error> {
if !pk.compressed {
return Err(Error::UncompressedPubkey);
}
Expand Down Expand Up @@ -500,7 +500,7 @@ mod tests {

use blockdata::script::Script;
use network::constants::Network::{Bitcoin, Testnet};
use util::key::PublicKey;
use util::ecdsa::PublicKey;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/util/bip143.rs
Expand Up @@ -274,7 +274,7 @@ mod tests {
use consensus::encode::deserialize;
use network::constants::Network;
use util::address::Address;
use util::key::PublicKey;
use util::ecdsa::PublicKey;
use hashes::hex::FromHex;

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions src/util/bip32.rs
Expand Up @@ -26,8 +26,8 @@ use hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine};
use secp256k1::{self, Secp256k1};

use network::constants::Network;
use util::{base58, endian};
use util::key::{self, PublicKey, PrivateKey};
use util::{base58, endian, key};
use util::ecdsa::{PublicKey, PrivateKey};

/// A chain code
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down