use of org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams in project XChange by knowm.
the class BinanceAccountService method withdrawFunds.
@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
try {
if (!(params instanceof DefaultWithdrawFundsParams)) {
throw new IllegalArgumentException("DefaultWithdrawFundsParams must be provided.");
}
WithdrawResponse withdraw;
if (params instanceof RippleWithdrawFundsParams) {
RippleWithdrawFundsParams rippleParams = null;
rippleParams = (RippleWithdrawFundsParams) params;
withdraw = super.withdraw(rippleParams.getCurrency().getCurrencyCode(), rippleParams.getAddress(), rippleParams.getTag(), rippleParams.getAmount());
} else {
DefaultWithdrawFundsParams p = (DefaultWithdrawFundsParams) params;
withdraw = super.withdraw(p.getCurrency().getCurrencyCode(), p.getAddress(), p.getAddressTag(), p.getAmount());
}
return withdraw.getId();
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams in project XChange by knowm.
the class BTCMarketsAccountServiceTest method withdrawFundsShouldAppendRippleTag.
@Test
public void withdrawFundsShouldAppendRippleTag() throws IOException {
// maybe the id would be more useful?
String status = "the-status";
BTCMarketsWithdrawCryptoResponse response = new BTCMarketsWithdrawCryptoResponse(true, null, null, status, "id", "desc", "ccy", BigDecimal.ONE, BigDecimal.ONE, 0L);
ArgumentCaptor<BTCMarketsWithdrawCryptoRequest> captor = ArgumentCaptor.forClass(BTCMarketsWithdrawCryptoRequest.class);
when(btcMarketsAuthenticated.withdrawCrypto(Mockito.eq(SPECIFICATION_API_KEY), Mockito.any(SynchronizedValueFactory.class), Mockito.any(BTCMarketsDigest.class), captor.capture())).thenReturn(response);
// when
RippleWithdrawFundsParams params = new RippleWithdrawFundsParams("any address", Currency.BTC, BigDecimal.TEN, "12345");
String result = btcMarketsAccountService.withdrawFunds(params);
assertThat(captor.getValue().address).isEqualTo("any address?dt=12345");
assertThat(result).isNotNull();
}
use of org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams in project XChange by knowm.
the class BTCMarketsAccountService method withdrawFunds.
@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
if (params instanceof DefaultWithdrawFundsParams) {
DefaultWithdrawFundsParams defaultWithdrawFundsParams = (DefaultWithdrawFundsParams) params;
String address = defaultWithdrawFundsParams.address;
if (params instanceof RippleWithdrawFundsParams) {
address = address + "?dt=" + ((RippleWithdrawFundsParams) params).tag;
}
return withdrawCrypto(address, defaultWithdrawFundsParams.getAmount(), defaultWithdrawFundsParams.getCurrency());
}
throw new IllegalStateException("Cannot process " + params);
}
use of org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams in project XChange by knowm.
the class ExmoAccountService method withdrawFunds.
@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
Map<String, Object> result;
if (params instanceof RippleWithdrawFundsParams) {
RippleWithdrawFundsParams rippleWithdrawFundsParams = (RippleWithdrawFundsParams) params;
result = exmo.withdrawCrypt(signatureCreator, apiKey, exchange.getNonceFactory(), rippleWithdrawFundsParams.getAmount(), rippleWithdrawFundsParams.getCurrency().getCurrencyCode(), rippleWithdrawFundsParams.getAddress(), rippleWithdrawFundsParams.getTag());
} else if (params instanceof DefaultWithdrawFundsParams) {
DefaultWithdrawFundsParams defaultWithdrawFundsParams = (DefaultWithdrawFundsParams) params;
result = exmo.withdrawCrypt(signatureCreator, apiKey, exchange.getNonceFactory(), defaultWithdrawFundsParams.getAmount(), defaultWithdrawFundsParams.getCurrency().getCurrencyCode(), defaultWithdrawFundsParams.getAddress(), null);
} else {
throw new IllegalStateException("Don't understand " + params);
}
Boolean success = (Boolean) result.get("result");
if (success) {
return result.get("task_id").toString();
} else {
throw new ExchangeException("Withdrawal failed: " + result.get("error").toString());
}
}
use of org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams in project XChange by knowm.
the class IndependentReserveAccountService method withdrawFunds.
@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
if (!(params instanceof DefaultWithdrawFundsParams)) {
throw new IllegalStateException("Don't know how to withdraw: " + params);
}
String destinationTag = null;
if (params instanceof RippleWithdrawFundsParams) {
destinationTag = ((RippleWithdrawFundsParams) params).getTag();
}
if (destinationTag == null && params instanceof MoneroWithdrawFundsParams) {
destinationTag = ((MoneroWithdrawFundsParams) params).getPaymentId();
}
DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params;
withdrawDigitalCurrency(defaultParams.getAmount(), defaultParams.getAddress(), "", defaultParams.getCurrency().getCurrencyCode(), destinationTag);
return null;
}
Aggregations