code: public static int calcSigHashValue(Transaction.SigHash mode, boolean anyoneCanPay) {
          Preconditions.checkArgument(SigHash.ALL == mode || SigHash.NONE == mode || SigHash.SINGLE == mode); // enforce compatibility since this code was made before the SigHash enum was updated
          int sighashFlags = mode.value;
          if (anyoneCanPay)
              sighashFlags |= Transaction.SigHash.ANYONECANPAY.value;
          return sighashFlags;
      }
docs: Calculates the byte used in the protocol to represent the combination of mode and anyoneCanPay.