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,
|
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