diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 041c64fc6..f77ee71e3 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -61,8 +61,8 @@ uint64_t ASSETCHAINS_COMMISSION; int64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0; uint64_t ASSETCHAINS_TIMEUNLOCKTO = 0; -uint8_t OPRETTYPE_COINBASETIMELOCK = 1; -uint8_t OPRETTYPE_REDEEMSCRIPT = 2; +#define OPRETTYPE_COINBASETIMELOCK = 1; +#define OPRETTYPE_REDEEMSCRIPT = 2; uint32_t ASSETCHAINS_ERAS = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; diff --git a/src/main.cpp b/src/main.cpp index 72b3f20f8..3ae4c65ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -918,9 +918,9 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh if (tx.vout.size() != 2 || tx.vout[1].scriptPubKey.size() < 4 || // minimum for any possible future to prevent out of bounds tx.vout[1].scriptPubKey.data()[0] != SCRIPT_OP_RETURN || - tx.vout[0].scriptPubKey.size() < 22 || + tx.vout[0].scriptPubKey.size() != 22 || *(uint8_t *)(tx.vout[0].scriptPubKey.data()) != 20 || - *(uint8_t *)((tx.vout[0].scriptPubKey.data()) + 21) != SCRIPT_OP_EQUAL) + ((uint8_t *)(tx.vout[0].scriptPubKey.data()))[21] != SCRIPT_OP_EQUAL) i = 0; else { @@ -937,8 +937,9 @@ bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeigh } else if (tx.vout[1].scriptPubKey.data()[2] == OPRETTYPE_REDEEMSCRIPT && i >= 23 && i < sizeof(script)) { - i -= 1; - memcpy(script, (uint8_t *)tx.vout[1].scriptPubKey.data()+3, i); + memcpy(script, ((uint8_t *)tx.vout[1].scriptPubKey.data())[i < SCRIPT_OP_PUSH1 ? 3 : i > SCRIPT_OP_PUSH1 ? 5 : 4]), i - 1); + // decrement after the prior call in case of optimization side effects + i--; calc_rmd160_sha256(scriptHash, script, i); } else