All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.knowm.xchange.exx.service.EXXAccountServiceRaw Maven / Gradle / Ivy

There is a newer version: 4.3.17.1
Show newest version
package org.knowm.xchange.exx.service;

import java.io.IOException;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.exx.EXXAuthenticated;
import org.knowm.xchange.exx.dto.account.EXXAccountInformation;
import org.knowm.xchange.exx.utils.CommonUtil;
import si.mazi.rescu.RestProxyFactory;
import si.mazi.rescu.SynchronizedValueFactory;

public class EXXAccountServiceRaw extends EXXBaseService {
  private final EXXAuthenticated exxAuthenticated;
  private String apiKey;
  private String secretKey;
  private SynchronizedValueFactory nonceFactory;

  public EXXAccountServiceRaw(Exchange exchange) {
    super(exchange);
    this.exxAuthenticated =
        RestProxyFactory.createProxy(
            EXXAuthenticated.class,
            exchange.getExchangeSpecification().getSslUri(),
            getClientConfig());

    this.apiKey = super.apiKey;
    this.secretKey = super.secretKey;
    this.nonceFactory = exchange.getNonceFactory();
  }

  /**
   * Obtain your own personal asset information.
   *
   * @return Object
   * @throws IOException
   */
  public EXXAccountInformation getExxAccountInfo() throws IOException {
    Long nonce = System.currentTimeMillis();
    String params = "accesskey=" + this.apiKey + "&nonce=" + nonce;
    String signature = CommonUtil.HmacSHA512(params, this.secretKey);

    return exxAuthenticated.getAccountInfo(this.apiKey, nonce, signature);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy