Merge rust-bitcoin/rust-bitcoin#4063: Automated nightly rustfmt (2025-02-16)
0fbfe68c72
2025-02-16 automated rustfmt nightly (Fmt Bot) Pull request description: Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action ACKs for top commit: apoelstra: ACK 0fbfe68c72496c3135108914cdb2c2b45e496e99; successfully ran local tests tcharding: ACK0fbfe68c72
Tree-SHA512: 08ac71f7cf0259dcda0d7fd127ad8485e65edb06307a09ae03506f61fb917faf0c8c721b2299f15a370d6fc124cf35488f6410ddf15d522371660e6d97fd848b
This commit is contained in:
commit
15a385a5b2
|
@ -499,10 +499,10 @@ impl PrivateKey {
|
|||
33 => false,
|
||||
34 => {
|
||||
if data[33] != 1 {
|
||||
return Err(InvalidWifCompressionFlagError{ invalid: data[33] }.into());
|
||||
return Err(InvalidWifCompressionFlagError { invalid: data[33] }.into());
|
||||
}
|
||||
true
|
||||
},
|
||||
}
|
||||
length => {
|
||||
return Err(InvalidBase58PayloadLengthError { length }.into());
|
||||
}
|
||||
|
@ -987,8 +987,7 @@ impl fmt::Display for FromWifError {
|
|||
InvalidAddressVersion(ref 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),
|
||||
InvalidWifCompressionFlag(ref e) =>
|
||||
write_err!(f, "invalid WIF compression flag";e),
|
||||
InvalidWifCompressionFlag(ref 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
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct InvalidWifCompressionFlagError{
|
||||
pub struct InvalidWifCompressionFlagError {
|
||||
/// The invalid compression flag.
|
||||
pub(crate) invalid: u8,
|
||||
}
|
||||
|
@ -1206,9 +1205,13 @@ mod tests {
|
|||
#[test]
|
||||
fn key_derivation() {
|
||||
// mainnet compressed WIF with invalid compression flag.
|
||||
let sk =
|
||||
PrivateKey::from_wif("L2x4uC2YgfFWZm9tF4pjDnVR6nJkheizFhEr2KvDNnTEmEqVzPJY");
|
||||
assert!(matches!(sk, Err(FromWifError::InvalidWifCompressionFlag(InvalidWifCompressionFlagError { invalid: 49 }))));
|
||||
let sk = PrivateKey::from_wif("L2x4uC2YgfFWZm9tF4pjDnVR6nJkheizFhEr2KvDNnTEmEqVzPJY");
|
||||
assert!(matches!(
|
||||
sk,
|
||||
Err(FromWifError::InvalidWifCompressionFlag(InvalidWifCompressionFlagError {
|
||||
invalid: 49
|
||||
}))
|
||||
));
|
||||
|
||||
// testnet compressed
|
||||
let sk =
|
||||
|
|
|
@ -616,10 +616,7 @@ mod tests {
|
|||
witness: Witness::new(),
|
||||
};
|
||||
|
||||
let txout = TxOut {
|
||||
value: Amount::from_sat(123456789),
|
||||
script_pubkey: ScriptBuf::new(),
|
||||
};
|
||||
let txout = TxOut { value: Amount::from_sat(123456789), script_pubkey: ScriptBuf::new() };
|
||||
|
||||
let tx_orig = Transaction {
|
||||
version: Version::ONE,
|
||||
|
|
|
@ -603,7 +603,8 @@ mod test {
|
|||
let witness_elements = 2;
|
||||
let content = append_u32_vec(&elements, &[0, 2]);
|
||||
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(1).unwrap(), [21_u8, 22]);
|
||||
assert_eq!(witness.size(), 6);
|
||||
|
|
Loading…
Reference in New Issue