XChange icon indicating copy to clipboard operation
XChange copied to clipboard

[Binance] cannot make more than 500 withdrawals

Open pvyhnal-generalbytes opened this issue 2 years ago • 3 comments

Our customer reported seeing the following exception:

org.knowm.xchange.binance.dto.BinanceException: Number of saved withdrawal addresses cannot exceed 500. (HTTP status code: 400)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.call(AnnotatedConstructor.java:124)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:291)
at com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromObjectWith(ValueInstantiator.java:288)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:202)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:454)
at com.fasterxml.jackson.databind.deser.std.ThrowableDeserializer.deserializeFromObject(ThrowableDeserializer.java:65)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:195)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4591)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3546)
at si.mazi.rescu.serialization.jackson.JacksonResponseReader.read(JacksonResponseReader.java:53)
at si.mazi.rescu.serialization.jackson.JacksonResponseReader.readException(JacksonResponseReader.java:58)
at si.mazi.rescu.ResponseReader.read(ResponseReader.java:82)
at si.mazi.rescu.RestInvocationHandler.mapInvocationResult(RestInvocationHandler.java:169)
at si.mazi.rescu.RestInvocationHandler.receiveAndMap(RestInvocationHandler.java:157)
at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:113)
at com.sun.proxy.$Proxy113.withdraw(Unknown Source)
at org.knowm.xchange.binance.service.BinanceAccountServiceRaw.lambda$withdraw$1(BinanceAccountServiceRaw.java:56)
at org.knowm.xchange.client.ResilienceUtils$DecorateCallableApi.call(ResilienceUtils.java:86)
at org.knowm.xchange.binance.service.BinanceAccountServiceRaw.withdraw(BinanceAccountServiceRaw.java:68)
at org.knowm.xchange.binance.service.BinanceAccountServiceRaw.withdraw(BinanceAccountServiceRaw.java:40)
at org.knowm.xchange.binance.service.BinanceAccountService.withdrawFunds(BinanceAccountService.java:131)

and Binance support told them:

If you provide the "name" parameter when calling /sapi/v1/capital/withdraw/apply, the address will be automatically added to the whitelist of addresses. In this case, do not specify the "name" parameter when making an API withdrawal. The total number of addresses whitelisted cannot exceed 500

The API spec says the name parameter is optional but the code has a comment saying it might be not?

https://github.com/knowm/XChange/blob/xchange-5.0.12/xchange-binance/src/main/java/org/knowm/xchange/binance/service/BinanceAccountServiceRaw.java#L38

We're on version 5.0.12

pvyhnal-generalbytes avatar Feb 20 '23 13:02 pvyhnal-generalbytes

If you submit a PR with the fix, we'll gladly merge it.

timmolter avatar Feb 28 '23 07:02 timmolter

To clarify, is your issue with the name parameter or the fact that you cannot retrieve more than 500 whitelisted addresses?

TheCookieLab avatar Mar 01 '23 13:03 TheCookieLab

as the quoted response from binance says, when we have the "name" parameter in the "withdraw" request, then the address is stored in a binance whitelist. (this does not seem to be documented). When the whitelist is full (500 addresses) new withdrawals with the "name" parameter fail because they cannot add the address to the whitelist.

I think the solution is just to omit the "name" parameter, but it the xchange code mentions it's mandatory. the api spec doesn't say that so it would have to be tested. Maybe it was mandatory in the past

pvyhnal-generalbytes avatar Mar 01 '23 14:03 pvyhnal-generalbytes