Skip to content

Commit 0e98dd2

Browse files
fix: start error strings with lowercase in descriptors::key module
1 parent a5c1785 commit 0e98dd2

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/descriptor/key.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -354,20 +354,20 @@ impl fmt::Display for MalformedKeyDataKind {
354354
use MalformedKeyDataKind::*;
355355

356356
let err = match self {
357-
EmptyKey => "Empty key",
358-
EncounteredUnprintableCharacter => "Encountered an unprintable character",
359-
InvalidFullPublicKeyPrefix => "Only full public keys with prefixes '02', '03' or '04' are allowed",
360-
InvalidMasterFingerprintLength => "Master fingerprint should be 8 characters long",
361-
InvalidMultiIndexStep => "Invalid multi index step in multipath descriptor",
362-
InvalidMultiXKeyDerivation => "Can't make a multi-xpriv with hardened derivation steps that are not shared among all paths into a public key",
363-
InvalidPublicKeyLength => "Public keys must be 64, 66 or 130 characters in size",
357+
EmptyKey => "empty key",
358+
EncounteredUnprintableCharacter => "encountered an unprintable character",
359+
InvalidFullPublicKeyPrefix => "only full public keys with prefixes '02', '03' or '04' are allowed",
360+
InvalidMasterFingerprintLength => "master fingerprint should be 8 characters long",
361+
InvalidMultiIndexStep => "invalid multi index step in multipath descriptor",
362+
InvalidMultiXKeyDerivation => "can't make a multi-xpriv with hardened derivation steps that are not shared among all paths into a public key",
363+
InvalidPublicKeyLength => "public keys must be 64, 66 or 130 characters in size",
364364
InvalidWildcardInDerivationPath => "'*' may only appear as last element in a derivation path",
365-
KeyTooShort => "Key too short",
366-
MultipleFingerprintsInPublicKey => "Multiple ']' in Descriptor Public Key",
365+
KeyTooShort => "key too short",
366+
MultipleFingerprintsInPublicKey => "multiple ']' in Descriptor Public Key",
367367
MultipleDerivationPathIndexSteps => "'<' may only appear once in a derivation path",
368-
NoKeyAfterOrigin => "No key after origin",
369-
NoMasterFingerprintFound => "No master fingerprint found after '['",
370-
UnclosedSquareBracket => "Unclosed '['",
368+
NoKeyAfterOrigin => "no key after origin",
369+
NoMasterFingerprintFound => "no master fingerprint found after '['",
370+
UnclosedSquareBracket => "unclosed '['",
371371
WildcardAsDerivedDescriptorKey => "cannot parse key with a wilcard as a DerivedDescriptorKey",
372372
};
373373

@@ -415,34 +415,34 @@ impl fmt::Display for DescriptorKeyParseError {
415415
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
416416
match self {
417417
DescriptorKeyParseError::Bip32Xpriv(err) => {
418-
write!(f, "Error while parsing BIP32 Xpriv: {err}")
418+
write!(f, "error while parsing BIP32 Xpriv: {err}")
419419
}
420420
DescriptorKeyParseError::Bip32Xpub(err) => {
421-
write!(f, "Error while parsing BIP32 Xpub: {err}")
421+
write!(f, "error while parsing BIP32 Xpub: {err}")
422422
}
423423
DescriptorKeyParseError::DerivationIndexError { index, err } => {
424-
write!(f, "Error while parsing derivation index '{index}': {err}")
424+
write!(f, "error while parsing derivation index '{index}': {err}")
425425
}
426426
DescriptorKeyParseError::DeriveHardenedKey(err) => {
427-
write!(f, "Unable to derive the hardened steps: {err}")
427+
write!(f, "unable to derive the hardened steps: {err}")
428428
}
429429
DescriptorKeyParseError::MalformedKeyData(err) => {
430430
write!(f, "{err}")
431431
}
432432
DescriptorKeyParseError::MasterDerivationPath(err) => {
433-
write!(f, "Error while parsing master derivation path: {err}")
433+
write!(f, "error while parsing master derivation path: {err}")
434434
}
435435
DescriptorKeyParseError::MasterFingerprint { fingerprint, err } => {
436-
write!(f, "Error while parsing master fingerprint '{fingerprint}': {err}")
436+
write!(f, "error while parsing master fingerprint '{fingerprint}': {err}")
437437
}
438438
DescriptorKeyParseError::FullPublicKey(err) => {
439-
write!(f, "Error while parsing full public key: {err}")
439+
write!(f, "error while parsing full public key: {err}")
440440
}
441441
DescriptorKeyParseError::WifPrivateKey(err) => {
442-
write!(f, "Error while parsing WIF private key: {err}")
442+
write!(f, "error while parsing WIF private key: {err}")
443443
}
444444
DescriptorKeyParseError::XonlyPublicKey(err) => {
445-
write!(f, "Error while parsing xonly public key: {err}")
445+
write!(f, "error while parsing xonly public key: {err}")
446446
}
447447
}
448448
}
@@ -1387,42 +1387,42 @@ mod test {
13871387
let desc = "[NonHexor]xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*";
13881388
assert_eq!(
13891389
DescriptorPublicKey::from_str(desc).unwrap_err().to_string(),
1390-
"Error while parsing master fingerprint 'NonHexor': failed to parse hex digit"
1390+
"error while parsing master fingerprint 'NonHexor': failed to parse hex digit"
13911391
);
13921392

13931393
// And ones with invalid xpubs..
13941394
let desc = "[78412e3a]xpub1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaLcgJvLJuZZvRcEL/1/*";
13951395
assert_eq!(
13961396
DescriptorPublicKey::from_str(desc).unwrap_err().to_string(),
1397-
"Error while parsing BIP32 Xpub: base58 encoding error"
1397+
"error while parsing BIP32 Xpub: base58 encoding error"
13981398
);
13991399

14001400
// ..or invalid raw keys
14011401
let desc = "[78412e3a]0208a117f3897c3a13c9384b8695eed98dc31bc2500feb19a1af424cd47a5d83/1/*";
14021402
assert_eq!(
14031403
DescriptorPublicKey::from_str(desc).unwrap_err().to_string(),
1404-
"Public keys must be 64, 66 or 130 characters in size",
1404+
"public keys must be 64, 66 or 130 characters in size",
14051405
);
14061406

14071407
// ..or invalid separators
14081408
let desc = "[78412e3a]]03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8";
14091409
assert_eq!(
14101410
DescriptorPublicKey::from_str(desc).unwrap_err().to_string(),
1411-
"Multiple \']\' in Descriptor Public Key"
1411+
"multiple \']\' in Descriptor Public Key"
14121412
);
14131413

14141414
// fuzzer errors
14151415
let desc = "[11111f11]033333333333333333333333333333323333333333333333333333333433333333]]333]]3]]101333333333333433333]]]10]333333mmmm";
14161416
assert_eq!(
14171417
DescriptorPublicKey::from_str(desc).unwrap_err().to_string(),
1418-
"Multiple \']\' in Descriptor Public Key"
1418+
"multiple \']\' in Descriptor Public Key"
14191419
);
14201420

14211421
// fuzz failure, hybrid keys
14221422
let desc = "0777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777";
14231423
assert_eq!(
14241424
DescriptorPublicKey::from_str(desc).unwrap_err().to_string(),
1425-
"Only full public keys with prefixes '02', '03' or '04' are allowed"
1425+
"only full public keys with prefixes '02', '03' or '04' are allowed"
14261426
);
14271427
}
14281428

@@ -1434,21 +1434,21 @@ mod test {
14341434
DescriptorSecretKey::from_str(secret_key)
14351435
.unwrap_err()
14361436
.to_string(),
1437-
"Error while parsing BIP32 Xpriv: unknown version magic bytes: [4, 136, 178, 30]"
1437+
"error while parsing BIP32 Xpriv: unknown version magic bytes: [4, 136, 178, 30]"
14381438
);
14391439

14401440
// And ones with invalid fingerprints
14411441
let desc = "[NonHexor]tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/1/*";
14421442
assert_eq!(
14431443
DescriptorSecretKey::from_str(desc).unwrap_err().to_string(),
1444-
"Error while parsing master fingerprint 'NonHexor': failed to parse hex digit"
1444+
"error while parsing master fingerprint 'NonHexor': failed to parse hex digit"
14451445
);
14461446

14471447
// ..or invalid raw keys
14481448
let desc = "[78412e3a]L32jTfVLei6BYTPUpwpJSkrHx8iL9GZzeErVS8y4Y/1/*";
14491449
assert_eq!(
14501450
DescriptorSecretKey::from_str(desc).unwrap_err().to_string(),
1451-
"Error while parsing WIF private key: invalid base58"
1451+
"error while parsing WIF private key: invalid base58"
14521452
);
14531453
}
14541454

0 commit comments

Comments
 (0)