Add rand-std feature
Currently we enable "secp256k1/rand-std" in the "rand" feature, this is incorrect because it means "rand" implies "std" which it does not. Add a "rand-std" feature that turns on "seck256k1/rand-std" and make the "rand" feature turn on "seck256k1/rand".
This commit is contained in:
parent
7fee6239e1
commit
f71335f971
|
@ -15,7 +15,8 @@ edition = "2018"
|
|||
# Please don't forget to add relevant features to docs.rs below
|
||||
[features]
|
||||
default = [ "std", "secp-recovery" ]
|
||||
rand = ["secp256k1/rand-std"]
|
||||
rand-std = ["secp256k1/rand-std"]
|
||||
rand = ["secp256k1/rand"]
|
||||
serde = ["actual-serde", "bitcoin_hashes/serde", "secp256k1/serde"]
|
||||
secp-lowmemory = ["secp256k1/lowmemory"]
|
||||
secp-recovery = ["secp256k1/recovery"]
|
||||
|
|
|
@ -8,24 +8,23 @@
|
|||
//! # Example: creating a new address from a randomly-generated key pair
|
||||
//!
|
||||
//! ```rust
|
||||
//! use bitcoin::network::constants::Network;
|
||||
//! use bitcoin::address::Address;
|
||||
//! use bitcoin::PublicKey;
|
||||
//! use bitcoin::secp256k1::Secp256k1;
|
||||
//! use bitcoin::secp256k1::rand::thread_rng;
|
||||
//! # #[cfg(feature = "rand-std")] {
|
||||
//! use bitcoin::{Address, PublicKey, Network};
|
||||
//! use bitcoin::secp256k1::{rand, Secp256k1};
|
||||
//!
|
||||
//! // Generate random key pair.
|
||||
//! let s = Secp256k1::new();
|
||||
//! let public_key = PublicKey::new(s.generate_keypair(&mut thread_rng()).1);
|
||||
//! let public_key = PublicKey::new(s.generate_keypair(&mut rand::thread_rng()).1);
|
||||
//!
|
||||
//! // Generate pay-to-pubkey-hash address.
|
||||
//! let address = Address::p2pkh(&public_key, Network::Bitcoin);
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! # Note: creating a new address requires the rand feature flag
|
||||
//! # Note: creating a new address requires the rand-std feature flag
|
||||
//!
|
||||
//! ```toml
|
||||
//! bitcoin = { version = "...", features = ["rand"] }
|
||||
//! bitcoin = { version = "...", features = ["rand-std"] }
|
||||
//! ```
|
||||
|
||||
use core::convert::TryFrom;
|
||||
|
|
|
@ -887,7 +887,7 @@ mod tests {
|
|||
use crate::hash_types::Txid;
|
||||
|
||||
use secp256k1::{Secp256k1, self};
|
||||
#[cfg(feature = "rand")]
|
||||
#[cfg(feature = "rand-std")]
|
||||
use secp256k1::{All, SecretKey};
|
||||
|
||||
use crate::blockdata::script::ScriptBuf;
|
||||
|
@ -1685,7 +1685,7 @@ mod tests {
|
|||
assert_eq!(psbt1, psbt2);
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
#[cfg(feature = "rand-std")]
|
||||
fn gen_keys() -> (PrivateKey, PublicKey, Secp256k1<All>) {
|
||||
use secp256k1::rand::thread_rng;
|
||||
|
||||
|
@ -1699,7 +1699,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "rand")]
|
||||
#[cfg(feature = "rand-std")]
|
||||
fn get_key_btree_map() {
|
||||
let (priv_key, pk, secp) = gen_keys();
|
||||
|
||||
|
@ -1811,7 +1811,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "rand")]
|
||||
#[cfg(feature = "rand-std")]
|
||||
fn sign_psbt() {
|
||||
use crate::WPubkeyHash;
|
||||
use crate::bip32::{Fingerprint, DerivationPath};
|
||||
|
|
Loading…
Reference in New Issue