Search in sources :

Example 1 with BitstampException

use of org.knowm.xchange.bitstamp.dto.BitstampException in project XChange by knowm.

the class BitstampAccountServiceRaw method withdrawXLM.

public BitstampWithdrawal withdrawXLM(BigDecimal amount, String address, String memo) throws IOException {
    try {
        Long longMemo = null;
        if (memo != null) {
            try {
                longMemo = Long.valueOf(memo);
            } catch (NumberFormatException exception) {
                throw new RuntimeException("Bitstamp supports only numbers for xlm memo field");
            }
        }
        BitstampWithdrawal response = bitstampAuthenticatedV2.withdrawXLM(apiKeyForV2Requests, signatureCreatorV2, uuidNonceFactory, timestampFactory, API_VERSION, amount, address, longMemo);
        return checkAndReturnWithdrawal(response);
    } catch (BitstampException e) {
        throw handleError(e);
    }
}
Also used : BitstampWithdrawal(org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal) BitstampException(org.knowm.xchange.bitstamp.dto.BitstampException)

Example 2 with BitstampException

use of org.knowm.xchange.bitstamp.dto.BitstampException in project XChange by knowm.

the class BitstampAccountServiceRaw method withdrawAddrAmount.

/**
 * To prevent code repetition we try to resolve client method
 */
public BitstampWithdrawal withdrawAddrAmount(Currency currency, BigDecimal amount, String address) {
    try {
        Class<? extends BitstampAuthenticatedV2> clientClass = bitstampAuthenticatedV2.getClass();
        Method withdrawMethod = clientClass.getMethod("withdraw" + currency.getCurrencyCode(), String.class, ParamsDigest.class, SynchronizedValueFactory.class, SynchronizedValueFactory.class, String.class, BigDecimal.class, String.class);
        BitstampWithdrawal response = (BitstampWithdrawal) withdrawMethod.invoke(bitstampAuthenticatedV2, apiKeyForV2Requests, signatureCreatorV2, uuidNonceFactory, timestampFactory, API_VERSION, amount, address);
        return checkAndReturnWithdrawal(response);
    } catch (BitstampException e) {
        throw handleError(e);
    } catch (Exception e) {
        throw new RuntimeException("Failed to call bitstamp withdraw method on authenticated client", e);
    }
}
Also used : BitstampWithdrawal(org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal) BitstampException(org.knowm.xchange.bitstamp.dto.BitstampException) Method(java.lang.reflect.Method) FundsExceededException(org.knowm.xchange.exceptions.FundsExceededException) IOException(java.io.IOException) BitstampException(org.knowm.xchange.bitstamp.dto.BitstampException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Example 3 with BitstampException

use of org.knowm.xchange.bitstamp.dto.BitstampException in project XChange by knowm.

the class BitstampAccountServiceRaw method withdrawRippleFunds.

public BitstampWithdrawal withdrawRippleFunds(BigDecimal amount, String address, Long destinationTag) throws IOException {
    BitstampRippleDepositAddress addressAndDt;
    // even if tag was not explicitly provided in method call, it can still be there as part of
    // address as addr?dt=tag
    addressAndDt = new BitstampRippleDepositAddress(null, address, destinationTag);
    try {
        BitstampWithdrawal response = bitstampAuthenticatedV2.withdrawXRP(apiKeyForV2Requests, signatureCreatorV2, uuidNonceFactory, timestampFactory, API_VERSION, amount, addressAndDt.getAddress(), addressAndDt.getDestinationTag());
        return checkAndReturnWithdrawal(response);
    } catch (BitstampException e) {
        throw handleError(e);
    }
}
Also used : BitstampWithdrawal(org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal) BitstampException(org.knowm.xchange.bitstamp.dto.BitstampException) BitstampRippleDepositAddress(org.knowm.xchange.bitstamp.dto.account.BitstampRippleDepositAddress)

Aggregations

BitstampException (org.knowm.xchange.bitstamp.dto.BitstampException)3 BitstampWithdrawal (org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal)3 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 BitstampRippleDepositAddress (org.knowm.xchange.bitstamp.dto.account.BitstampRippleDepositAddress)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 FundsExceededException (org.knowm.xchange.exceptions.FundsExceededException)1