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

Use library to_hex function #573

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2401,14 +2401,13 @@ mod test {
}

#[test]
#[cfg(all(feature = "rand-std", feature = "bitcoin-hashes-std"))]
#[cfg(feature = "rand-std")]
fn test_keypair_from_str() {
use bitcoin_hashes::hex::ToHex;

let ctx = crate::Secp256k1::new();
let keypair = KeyPair::new(&ctx, &mut rand::thread_rng());
let msg = keypair.secret_key().secret_bytes().to_hex();
let parsed_key: KeyPair = msg.parse().unwrap();
let mut buf = [0_u8; constants::SECRET_KEY_SIZE * 2]; // Holds hex digits.
let s = to_hex(&keypair.secret_key().secret_bytes(), &mut buf).unwrap();
let parsed_key = KeyPair::from_str(s).unwrap();
assert_eq!(parsed_key, keypair);
}

Expand Down