Skip to content

Commit 92c4923

Browse files
committed
Merge #573: Use library to_hex function
bdfa0ff Use library to_hex function (Tobin C. Harding) Pull request description: 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. ACKs for top commit: apoelstra: ACK bdfa0ff Tree-SHA512: 0923939cfeb3cb4f8a3c2fad3961f2b17d3083d85232b3992d9efef59e622fa18f6ecf3c93b064518a7cb6ac4b704480a59ecdc3bcc016811758b4a13b00d31f
2 parents 0e689c7 + bdfa0ff commit 92c4923

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)