Author

Topic: Verifying mrkl root from two children nodes in JAVA (Read 1302 times)

legendary
Activity: 1526
Merit: 1129
Why are you trying to parse a string from another hex-encoded string? Bitcoin doesn't require such an operation anywhere. If you're trying to verify a merkle tree, bitcoinj already has code to do that.
newbie
Activity: 9
Merit: 0
I have a better formatted version of my issue here:
http://bitcoin.stackexchange.com/questions/17676/verifying-mrkl-root-from-two-children-nodes-in-java

I am convinced that there is a JAVA issue with my hexToAscii implementation.

Code:
public String hexToBin(String hex) {
  StringBuilder sb = new StringBuilder();
  StringBuilder temp = new StringBuilder();
  //49204c6f7665204a617661 split into two characters 49, 20, 4c...
  for(int i = 0; i < hex.length() - 1; i += 2){
      //grab the hex in pairs
      String output = hex.substring(i, (i + 2));
      //convert hex to decimal
      int decimal = Integer.parseInt(output, 16);
      //convert the decimal to character
      temp.append(decimal);
  }
  return sb.toString();
}


Code:
d4 : parse=> Ô
9b : parse=> ›
95 : parse=> •
84 : parse=> „
9c : parse=> œ
87 : parse=> ‡
b8 : parse=> ¸
a4 : parse=> ¤

Why so many blanks? My friend's php implementation (which works) spits out characters for some of those.  Although our string lengths are the same size (32), his contains characters that mine doesn't.  (this results in the sha256 being different as well)

Some expertise would be appreciated here =/

Jump to: