Added the getWalletImportFormat to the BrainKey class
This commit is contained in:
parent
8f7a5549bd
commit
4c105de826
4 changed files with 28 additions and 3 deletions
|
@ -1,7 +1,6 @@
|
|||
package com.luminiasoft.bitshares;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import org.bitcoinj.core.Base58;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.crypto.HDKeyDerivation;
|
||||
|
|
|
@ -2,12 +2,16 @@ package com.luminiasoft.bitshares;
|
|||
|
||||
import com.luminiasoft.bitshares.crypto.AndroidRandomSource;
|
||||
import com.luminiasoft.bitshares.crypto.SecureRandomStrengthener;
|
||||
import org.bitcoinj.core.Base58;
|
||||
import org.bitcoinj.core.DumpedPrivateKey;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.ECPoint;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
@ -72,11 +76,30 @@ public class BrainKey {
|
|||
System.out.println("UnsupportedEncodingException. Msg: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the array of bytes representing the public key.
|
||||
* @return
|
||||
*/
|
||||
public byte[] getPublicKey() {
|
||||
return mPrivateKey.getPubKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the private key as an instance of the ECKey class.
|
||||
* @return
|
||||
*/
|
||||
public ECKey getPrivateKey() {
|
||||
return mPrivateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the private key in the Wallet Import Format for the uncompressed private key.
|
||||
* @see <a href="https://en.bitcoin.it/wiki/Wallet_import_format">WIF</a>
|
||||
* @return
|
||||
*/
|
||||
public String getWalletImportFormat(){
|
||||
DumpedPrivateKey wif = this.mPrivateKey.decompress().getPrivateKeyEncoded(NetworkParameters.fromID(NetworkParameters.ID_MAINNET));
|
||||
return wif.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,10 @@ import java.io.IOException;
|
|||
|
||||
public class Main {
|
||||
// Brain key from Nelson's app referencing the bilthon-83 account
|
||||
public static final String BRAIN_KEY = "PUMPER ISOTOME SERE STAINER CLINGER MOONLIT CHAETA UPBRIM AEDILIC BERTHER NIT SHAP SAID SHADING JUNCOUS CHOUGH";
|
||||
// public static final String BRAIN_KEY = "PUMPER ISOTOME SERE STAINER CLINGER MOONLIT CHAETA UPBRIM AEDILIC BERTHER NIT SHAP SAID SHADING JUNCOUS CHOUGH";
|
||||
|
||||
//public static final String BRAIN_KEY = "TWIXT SERMO TRILLI AUDIO PARDED PLUMET BIWA REHUNG MAUDLE VALVULA OUTBURN FEWNESS ALIENER UNTRACE PRICH TROKER";
|
||||
public static final String BRAIN_KEY = "SIVER TIKKER FOGO HOMINAL PRAYER LUTEIN SMALLY ACARID MEROPIA TRANCE BOGONG IDDAT HICKORY SOUTANE MOOD DOWSER";
|
||||
|
||||
public static final String BIP39_KEY = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
|
||||
|
||||
|
@ -66,7 +68,7 @@ public class Main {
|
|||
|
||||
// test.testRandomNumberGeneration();
|
||||
|
||||
test.testBrainKeyOperations(true);
|
||||
test.testBrainKeyOperations(false);
|
||||
|
||||
// test.testBip39Opertion();
|
||||
}
|
||||
|
|
|
@ -546,6 +546,7 @@ public class Test {
|
|||
Address address = new Address(key);
|
||||
System.out.println("Block explorer's address: "+address);
|
||||
|
||||
System.out.println("Wif: : "+brainKey.getWalletImportFormat());
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("FileNotFoundException. Msg: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Reference in a new issue