Search in sources :

Example 1 with RippleWithdrawFundsParams

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);
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) BinanceException(org.knowm.xchange.binance.dto.BinanceException) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) WithdrawResponse(org.knowm.xchange.binance.dto.account.WithdrawResponse)

Example 2 with RippleWithdrawFundsParams

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();
}
Also used : RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) BTCMarketsWithdrawCryptoRequest(org.knowm.xchange.btcmarkets.dto.trade.BTCMarketsWithdrawCryptoRequest) BTCMarketsWithdrawCryptoResponse(org.knowm.xchange.btcmarkets.dto.trade.BTCMarketsWithdrawCryptoResponse) SynchronizedValueFactory(si.mazi.rescu.SynchronizedValueFactory) Test(org.junit.Test)

Example 3 with RippleWithdrawFundsParams

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);
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams)

Example 4 with RippleWithdrawFundsParams

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());
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Example 5 with RippleWithdrawFundsParams

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;
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) MoneroWithdrawFundsParams(org.knowm.xchange.service.trade.params.MoneroWithdrawFundsParams)

Aggregations

RippleWithdrawFundsParams (org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams)5 DefaultWithdrawFundsParams (org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams)4 Test (org.junit.Test)1 BinanceException (org.knowm.xchange.binance.dto.BinanceException)1 WithdrawResponse (org.knowm.xchange.binance.dto.account.WithdrawResponse)1 BTCMarketsWithdrawCryptoRequest (org.knowm.xchange.btcmarkets.dto.trade.BTCMarketsWithdrawCryptoRequest)1 BTCMarketsWithdrawCryptoResponse (org.knowm.xchange.btcmarkets.dto.trade.BTCMarketsWithdrawCryptoResponse)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 MoneroWithdrawFundsParams (org.knowm.xchange.service.trade.params.MoneroWithdrawFundsParams)1 SynchronizedValueFactory (si.mazi.rescu.SynchronizedValueFactory)1