XChange
XChange copied to clipboard
Huobi nullpointer, because transactionFeeWithdrawal may be null
In HuobiAdapters, the line
BigDecimal transactFeeWithdraw = new BigDecimal(huobiCurrency.getTransactFeeWithdraw());
leads to a nullpointer, since transactFeeWithdraw may be null. Huobi's API documentation says: "Withdraw fee in each request (only applicable to withdrawFeeType = fixed)" according to https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
I am having the same issue with it. The adapter stopped working all of a sudden. Although, I am not sure how that happened, because there is no Huobi changelog that would indicate anything obvious.
Caused by: java.lang.NullPointerException at java.base/java.math.BigDecimal.<init>(BigDecimal.java:834) at org.knowm.xchange.huobi.HuobiAdapters.getCurrencyMetaData(HuobiAdapters.java:140) at org.knowm.xchange.huobi.HuobiAdapters.adaptCurrencyMetaData(HuobiAdapters.java:126) at org.knowm.xchange.huobi.HuobiAdapters.adaptToExchangeMetaData(HuobiAdapters.java:111) at org.knowm.xchange.huobi.HuobiExchange.remoteInit(HuobiExchange.java:45) at org.knowm.xchange.BaseExchange.applySpecification(BaseExchange.java:113) at org.knowm.xchange.ExchangeFactory.createExchange(ExchangeFactory.java:130) ...
A quick and dirty workaround would be modifying the HuobiAdapters.getCurrencyMetaData() method to:
private static CurrencyMetaData getCurrencyMetaData(
HuobiCurrency huobiCurrency, boolean isDelisted) {
int withdrawPrecision = huobiCurrency.getWithdrawPrecision();
BigDecimal transactFeeWithdraw = BigDecimal.ONE;
if(huobiCurrency!=null && huobiCurrency.getTransactFeeWithdraw() != null) {
transactFeeWithdraw = new BigDecimal(huobiCurrency.getTransactFeeWithdraw());
}
BigDecimal minWithdrawAmt = new BigDecimal(huobiCurrency.getMinWithdrawAmt());
WalletHealth walletHealthStatus =
isDelisted ? WalletHealth.OFFLINE : getWalletHealthStatus(huobiCurrency);
return new CurrencyMetaData(
withdrawPrecision, transactFeeWithdraw, minWithdrawAmt, walletHealthStatus);
}
@mumch I have created a solution locally and installed a snapshot version to use in my uber jar.
I can create a PR in your repo if it helps.
Thanks, Norbert
@vangogiel If you have an appropriate solution, better make a pull request directly here to the XChange project. Thank you and regards, mum
My solution was to just query the transactionFeeWithdraw if it is null to place BigDecimal.ZERO
Στις Παρ 12 Αυγ 2022 στις 4:17 μ.μ., ο/η mumch @.***> έγραψε:
@vangogiel https://github.com/vangogiel If you have an appropriate solution, better make a pull request directly here to the XChange project. Thank you and regards, mum
— Reply to this email directly, view it on GitHub https://github.com/knowm/XChange/issues/4537#issuecomment-1213100245, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHIWQ746TGJSCLC4QWNZBN3VYZFGDANCNFSM55A5YFVQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@mumch
I created a PR, https://github.com/knowm/XChange/pull/4552.
In my opinion, this is the cleanest approach.
I wanted to add a test, but there is no structure for Integration
or Exchange
tests, so I wasn't invasive as much.
@vangogiel i have add your implementation to my PR #4546 also. Thanks
@makarid @mumch What happens to my PR then?
Hi @vangogiel I don't know, I am not one of the project owners. But I guess, it will be merged with the next release.
I have add your implementation to my PR and it got merge. Then probably your PR was cancelled because my PR had already merged it.
On Thu, Aug 25, 2022, 12:44 PM mumch @.***> wrote:
Hi @vangogiel https://github.com/vangogiel I don't know, I am not one of the project owners. But I guess, it will be merged with the next release.
— Reply to this email directly, view it on GitHub https://github.com/knowm/XChange/issues/4537#issuecomment-1227031948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHIWQ7ZCHCCI4TZTHBNP6HLV246BFANCNFSM55A5YFVQ . You are receiving this because you were mentioned.Message ID: @.***>
Yeah, it would be nice to get credit for that work.
5.0.14-SNAPSHOT
fix this issue.
pom.xml as follow:
<dependencies>
<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-huobi</artifactId>
<version>5.0.14-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-oss-snapshot</id>
<snapshots/>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
I'll do a proper release soon, as it's been a long while now.