use of org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal 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);
}
}
use of org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal in project XChange by knowm.
the class BitstampAccountServiceRaw method withdrawBitstampFunds.
/**
* This method can withdraw any currency if withdrawal endpoint is configured in
* BitstampAuthenticatedV2
*/
public BitstampWithdrawal withdrawBitstampFunds(Currency currency, BigDecimal amount, final String address, final String tag) throws IOException {
BitstampWithdrawal response;
if (currency.equals(Currency.XRP)) {
Long dt = null;
try {
dt = Long.valueOf(tag);
} catch (NumberFormatException e) {
// dt may be part of address,
}
response = withdrawRippleFunds(amount, address, dt);
} else if (currency.equals(Currency.XLM)) {
response = withdrawXLM(amount, address, tag);
} else {
response = withdrawAddrAmount(currency, amount, address);
}
if (response.error != null) {
throw new ExchangeException("Failed to withdraw: " + response.error);
}
if (response.getId() == null) {
return null;
}
return response;
}
use of org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal in project XChange by knowm.
the class BitstampAccountDemo method raw.
private static void raw(BitstampAccountServiceRaw accountService) throws IOException {
// Get the account information
BitstampBalance bitstampBalance = accountService.getBitstampBalance();
System.out.println("BitstampBalance: " + bitstampBalance);
BitstampDepositAddress depositAddress = accountService.getBitstampBitcoinDepositAddress();
System.out.println("BitstampDepositAddress address: " + depositAddress);
final List<DepositTransaction> unconfirmedDeposits = accountService.getUnconfirmedDeposits();
System.out.println("Unconfirmed deposits:");
for (DepositTransaction unconfirmedDeposit : unconfirmedDeposits) {
System.out.println(unconfirmedDeposit);
}
final List<WithdrawalRequest> withdrawalRequests = accountService.getWithdrawalRequests(50000000l);
System.out.println("Withdrawal requests:");
for (WithdrawalRequest unconfirmedDeposit : withdrawalRequests) {
System.out.println(unconfirmedDeposit);
}
BitstampWithdrawal withdrawResult = accountService.withdrawBitstampFunds(Currency.BTC, new BigDecimal(1).movePointLeft(4), "XXX");
System.out.println("BitstampBooleanResponse = " + withdrawResult);
}
use of org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal in project XChange by knowm.
the class BitstampAccountService method withdrawFunds.
@Override
public String withdrawFunds(WithdrawFundsParams params) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {
BitstampWithdrawal response;
// XRP, XLM and HBAR add extra param to transaction address which will be the addressTag
if (params instanceof DefaultWithdrawFundsParams) {
DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params;
response = withdrawBitstampFunds(defaultParams.getCurrency(), defaultParams.getAmount(), defaultParams.getAddress(), defaultParams.getAddressTag());
if (response.error != null) {
throw new ExchangeException("Failed to withdraw: " + response.error);
}
} else {
throw new IllegalStateException("Unsupported WithdrawFundsParams sub class");
}
if (response.getId() == null) {
return null;
}
return Long.toString(response.getId());
}
use of org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal 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);
}
}
Aggregations