message: [script] simplify CheckMinimalPush checks, add safety assert
  * simplify CheckMinimalPush checks, add safety assert
  * CheckMinimalPush comments are prescriptive
  * Use DbgAssert in CheckMinimalDataPush
  As is BU code convention
diff: #include "pubkey.h"
  #include "script/script.h"
  #include "uint256.h"
  +#include "util.h"
  const std::string strMessageMagic = "Bitcoin Signed Message:\n";
  extern uint256 SignatureHashLegacy(const CScript &scriptCode,
  @@ -496,34 +497,36 @@ bool CheckPubKeyEncoding(const valtype &vchPubKey, unsigned int flags, ScriptErr
  bool static CheckMinimalPush(const valtype &data, opcodetype opcode)
  {
  + // Excludes OP_1NEGATE, OP_1-16 since they are by definition minimal
  + DbgAssert(0 <= opcode && opcode <= OP_PUSHDATA4, return true);
  if (data.size() == 0)
  {
  - // Could have used OP_0.
  + // Should have used OP_0.
  return opcode == OP_0;
  }
  else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16)
  {
  - // Could have used OP_1 .. OP_16.
  - return opcode == OP_1 + (data[0] - 1);
  + // Should have used OP_1 .. OP_16.
  + return false;
  }
  else if (data.size() == 1 && data[0] == 0x81)
  {
  - // Could have used OP_1NEGATE.
  - return opcode == OP_1NEGATE;
  + // Should have used OP_1NEGATE.
  + return false;
  }
  else if (data.size() <= 75)
  {
  - // Could have used a direct push (opcode indicating number of bytes pushed + those bytes).
  + // Must have used a direct push (opcode indicating number of bytes pushed + those bytes).
  return opcode == data.size();
  }
  else if (data.size() <= 255)
  {
  - // Could have used OP_PUSHDATA.
  + // Must have used OP_PUSHDATA.
  return opcode == OP_PUSHDATA1;
  }
  else if (data.size() <= 65535)
  {
  - // Could have used OP_PUSHDATA2.
  + // Must have used OP_PUSHDATA2.
  return opcode == OP_PUSHDATA2;
  }
  return true;
  