Confidential informants are what we call good police work. Not illegal. You should discuss the whole thing with your attorney. There are a few times that a CI can't remain "confidential" and still have that information used against you, it's far from a universal prohibition.
Further, there's no honor among criminals (the coloquial expression is thieves, but it pretty much applies). Your criminal associates have no obligation not to "rat" on you and the police and prosecution again are well suited by getting information from one criminal about another.