Esempio n. 1
0
  /**
   * @param args
   * @throws GeneralSecurityException
   * @throws IOException
   */
  public static void main(String[] args) throws GeneralSecurityException, IOException {

    final String rpcuser = "******"; // RPC User name (set in config)
    final String rpcpassword = "******"; // RPC Pass (set in config)

    Authenticator.setDefault(
        new Authenticator() { // This sets the default authenticator, with the set username and
          // password
          protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(rpcuser, rpcpassword.toCharArray());
          }
        });

    while (true) {
      Work work = getwork(); // Gets the work from the server
      String data = work.result.data; // Gets the data to hash from the work
      String target = work.result.target; // Gets the target from the work
      String realdata = data.substring(0, 160);
      byte[] databyte = endianSwitch(Converter.fromHexString(realdata));

      // Converts the target string to a byte array for easier comparison
      byte[] targetbyte = Converter.fromHexString(target);
      System.out.println(printByteArray(targetbyte));
      if (doScrypt(
          databyte,
          targetbyte)) { // Calls sCrypt with the proper parameters, and returns the correct data
        work.result.data = printByteArray(endianSwitch(databyte)) + data.substring(160, 256);
        System.out.println(sendWork(work)); // Send the work
      }
    }
  }