DeterministicKeyChain: Allow encrypting DeterministicKeyChain with arbitrary path

This commit is contained in:
HashEngineering
2018-03-11 22:09:26 -07:00
committed by Andreas Schildbach
parent 4bbb7be059
commit e0d9683bd5
2 changed files with 11 additions and 0 deletions

View File

@@ -433,6 +433,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
checkNotNull(chain.seed);
checkArgument(!chain.rootKey.isEncrypted(), "Chain already encrypted");
setAccountPath(chain.getAccountPath());
this.issuedExternalKeys = chain.issuedExternalKeys;
this.issuedInternalKeys = chain.issuedInternalKeys;

View File

@@ -165,6 +165,16 @@ public class WalletTest extends TestWithWallet {
basicSpendingCommon(encryptedWallet, myEncryptedAddress, OTHER_ADDRESS, encryptedWallet);
}
@Test
public void encryptWalletWithArbitraryPath() throws Exception {
final byte[] ENTROPY = Sha256Hash.hash("don't use a string seed like this in real life".getBytes());
KeyChainGroup keyChainGroup = new KeyChainGroup(UNITTEST,
new DeterministicSeed(ENTROPY, "", 1389353062L),
DeterministicKeyChain.BIP44_ACCOUNT_ZERO_PATH);
Wallet encryptedWallet = new Wallet(UNITTEST, keyChainGroup);
encryptedWallet.encrypt(PASSWORD1);
}
@Test
public void basicSpendingFromP2SH() throws Exception {
createMarriedWallet(2, 2);