bitcoinj/bitcoinj — pull request #93 by troggy (2014-06-05 14:23:06+00:00)
Title: HD wallet: currentKey is now stable after serialization roundtrip

At the moment currentKeys map of KeyChainGroup is not restored after deserialization and subsequent call to currentKey produces different key then expected.

As an example the following test will fail:
```
DeterministicKey key = group.currentKey(KeyChain.KeyPurpose.CHANGE);
group = KeyChainGroup.fromProtobufUnencrypted(group.serializeToProtobuf());
assertEquals(key, group.currentKey(KeyChain.KeyPurpose.CHANGE));
```

Proposed solution reconstructs currentKey map on deserialization using stored numbers of issues keys. It is
not future-proof as it assumes only RECEIVE and CHANGE keys are being used.

Some of the changes in KeyChainGroupTest may seem pointless, but they are not. I've deliberately added one more freshKey call to make the group have different number of external and internal keys issued.