Make `ScriptHash` & `WScriptHash` obey sanity rule
These were re-implementing hashing after the check rather than calling the `_unchecked` method, so this replaces the manual implementation with the method.
This commit is contained in:
parent
9ec9adc71d
commit
ce55dd5b70
|
@ -69,7 +69,8 @@ impl ScriptHash {
|
|||
return Err(RedeemScriptSizeError { size: redeem_script.len() });
|
||||
}
|
||||
|
||||
Ok(ScriptHash(hash160::Hash::hash(redeem_script.as_bytes())))
|
||||
// We've just checked the length
|
||||
Ok(ScriptHash::from_script_unchecked(redeem_script))
|
||||
}
|
||||
|
||||
/// Constructs a new `ScriptHash` from any script irrespective of script size.
|
||||
|
@ -99,7 +100,8 @@ impl WScriptHash {
|
|||
return Err(WitnessScriptSizeError { size: witness_script.len() });
|
||||
}
|
||||
|
||||
Ok(WScriptHash(sha256::Hash::hash(witness_script.as_bytes())))
|
||||
// We've just checked the length
|
||||
Ok(WScriptHash::from_script_unchecked(witness_script))
|
||||
}
|
||||
|
||||
/// Constructs a new `WScriptHash` from any script irrespective of script size.
|
||||
|
|
Loading…
Reference in New Issue