Use boxed sliced instead of Vec in InvalidPreimageHashPair variant

This commit is contained in:
Riccardo Casatta 2020-11-18 10:48:29 +01:00
parent 781b0e014a
commit 0eaf45ca81
No known key found for this signature in database
GPG Key ID: FD986A969E450397
2 changed files with 4 additions and 4 deletions

View File

@ -68,9 +68,9 @@ pub enum Error {
/// Hash-type /// Hash-type
hash_type: PsbtHash, hash_type: PsbtHash,
/// Pre-image /// Pre-image
preimage: Vec<u8>, preimage: Box<[u8]>,
/// Hash value /// Hash value
hash: Vec<u8>, hash: Box<[u8]>,
}, },
/// Data inconsistency/conflicting data during merge procedure /// Data inconsistency/conflicting data during merge procedure
MergeConflict(String), MergeConflict(String),

View File

@ -311,8 +311,8 @@ where
let val: Vec<u8> = Deserialize::deserialize(&raw_value)?; let val: Vec<u8> = Deserialize::deserialize(&raw_value)?;
if <H as hashes::Hash>::hash(&val) != key_val { if <H as hashes::Hash>::hash(&val) != key_val {
return Err(psbt::Error::InvalidPreimageHashPair { return Err(psbt::Error::InvalidPreimageHashPair {
preimage: val, preimage: val.into_boxed_slice(),
hash: Vec::from(key_val.borrow()), hash: Box::from(key_val.borrow()),
hash_type: hash_type, hash_type: hash_type,
} }
.into()); .into());