platelminto / java-bittrex

Java wrapper for the Bittrex API
MIT License
23 stars 18 forks source link

Not reading KEY AND SECRET #7

Open JoseAntonioCaraballo opened 6 years ago

JoseAntonioCaraballo commented 6 years ago

I have been trying to fix this for the last couple of days can you please help. So I'm trying to compile this program to see if it works. I added the key.txt file in the same folder as the source and then i added " - --

Exception in thread "main" java.lang.NullPointerException at com.example.bigboy.bittrexProfit.EncryptionUtility.calculateHash(EncryptionUtility.java:27) at com.example.bigboy.bittrexProfit.Bittrex.getResponseBody(Bittrex.java:345) at com.example.bigboy.bittrexProfit.Bittrex.getJson(Bittrex.java:263) at com.example.bigboy.bittrexProfit.Bittrex.getMarketSummary(Bittrex.java:87) at com.example.bigboy.bittrexProfit.MainActivity.main(MainActivity.java:17)

Can someone please help me

platelminto commented 6 years ago

Could you post what code you're trying to run? It doesn't seem to be an issue the API keys text file. Are you running the setAuthKeysFromTextFile() method? For a keys.txt file in the source folder (and in the same package), run setAuthKeysFromTextFile("keys.txt") on the wrapper.

JoseAntonioCaraballo commented 6 years ago

Im running the same example you gave us in the front MainActivity.java-------- public class MainActivity {

public static void main(String...args) { Bittrex wrapper = new Bittrex(); wrapper.setAuthKeysFromTextFile("keys.txt"); String rawResponse = wrapper.getMarketSummary("BTC-LTC"); List<HashMap<String, String>> responseMapList = Bittrex.getMapsFromResponse(rawResponse); (Only part of it)

Bittrex.java------
public void setAuthKeysFromTextFile(String textFile) try (Scanner scan = new Scanner(getClass().getResourceAsStream(textFile))) { String apikeyLine = scan.nextLine(), secretLine = scan.nextLine(); apikey = apikeyLine.substring(apikeyLine.indexOf("\"") + 1, apikeyLine.lastIndexOf("\"") ); secret = secretLine.substring(secretLine.indexOf("\"") + 1, secretLine.lastIndexOf("\"") ); } catch (NullPointerException | IndexOutOfBoundsException e) { System.err.println("Text file not found or corrupted - please attach key.txt & secret in the format provided."); } } (Only part of it)

keys.txt------------ `

JoseAntonioCaraballo commented 6 years ago

Hi,

Have you gotten the chance to view the code i posted on github? Have you ran the project lately with successful build?

I appreciate you helping me.

Sent from Bluehttp://www.bluemail.me/r?b=11870 On Jan 29, 2018, at 8:23 AM, Giorgio Momigliano notifications@github.com<mailto:notifications@github.com> wrote:

Could you post what code you're trying to run? It doesn't seem to be an issue the API keys text file. Are you running the setAuthKeysFromTextFile() method? For a keys.txt file in the source folder (and in the same package), run setAuthKeysFromTextFile("keys.txt") on the wrapper.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/platelminto/java-bittrex/issues/7#issuecomment-361243812, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQC69Rjws3ZgB9twKyG6N7eEvbyxAmJHks5tPcZmgaJpZM4Rv_3N.