Skip to content

Commit

Permalink
Fix Private Key Version (128)
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Dec 20, 2014
1 parent 5b406af commit a166092
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/bitcoinj/core/CoinDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ public enum CoinPrecision {

public static final String DONATION_ADDRESS = "FkknEYnex1MeZyPRnEebFK5ZBHHsFZbvaf"; //HashEngineering donation DGC address

public static final String UNSPENT_API_URL = "http://dgc.blockr.io/api/v1/address/unspent/";
public static final String UNSPENT_API_URL = "https://chainz.cryptoid.info/grs/api.dws?q=unspent";
public enum UnspentAPIType {
BitEasy,
Blockr,
Abe
Abe,
Cryptoid,
};
public static final UnspentAPIType UnspentAPI = UnspentAPIType.Blockr;
public static final UnspentAPIType UnspentAPI = UnspentAPIType.Cryptoid;

enum CoinHash {
SHA256,
Expand Down
6 changes: 1 addition & 5 deletions core/src/main/java/org/bitcoinj/core/DumpedPrivateKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ private static byte[] encode(byte[] keyBytes, boolean compressed) {
*/
public DumpedPrivateKey(NetworkParameters params, String encoded) throws AddressFormatException {
super(encoded);
if (CoinDefinition.allowBitcoinPrivateKey && version == 128)
{

}
else if (params != null && version != (params.getDumpedPrivateKeyHeader()))
if (params != null && version != (params.getDumpedPrivateKeyHeader()))
throw new AddressFormatException("Mismatched version number, trying to cross networks? " + version +
" vs " + params.getDumpedPrivateKeyHeader());
if (bytes.length == 33 && bytes[32] == 1) {
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/bitcoinj/core/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,9 @@ public synchronized Sha256Hash hashForSignature(int inputIndex, byte[] connected
uint32ToByteStreamLE(0x000000ff & sigHashType, bos);
// Note that this is NOT reversed to ensure it will be signed correctly. If it were to be printed out
// however then we would expect that it is IS reversed.
Sha256Hash hash = new Sha256Hash(doubleDigest(bos.toByteArray()));
//Sha256Hash hash = new Sha256Hash(doubleDigest(bos.toByteArray()));
byte [] bytes = bos.toByteArray();
Sha256Hash hash = new Sha256Hash(singleDigest(bytes, 0, bytes.length));
bos.close();

// Put the transaction back to how we found it.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/params/MainNetParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public MainNetParams() {
targetTimespan = TARGET_TIMESPAN;

maxTarget = CoinDefinition.proofOfWorkLimit;
dumpedPrivateKeyHeader = 128 + CoinDefinition.AddressHeader;
dumpedPrivateKeyHeader = 128;// + CoinDefinition.AddressHeader;
addressHeader = CoinDefinition.AddressHeader;
p2shHeader = CoinDefinition.p2shHeader;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader};
Expand Down

0 comments on commit a166092

Please sign in to comment.