1919
2020class TxValidationState ;
2121
22+ namespace ProTxVersion {
23+ enum : uint16_t {
24+ LegacyBLS = 1 ,
25+ BasicBLS = 2 ,
26+ };
27+ } // namespace ProTxVersion
28+
2229class CProRegTx
2330{
2431public:
2532 static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_REGISTER;
26- static constexpr uint16_t LEGACY_BLS_VERSION = 1 ;
27- static constexpr uint16_t BASIC_BLS_VERSION = 2 ;
2833
2934 [[nodiscard]] static constexpr auto GetVersion (const bool is_basic_scheme_active) -> uint16_t
3035 {
31- return is_basic_scheme_active ? BASIC_BLS_VERSION : LEGACY_BLS_VERSION ;
36+ return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS ;
3237 }
3338
34- uint16_t nVersion{LEGACY_BLS_VERSION}; // message version
39+ uint16_t nVersion{ProTxVersion::LegacyBLS}; // message version
3540 MnType nType{MnType::Regular};
3641 uint16_t nMode{0 }; // only 0 supported for now
3742 COutPoint collateralOutpoint{uint256 (), (uint32_t )-1 }; // if hash is null, we refer to a ProRegTx output
@@ -52,7 +57,7 @@ class CProRegTx
5257 READWRITE (
5358 obj.nVersion
5459 );
55- if (obj.nVersion == 0 || obj.nVersion > BASIC_BLS_VERSION ) {
60+ if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS ) {
5661 // unknown version, bail out early
5762 return ;
5863 }
@@ -63,7 +68,7 @@ class CProRegTx
6368 obj.collateralOutpoint ,
6469 obj.addr ,
6570 obj.keyIDOwner ,
66- CBLSLazyPublicKeyVersionWrapper (const_cast <CBLSLazyPublicKey&>(obj.pubKeyOperator ), (obj.nVersion == LEGACY_BLS_VERSION )),
71+ CBLSLazyPublicKeyVersionWrapper (const_cast <CBLSLazyPublicKey&>(obj.pubKeyOperator ), (obj.nVersion == ProTxVersion::LegacyBLS )),
6772 obj.keyIDVoting ,
6873 obj.nOperatorReward ,
6974 obj.scriptPayout ,
@@ -119,15 +124,13 @@ class CProUpServTx
119124{
120125public:
121126 static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_SERVICE;
122- static constexpr uint16_t LEGACY_BLS_VERSION = 1 ;
123- static constexpr uint16_t BASIC_BLS_VERSION = 2 ;
124127
125128 [[nodiscard]] static constexpr auto GetVersion (const bool is_basic_scheme_active) -> uint16_t
126129 {
127- return is_basic_scheme_active ? BASIC_BLS_VERSION : LEGACY_BLS_VERSION ;
130+ return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS ;
128131 }
129132
130- uint16_t nVersion{LEGACY_BLS_VERSION }; // message version
133+ uint16_t nVersion{ProTxVersion::LegacyBLS }; // message version
131134 MnType nType{MnType::Regular};
132135 uint256 proTxHash;
133136 CService addr;
@@ -143,11 +146,11 @@ class CProUpServTx
143146 READWRITE (
144147 obj.nVersion
145148 );
146- if (obj.nVersion == 0 || obj.nVersion > BASIC_BLS_VERSION ) {
149+ if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS ) {
147150 // unknown version, bail out early
148151 return ;
149152 }
150- if (obj.nVersion == BASIC_BLS_VERSION ) {
153+ if (obj.nVersion >= ProTxVersion::BasicBLS ) {
151154 READWRITE (
152155 obj.nType );
153156 }
@@ -165,7 +168,7 @@ class CProUpServTx
165168 }
166169 if (!(s.GetType () & SER_GETHASH)) {
167170 READWRITE (
168- CBLSSignatureVersionWrapper (const_cast <CBLSSignature&>(obj.sig ), (obj.nVersion == LEGACY_BLS_VERSION ))
171+ CBLSSignatureVersionWrapper (const_cast <CBLSSignature&>(obj.sig ), (obj.nVersion == ProTxVersion::LegacyBLS ))
169172 );
170173 }
171174 }
@@ -199,15 +202,13 @@ class CProUpRegTx
199202{
200203public:
201204 static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_REGISTRAR;
202- static constexpr uint16_t LEGACY_BLS_VERSION = 1 ;
203- static constexpr uint16_t BASIC_BLS_VERSION = 2 ;
204205
205206 [[nodiscard]] static constexpr auto GetVersion (const bool is_basic_scheme_active) -> uint16_t
206207 {
207- return is_basic_scheme_active ? BASIC_BLS_VERSION : LEGACY_BLS_VERSION ;
208+ return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS ;
208209 }
209210
210- uint16_t nVersion{LEGACY_BLS_VERSION }; // message version
211+ uint16_t nVersion{ProTxVersion::LegacyBLS }; // message version
211212 uint256 proTxHash;
212213 uint16_t nMode{0 }; // only 0 supported for now
213214 CBLSLazyPublicKey pubKeyOperator;
@@ -221,14 +222,14 @@ class CProUpRegTx
221222 READWRITE (
222223 obj.nVersion
223224 );
224- if (obj.nVersion == 0 || obj.nVersion > BASIC_BLS_VERSION ) {
225+ if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS ) {
225226 // unknown version, bail out early
226227 return ;
227228 }
228229 READWRITE (
229230 obj.proTxHash ,
230231 obj.nMode ,
231- CBLSLazyPublicKeyVersionWrapper (const_cast <CBLSLazyPublicKey&>(obj.pubKeyOperator ), (obj.nVersion == LEGACY_BLS_VERSION )),
232+ CBLSLazyPublicKeyVersionWrapper (const_cast <CBLSLazyPublicKey&>(obj.pubKeyOperator ), (obj.nVersion == ProTxVersion::LegacyBLS )),
232233 obj.keyIDVoting ,
233234 obj.scriptPayout ,
234235 obj.inputsHash
@@ -264,12 +265,10 @@ class CProUpRevTx
264265{
265266public:
266267 static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_REVOKE;
267- static constexpr uint16_t LEGACY_BLS_VERSION = 1 ;
268- static constexpr uint16_t BASIC_BLS_VERSION = 2 ;
269268
270269 [[nodiscard]] static constexpr auto GetVersion (const bool is_basic_scheme_active) -> uint16_t
271270 {
272- return is_basic_scheme_active ? BASIC_BLS_VERSION : LEGACY_BLS_VERSION ;
271+ return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS ;
273272 }
274273
275274 // these are just informational and do not have any effect on the revocation
@@ -281,7 +280,7 @@ class CProUpRevTx
281280 REASON_LAST = REASON_CHANGE_OF_KEYS
282281 };
283282
284- uint16_t nVersion{LEGACY_BLS_VERSION }; // message version
283+ uint16_t nVersion{ProTxVersion::LegacyBLS }; // message version
285284 uint256 proTxHash;
286285 uint16_t nReason{REASON_NOT_SPECIFIED};
287286 uint256 inputsHash; // replay protection
@@ -292,7 +291,7 @@ class CProUpRevTx
292291 READWRITE (
293292 obj.nVersion
294293 );
295- if (obj.nVersion == 0 || obj.nVersion > BASIC_BLS_VERSION ) {
294+ if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS ) {
296295 // unknown version, bail out early
297296 return ;
298297 }
@@ -303,7 +302,7 @@ class CProUpRevTx
303302 );
304303 if (!(s.GetType () & SER_GETHASH)) {
305304 READWRITE (
306- CBLSSignatureVersionWrapper (const_cast <CBLSSignature&>(obj.sig ), (obj.nVersion == LEGACY_BLS_VERSION ))
305+ CBLSSignatureVersionWrapper (const_cast <CBLSSignature&>(obj.sig ), (obj.nVersion == ProTxVersion::LegacyBLS ))
307306 );
308307 }
309308 }
0 commit comments