She had been changed and blackmail to marry her or demanding money?

Hi my name is Kumar,age 36M,I'm married in 2017,and had a girl child aged 4yrs,but in recent times from 1yr my wife and me are not living together due to some reasons. I had a friend who was known to me since 2008, her age 30F unmarried,we r so close to eachother and vry besties,she knows me vry well and before my marriage she proposed me,but i rejected and got married,after that we had no contact for almost 1yr, after we came into contact again somehow and we keep moving as friends, from corona time I got some financial problems and from their onwards She started helping me financially as keep going,she gave me around 25Lakhs,i never asked or demand her to give money,she only used to say me that she had so much money and can help me out from the situation,after u got settled plz return my money back,and she did not give me the amount in lumpsum, from 2019 to 2022 she had given me that to not by had,all in my bank account and the transaction is clear.so from since last year we r too close that,we had an sexual intercourse twice with her consent only. Now here is the problem that suddenly she started asking for me that to very urgent,I had explained her well about my situation and she too know all my personal things,I asked her to give me 3months time,so I can clear for you,but one day all of the sudden,she and her family had logged a complaint against me for rape and disha case and cheating case for 2 crore rupees,I had been taken to the police station and said clearly what all happened,but the police personnel also threatened me and send me to that party for settlement, Here they are threatening and blackmailing me to marry her or demanding for 50Lakh rupees,saying that u had no choice if not we will go to media and on that day I feared about my family and accepted to give money,they had made a document for that amount and given me some time. Can I have any right in law,that can I also file a case.i will give her the money but I had not that much,and no time, already time they given is running out,what the correct decision I had to make in this situation,plzz sir anyone plzz help me out. Thanks...