Ejemplo n.º 1
0
        /// <summary>
        /// Private Bittrex Call: getbalances
        /// </summary>
        /// <returns></returns>
        private async Task <GetBalancesResult> GetBalances()
        {
            var nonce = APIHelpers.GetNonce();

            var uri = $"https://bittrex.com/api/v1.1/account/getbalances?apikey={ApiKey}&nonce={nonce}";

            var hmac = APIHelpers.GetHash(uri, ApiSecret, APIHelpers.HashAlgorithmType.HMACNineBit, Encoding.ASCII);

            RESTClient.Headers.Clear();
            RESTClient.Headers.Add("apisign", hmac);

            //TODO: Remove GetBalancesArgs. No idea why we are passing GetBalancesArgs in...
            return(await RESTClient.PostAsync <GetBalancesResult, object>(new object(), $"https://bittrex.com/api/v1.1//account/getbalances?apikey={ApiKey}&nonce={nonce}"));
        }
        /// <summary>
        /// Private IR Call: GetAccounts
        /// </summary>
        /// <returns></returns>
        private async Task <List <AccountHolding> > GetAccounts()
        {
            var nonce = APIHelpers.GetNonce();

            dynamic data = new ExpandoObject();

            data.apiKey = ApiKey;
            data.nonce  = nonce;

            var getAccountsArgs = new GetAccountsArgs
            {
                apiKey    = ApiKey,
                nonce     = nonce,
                signature = APIHelpers.GetSignature(RESTClient.BaseUri, "/Private/GetAccounts", data, ApiSecret, APIHelpers.HashAlgorithmType.HMACEightBit)
            };

            return(await RESTClient.PostAsync <List <AccountHolding>, GetAccountsArgs>(getAccountsArgs, "Private/GetAccounts"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Private IR Call: GetAccounts
        /// </summary>
        /// <returns></returns>
        private async Task <List <Balance> > Balances()
        {
            //TODO: Why is this different to the other APIS? Consolidate....
            var nonce            = APIHelpers.GetNonce();
            var bitfinexPostBase = new BitfinexPostBase {
                Request = BalanceRequestUrl, Nonce = nonce
            };
            var jsonObj = JsonConvert.SerializeObject(bitfinexPostBase);
            var payload = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonObj));

            RESTClient.Headers.Clear();
            RESTClient.Headers.Add("X-BFX-APIKEY", ApiKey);
            RESTClient.Headers.Add("X-BFX-PAYLOAD", payload);

            //Notice the ToLower here. This is specific to Bitfinex
            var signature = APIHelpers.GetHash(payload, ApiSecret, APIHelpers.HashAlgorithmType.HMACThreeEightFour, Encoding.UTF8).ToLower();

            RESTClient.Headers.Add("X-BFX-SIGNATURE", signature);

            var retVal = await RESTClient.GetAsync <List <Balance> >(BalanceRequestUrl);

            return(retVal);
        }