pub fn is_valid_fingerprint(s: &str) -> boolExpand description
Validates a relay fingerprint string.
A valid fingerprint consists of exactly 40 hexadecimal characters (case-insensitive), representing a 160-bit SHA-1 hash of the relay’s identity key.
§Arguments
s- The string to validate
§Returns
true if the string is a valid fingerprint, false otherwise.
§Format
- Length: exactly 40 characters
- Characters: hexadecimal digits (0-9, a-f, A-F)
§Example
use stem_rs::util::is_valid_fingerprint;
// Valid fingerprints (case-insensitive)
assert!(is_valid_fingerprint("9695DFC35FFEB861329B9F1AB04C46397020CE31"));
assert!(is_valid_fingerprint("9695dfc35ffeb861329b9f1ab04c46397020ce31"));
// Invalid fingerprints
assert!(!is_valid_fingerprint("9695DFC35FFEB861329B9F1AB04C4639702")); // Too short
assert!(!is_valid_fingerprint("ZZZZDFC35FFEB861329B9F1AB04C46397020CE31")); // Invalid chars§This Compiles But Is Wrong
use stem_rs::util::is_valid_fingerprint;
// Don't include the "$" prefix - that's for fingerprint references
let with_prefix = "$9695DFC35FFEB861329B9F1AB04C46397020CE31";
assert!(!is_valid_fingerprint(with_prefix)); // Returns false!
// Use is_valid_fingerprint_with_prefix for prefixed fingerprints
use stem_rs::util::is_valid_fingerprint_with_prefix;
assert!(is_valid_fingerprint_with_prefix(with_prefix));