Commit 6f3098a5 authored by zeroleak's avatar zeroleak
Browse files

cleanup

parent 75dbe7e7
......@@ -32,21 +32,18 @@ public class HD_Wallet {
this(purpose, mc.toMnemonic(mSeed), mParams, mSeed, strPassphrase);
}
// used by Sparrow
public HD_Wallet(byte[] mSeed, String strPassphrase, List<String> mWordList, NetworkParameters mParams) {
protected HD_Wallet(int purpose, List<String> mWordList, NetworkParameters mParams, byte[] mSeed, String strPassphrase) {
this.mSeed = mSeed;
this.strPassphrase = strPassphrase;
this.mWordList = mWordList;
this.mParams = mParams;
this.mAccounts = new LinkedHashMap<>();
}
protected HD_Wallet(int purpose, List<String> wordList, NetworkParameters mParams, byte[] mSeed, String strPassphrase) {
this(mSeed, strPassphrase, wordList, mParams);
// compute rootKey for accounts
this.mRoot = computeRootKey(purpose, mWordList, strPassphrase, mParams);
// initialize accounts
mAccounts = new LinkedHashMap<>();
getAccount(0);
}
public HD_Wallet(int purpose, HD_Wallet inputWallet) {
......@@ -58,6 +55,8 @@ public class HD_Wallet {
*/
public HD_Wallet(NetworkParameters params, String[] xpub) throws AddressFormatException {
mParams = params;
// initialize accounts
mAccounts = new LinkedHashMap<>();
for(int i = 0; i < xpub.length; i++) {
mAccounts.put(i, new HD_Account(mParams, xpub[i], i));
......
......@@ -17,22 +17,22 @@ public class HD_WalletFactoryGenericTest {
// https://github.com/trezor/python-mnemonic/blob/master/vectors.json
hdWallet = hdWalletFactory.restoreWallet("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", passphrase, 1, params);
hdWallet = hdWalletFactory.restoreWallet("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", passphrase, params);
Assertions.assertEquals("00000000000000000000000000000000", hdWallet.getSeedHex());
Assertions.assertEquals(passphrase, hdWallet.getPassphrase());
Assertions.assertEquals(new BigInteger("98271371290466655911529653016182302339914803975553744677741258513646170498272"), hdWallet.mRoot.getPrivKey());
hdWallet = hdWalletFactory.restoreWallet("legal winner thank year wave sausage worth useful legal winner thank yellow", passphrase, 1, params);
hdWallet = hdWalletFactory.restoreWallet("legal winner thank year wave sausage worth useful legal winner thank yellow", passphrase, params);
Assertions.assertEquals("7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", hdWallet.getSeedHex());
Assertions.assertEquals(passphrase, hdWallet.getPassphrase());
Assertions.assertEquals(new BigInteger("12662160214494740211391410586234565047416291165663256642181573049330307149082"), hdWallet.mRoot.getPrivKey());
hdWallet = hdWalletFactory.restoreWallet("letter advice cage absurd amount doctor acoustic avoid letter advice cage above", passphrase, 1, params);
hdWallet = hdWalletFactory.restoreWallet("letter advice cage absurd amount doctor acoustic avoid letter advice cage above", passphrase, params);
Assertions.assertEquals("80808080808080808080808080808080", hdWallet.getSeedHex());
Assertions.assertEquals(passphrase, hdWallet.getPassphrase());
Assertions.assertEquals(new BigInteger("63978822330767128043945360358261997375960365869251665953739239749472592461997"), hdWallet.mRoot.getPrivKey());
hdWallet = hdWalletFactory.restoreWallet("void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold", passphrase, 1, params);
hdWallet = hdWalletFactory.restoreWallet("void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold", passphrase, params);
Assertions.assertEquals("f585c11aec520db57dd353c69554b21a89b20fb0650966fa0a9d6f74fd989d8f", hdWallet.getSeedHex());
Assertions.assertEquals(passphrase, hdWallet.getPassphrase());
Assertions.assertEquals(new BigInteger("11902135336207312062323482070347138053483447968293492732980096496846405108646"), hdWallet.mRoot.getPrivKey());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment