2025-02-16 automated rustfmt nightly
This commit is contained in:
parent
3fb5275e16
commit
0fbfe68c72
|
@ -499,10 +499,10 @@ impl PrivateKey {
|
||||||
33 => false,
|
33 => false,
|
||||||
34 => {
|
34 => {
|
||||||
if data[33] != 1 {
|
if data[33] != 1 {
|
||||||
return Err(InvalidWifCompressionFlagError{ invalid: data[33] }.into());
|
return Err(InvalidWifCompressionFlagError { invalid: data[33] }.into());
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
},
|
}
|
||||||
length => {
|
length => {
|
||||||
return Err(InvalidBase58PayloadLengthError { length }.into());
|
return Err(InvalidBase58PayloadLengthError { length }.into());
|
||||||
}
|
}
|
||||||
|
@ -987,8 +987,7 @@ impl fmt::Display for FromWifError {
|
||||||
InvalidAddressVersion(ref e) =>
|
InvalidAddressVersion(ref e) =>
|
||||||
write_err!(f, "decoded base58 data contained an invalid address version btye"; e),
|
write_err!(f, "decoded base58 data contained an invalid address version btye"; e),
|
||||||
Secp256k1(ref e) => write_err!(f, "private key validation failed"; e),
|
Secp256k1(ref e) => write_err!(f, "private key validation failed"; e),
|
||||||
InvalidWifCompressionFlag(ref e) =>
|
InvalidWifCompressionFlag(ref e) => write_err!(f, "invalid WIF compression flag";e),
|
||||||
write_err!(f, "invalid WIF compression flag";e),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1179,7 +1178,7 @@ impl std::error::Error for InvalidAddressVersionError {}
|
||||||
|
|
||||||
/// Invalid compression flag for a WIF key
|
/// Invalid compression flag for a WIF key
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct InvalidWifCompressionFlagError{
|
pub struct InvalidWifCompressionFlagError {
|
||||||
/// The invalid compression flag.
|
/// The invalid compression flag.
|
||||||
pub(crate) invalid: u8,
|
pub(crate) invalid: u8,
|
||||||
}
|
}
|
||||||
|
@ -1206,9 +1205,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn key_derivation() {
|
fn key_derivation() {
|
||||||
// mainnet compressed WIF with invalid compression flag.
|
// mainnet compressed WIF with invalid compression flag.
|
||||||
let sk =
|
let sk = PrivateKey::from_wif("L2x4uC2YgfFWZm9tF4pjDnVR6nJkheizFhEr2KvDNnTEmEqVzPJY");
|
||||||
PrivateKey::from_wif("L2x4uC2YgfFWZm9tF4pjDnVR6nJkheizFhEr2KvDNnTEmEqVzPJY");
|
assert!(matches!(
|
||||||
assert!(matches!(sk, Err(FromWifError::InvalidWifCompressionFlag(InvalidWifCompressionFlagError { invalid: 49 }))));
|
sk,
|
||||||
|
Err(FromWifError::InvalidWifCompressionFlag(InvalidWifCompressionFlagError {
|
||||||
|
invalid: 49
|
||||||
|
}))
|
||||||
|
));
|
||||||
|
|
||||||
// testnet compressed
|
// testnet compressed
|
||||||
let sk =
|
let sk =
|
||||||
|
|
|
@ -616,10 +616,7 @@ mod tests {
|
||||||
witness: Witness::new(),
|
witness: Witness::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let txout = TxOut {
|
let txout = TxOut { value: Amount::from_sat(123456789), script_pubkey: ScriptBuf::new() };
|
||||||
value: Amount::from_sat(123456789),
|
|
||||||
script_pubkey: ScriptBuf::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let tx_orig = Transaction {
|
let tx_orig = Transaction {
|
||||||
version: Version::ONE,
|
version: Version::ONE,
|
||||||
|
|
|
@ -603,7 +603,8 @@ mod test {
|
||||||
let witness_elements = 2;
|
let witness_elements = 2;
|
||||||
let content = append_u32_vec(&elements, &[0, 2]);
|
let content = append_u32_vec(&elements, &[0, 2]);
|
||||||
let indices_start = elements.len();
|
let indices_start = elements.len();
|
||||||
let witness = Witness::from_parts__unstable(content.clone(), witness_elements, indices_start);
|
let witness =
|
||||||
|
Witness::from_parts__unstable(content.clone(), witness_elements, indices_start);
|
||||||
assert_eq!(witness.nth(0).unwrap(), [11_u8]);
|
assert_eq!(witness.nth(0).unwrap(), [11_u8]);
|
||||||
assert_eq!(witness.nth(1).unwrap(), [21_u8, 22]);
|
assert_eq!(witness.nth(1).unwrap(), [21_u8, 22]);
|
||||||
assert_eq!(witness.size(), 6);
|
assert_eq!(witness.size(), 6);
|
||||||
|
|
Loading…
Reference in New Issue