knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.82k stars 1.93k forks source link

Binance get deposit address - failure reason not available #3879

Open pvyhnal-generalbytes opened 3 years ago

pvyhnal-generalbytes commented 3 years ago

when calling org.knowm.xchange.binance.service.BinanceAccountService#requestDepositAddress it can get something like {"msg":"Apologies but we are unable to provide services to you as per our Terms of Use.","success":false} (HTTP 200) from the server and it is logged in TRACE level but when that happen null is returned from that method.

Is this the pattern with other exchanges too or should it throw an exception?

CayenneLow commented 3 years ago

Hey, just chiming in here in case this would be useful. I know this isn't exactly an answer to your question but I was getting that error as well when hosting my app in a US region. Binance has a separate API for US that you should be using (or just host the app somewhere other than US)

earce commented 3 years ago

To cayenne's point that was my first reaction (but I am not sure if that is what is causing it) but us is binance.us and everywhere else is binance.com

pvyhnal-generalbytes commented 3 years ago

Yes this specific error happens when you call binance.com from the USA (see this reddit post) but my issue is that in that case the method just returns null. Should it throw an exception with the message from the HTTP response instead?

The same problem is when your IP is not on the whitelist for example. You would need trace logging to see the reason why it failed.

earce commented 3 years ago

@pvyhnal-generalbytes i think throwing the message the exchange is throwing back is most certainly the right way to go about this feel free to open a PR