Skip to content

Commit bdfa0ff

Browse files
committed
Use library to_hex function
We do not need to use the `hex` module from `bitcoin_hashes` to encode into hex, we have a function in this library. Use library hex encoding logic, removes dependency on the `hex` module of `bitcoin_hashes` entirely from this crate.
1 parent 0e689c7 commit bdfa0ff

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/key.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2401,14 +2401,13 @@ mod test {
24012401
}
24022402

24032403
#[test]
2404-
#[cfg(all(feature = "rand-std", feature = "bitcoin-hashes-std"))]
2404+
#[cfg(feature = "rand-std")]
24052405
fn test_keypair_from_str() {
2406-
use bitcoin_hashes::hex::ToHex;
2407-
24082406
let ctx = crate::Secp256k1::new();
24092407
let keypair = KeyPair::new(&ctx, &mut rand::thread_rng());
2410-
let msg = keypair.secret_key().secret_bytes().to_hex();
2411-
let parsed_key: KeyPair = msg.parse().unwrap();
2408+
let mut buf = [0_u8; constants::SECRET_KEY_SIZE * 2]; // Holds hex digits.
2409+
let s = to_hex(&keypair.secret_key().secret_bytes(), &mut buf).unwrap();
2410+
let parsed_key = KeyPair::from_str(s).unwrap();
24122411
assert_eq!(parsed_key, keypair);
24132412
}
24142413

0 commit comments

Comments
 (0)