Changeset View
Changeset View
Standalone View
Standalone View
src/script/sighashtype.h
Show All 20 Lines | |||||
/** | /** | ||||
* Base signature hash types | * Base signature hash types | ||||
* Base sig hash types not defined in this enum may be used, but they will be | * Base sig hash types not defined in this enum may be used, but they will be | ||||
* represented as UNSUPPORTED. See transaction | * represented as UNSUPPORTED. See transaction | ||||
* c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73 for an | * c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73 for an | ||||
* example where an unsupported base sig hash of 0 was used. | * example where an unsupported base sig hash of 0 was used. | ||||
*/ | */ | ||||
enum class BaseSigHashType : uint32_t { | enum class BaseSigHashType : uint8_t { | ||||
UNSUPPORTED = 0, | UNSUPPORTED = 0, | ||||
ALL = SIGHASH_ALL, | ALL = SIGHASH_ALL, | ||||
NONE = SIGHASH_NONE, | NONE = SIGHASH_NONE, | ||||
SINGLE = SIGHASH_SINGLE | SINGLE = SIGHASH_SINGLE | ||||
}; | }; | ||||
/** Signature hash type wrapper class */ | /** Signature hash type wrapper class */ | ||||
class SigHashType { | class SigHashType { | ||||
Show All 24 Lines | public: | ||||
} | } | ||||
BaseSigHashType getBaseType() const { | BaseSigHashType getBaseType() const { | ||||
return BaseSigHashType(sigHash & 0x1f); | return BaseSigHashType(sigHash & 0x1f); | ||||
} | } | ||||
uint32_t getForkValue() const { return sigHash >> 8; } | uint32_t getForkValue() const { return sigHash >> 8; } | ||||
bool hasSupportedBaseType() const { | bool isDefined() const { | ||||
BaseSigHashType baseType = getBaseType(); | auto baseType = | ||||
BaseSigHashType(sigHash & ~(SIGHASH_FORKID | SIGHASH_ANYONECANPAY)); | |||||
return baseType >= BaseSigHashType::ALL && | return baseType >= BaseSigHashType::ALL && | ||||
baseType <= BaseSigHashType::SINGLE; | baseType <= BaseSigHashType::SINGLE; | ||||
} | } | ||||
bool hasForkId() const { return (sigHash & SIGHASH_FORKID) != 0; } | bool hasForkId() const { return (sigHash & SIGHASH_FORKID) != 0; } | ||||
bool hasAnyoneCanPay() const { | bool hasAnyoneCanPay() const { | ||||
return (sigHash & SIGHASH_ANYONECANPAY) != 0; | return (sigHash & SIGHASH_ANYONECANPAY) != 0; | ||||
Show All 10 Lines |