hasDefinedHashtype method

bool hasDefinedHashtype()

Returns true if the hashType is exactly equal to one of the standard options or combinations thereof. Translated from bitcoind's IsDefinedHashtypeSignature

Implementation

bool hasDefinedHashtype() {

    if (!(_nhashtype != null  && _nhashtype.isFinite && _nhashtype.floor() == _nhashtype && _nhashtype > 0)) {
        return false;
    }

    // accept with or without Signature.SIGHASH_ANYONECANPAY by ignoring the bit
    try {
        var temp = _nhashtype & 0x1F;
        if (temp < SighashType.SIGHASH_ALL.value || temp > SighashType.SIGHASH_SINGLE.value) {
            return false;
        }
    } catch (ex) {
        return false;
    }
    return true;
}