Fail on error codes returned by chain SPV validation
Validate SPV returns error codes for chain headers validation failures.
Here we check for errors and revert the transaction if error occurred.
@@ -88,7 +88,11 @@ library DepositUtils {
}
uint256 _observedDiff = _bitcoinHeaders.validateHeaderChain();
- require(_observedDiff > 3, "ValidateSPV returned an error code");
+
+ require(_observedDiff != ValidateSPV.getErrBadLength(), "Invalid length of the headers chain");
+ require(_observedDiff != ValidateSPV.getErrInvalidChain(), "Invalid headers chain");
+ require(_observedDiff != ValidateSPV.getErrLowWork(), "Insufficient work in a header");
+
/* TODO: make this better than 6 */
require(
_observedDiff >= _reqDiff.mul(TBTCConstants.getTxProofDifficultyFactor()),
