@@ -988,10 +988,10 @@ bool isBlockBetweenFakeSerialAttackRange(int nHeight)
988988 return nHeight <= Params ().Zerocoin_Block_EndFakeSerial ();
989989}
990990
991- bool CheckPublicCoinSpendEnforced (int blockHeight, bool isPrivZerocoinSpend, bool isPublicSpend) {
991+ bool CheckPublicCoinSpendEnforced (int blockHeight, bool isPublicSpend) {
992992 if (blockHeight >= Params ().Zerocoin_Block_Public_Spend_Enabled ()) {
993993 // reject old coin spend
994- if (isPrivZerocoinSpend ) {
994+ if (!isPublicSpend ) {
995995 return error (" %s: failed to add block with older zc spend version" , __func__);
996996 }
997997
@@ -1042,11 +1042,14 @@ bool ContextualCheckZerocoinSpendNoSerialCheck(const CTransaction& tx, const Coi
10421042 }
10431043 }
10441044
1045- // Reject V1 old serials.
1046- if (spend->getVersion () < libzerocoin::PrivateCoin::PUBKEY_VERSION) {
1047- return error (" %s : zPIV v1 serial spend not spendable\n " , __func__,
1048- spend->getCoinSerialNumber ().GetHex (), tx.GetHash ().GetHex ());
1045+ if (pindex->nHeight >= Params ().Zerocoin_Block_Public_Spend_Enabled ()) {
1046+ // Reject V1 old serials.
1047+ if (spend->getVersion () < libzerocoin::PrivateCoin::PUBKEY_VERSION) {
1048+ return error (" %s : zPIV v1 serial spend not spendable, serial %s, tx %s\n " , __func__,
1049+ spend->getCoinSerialNumber ().GetHex (), tx.GetHash ().GetHex ());
1050+ }
10491051 }
1052+
10501053 // Reject serial's that are not in the acceptable value range
10511054 if (!spend->HasValidSerial (Params ().Zerocoin_Params (false ))) {
10521055 // Up until this block our chain was not checking serials correctly..
@@ -1416,7 +1419,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa
14161419 }
14171420
14181421 // Check enforcement
1419- if (!CheckPublicCoinSpendEnforced (chainActive.Height (), isPrivZerocoinSpend, isPublicSpend)){
1422+ if (!CheckPublicCoinSpendEnforced (chainActive.Height (), isPublicSpend)){
14201423 return state.Invalid (error (" %s: AcceptToMemoryPool failed for tx %s" , __func__,
14211424 tx.GetHash ().GetHex ()), REJECT_INVALID, " bad-txns-invalid-zpiv" );
14221425 }
@@ -3250,7 +3253,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
32503253 continue ;
32513254
32523255 // Check enforcement
3253- if (!CheckPublicCoinSpendEnforced (pindex->nHeight , isPrivZerocoinSpend, isPublicSpend)){
3256+ if (!CheckPublicCoinSpendEnforced (pindex->nHeight , isPublicSpend)){
32543257 return false ;
32553258 }
32563259
@@ -4811,7 +4814,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
48114814 if (isPrivZerocoinSpend || isPublicSpend) {
48124815
48134816 // Check enforcement
4814- if (!CheckPublicCoinSpendEnforced (pindex->nHeight , isPrivZerocoinSpend, isPublicSpend)){
4817+ if (!CheckPublicCoinSpendEnforced (pindex->nHeight , isPublicSpend)){
48154818 return false ;
48164819 }
48174820
0 commit comments