Closed GoogleCodeExporter closed 9 years ago
Right, there's a lot of inconsistency around how private keys are represented.
I have no idea what "Private Key WIF" means.
Wallet-Tool currently assumes all pubkeys are compressed. To get the
uncompressed form, you need to write your own code and use
public ECKey(BigInteger privKey, byte[] pubKey, boolean compressed) {}
Set privKey to be the private key, pubKey to null, compressed to false.
Yes, I know the ECKey API is a mess. Will fix one day.
Once you convert that ECKey to an address, it should match up. Does that help?
Original comment by hearn@google.com
on 12 Apr 2013 at 9:35
So how to generate uncompressed private key string which can be inserted to,
say, armory?
Original comment by valle.ke...@gmail.com
on 19 Apr 2013 at 6:11
Armory should just be fixed to understand compressed keys. Maybe we'd make
compression optional in future bitcoinj releases but there isn't really any
advantage to doing so, other software should just be upgraded to handle it.
Original comment by hearn@google.com
on 22 Apr 2013 at 11:33
Original comment by hearn@google.com
on 17 Jun 2013 at 1:43
all it needs is to remove the version byte from the Base58 decoded array before
creating the key.
import java.util.Arrays;
import java.util.Scanner;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Base58;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.params.MainNetParams;
public class MyClass {
/**
* @param args
* @throws AddressFormatException
*/
public static void main(String[] args) throws AddressFormatException {
Scanner in = new Scanner(System.in);
System.out.println("enter private key:");
byte[] g = Arrays.copyOfRange(Base58.decodeChecked(in.nextLine()), 1, 33);
ECKey priv = ECKey.fromPrivate(g, false);
String myAddr = priv.toAddress(MainNetParams.get()).toString();
System.out.println(myAddr);
}
}
Original comment by oha...@gmail.com
on 25 Jan 2015 at 12:31
Original issue reported on code.google.com by
fireduck@gmail.com
on 11 Apr 2013 at 9:20