Fix bug in PSBT `Deserialize` for `XOnlyPublicKey`
During upgrade of `secp256k1` a number of function calls needed to be rewritten to not use `from_slice` but `from_byte_array`. Unfortunately, the conversion wasn't correct and caused panics on invalid inputs rather than errors. This fixes it simply by calling `try_into` on the entire slice and converting the error.
This commit is contained in:
parent
8efacd4dda
commit
bbe87eccf2
|
@ -261,7 +261,7 @@ impl Serialize for XOnlyPublicKey {
|
||||||
impl Deserialize for XOnlyPublicKey {
|
impl Deserialize for XOnlyPublicKey {
|
||||||
fn deserialize(bytes: &[u8]) -> Result<Self, Error> {
|
fn deserialize(bytes: &[u8]) -> Result<Self, Error> {
|
||||||
XOnlyPublicKey::from_byte_array(
|
XOnlyPublicKey::from_byte_array(
|
||||||
bytes[..32].try_into().expect("statistically impossible to hit"),
|
bytes.try_into().map_err(|_| Error::InvalidXOnlyPublicKey)?,
|
||||||
)
|
)
|
||||||
.map_err(|_| Error::InvalidXOnlyPublicKey)
|
.map_err(|_| Error::InvalidXOnlyPublicKey)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue