Skip to content

Commit

Permalink
DeterministicKeyChain: Allow encrypting DeterministicKeyChain with ar…
Browse files Browse the repository at this point in the history
…bitrary path
  • Loading branch information
HashEngineering authored and Andreas Schildbach committed Mar 12, 2018
1 parent 4bbb7be commit e0d9683
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ protected DeterministicKeyChain(KeyCrypter crypter, KeyParameter aesKey, Determi
checkNotNull(chain.seed);

checkArgument(!chain.rootKey.isEncrypted(), "Chain already encrypted");
setAccountPath(chain.getAccountPath());

this.issuedExternalKeys = chain.issuedExternalKeys;
this.issuedInternalKeys = chain.issuedInternalKeys;
Expand Down
10 changes: 10 additions & 0 deletions core/src/test/java/org/bitcoinj/wallet/WalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ public void basicSpendingWithEncryptedWallet() throws Exception {
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);
Expand Down

0 comments on commit e0d9683

Please sign in to comment.