3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Check for loading wallet of wrong params in deserializer (in another way so people who use the API at a lower level also get checked)

This commit is contained in:
Mike Hearn 2014-08-06 18:21:31 +02:00
parent 925338b4fc
commit 249d547ee3
2 changed files with 8 additions and 0 deletions

View File

@ -22,4 +22,10 @@ public class UnreadableWalletException extends Exception {
public static class FutureVersion extends UnreadableWalletException { public static class FutureVersion extends UnreadableWalletException {
public FutureVersion() { super("Unknown wallet version from the future."); } public FutureVersion() { super("Unknown wallet version from the future."); }
} }
public static class WrongNetwork extends UnreadableWalletException {
public WrongNetwork() {
super("Mismatched network ID");
}
}
} }

View File

@ -383,6 +383,8 @@ public class WalletProtobufSerializer {
Protos.Wallet walletProto) throws UnreadableWalletException { Protos.Wallet walletProto) throws UnreadableWalletException {
if (walletProto.getVersion() > 1) if (walletProto.getVersion() > 1)
throw new UnreadableWalletException.FutureVersion(); throw new UnreadableWalletException.FutureVersion();
if (!walletProto.getNetworkIdentifier().equals(params.getId()))
throw new UnreadableWalletException.WrongNetwork();
// Read the scrypt parameters that specify how encryption and decryption is performed. // Read the scrypt parameters that specify how encryption and decryption is performed.
KeyChainGroup chain; KeyChainGroup chain;