@Test(expected = AddressFormatException.WrongNetwork.class) public void checkNetworkWrong() throws Exception { DumpedPrivateKey.fromBase58(TESTNET, "5HtUCLMFWNueqN9unpgX2DzjMg6SDNZyKRb8s3LJgpFg5ubuMrk"); }
public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58) throws AddressFormatException, AddressFormatException.WrongNetwork { byte[] versionAndDataBytes = Base58.decodeChecked(base58); int version = versionAndDataBytes[0] & 0xFF; byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length); if (params == null) { for (NetworkParameters p : Networks.get()) if (version == p.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(p, bytes); throw new AddressFormatException.InvalidPrefix("No network found for version " + version); } else { if (version == params.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(params, bytes); throw new AddressFormatException.WrongNetwork(version); } }
DumpedPrivateKey extends PrefixedChecksummedBytes { public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58) throws AddressFormatException, AddressFormatException.WrongNetwork { byte[] versionAndDataBytes = Base58.decodeChecked(base58); int version = versionAndDataBytes[0] & 0xFF; byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length); if (params == null) { for (NetworkParameters p : Networks.get()) if (version == p.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(p, bytes); throw new AddressFormatException.InvalidPrefix("No network found for version " + version); } else { if (version == params.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(params, bytes); throw new AddressFormatException.WrongNetwork(version); } } }
DumpedPrivateKey extends PrefixedChecksummedBytes { public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58) throws AddressFormatException, AddressFormatException.WrongNetwork { byte[] versionAndDataBytes = Base58.decodeChecked(base58); int version = versionAndDataBytes[0] & 0xFF; byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length); if (params == null) { for (NetworkParameters p : Networks.get()) if (version == p.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(p, bytes); throw new AddressFormatException.InvalidPrefix("No network found for version " + version); } else { if (version == params.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(params, bytes); throw new AddressFormatException.WrongNetwork(version); } } private  DumpedPrivateKey(NetworkParameters params, byte[] bytes);   DumpedPrivateKey(NetworkParameters params, byte[] keyBytes, boolean compressed); }
DumpedPrivateKey extends PrefixedChecksummedBytes { public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58) throws AddressFormatException, AddressFormatException.WrongNetwork { byte[] versionAndDataBytes = Base58.decodeChecked(base58); int version = versionAndDataBytes[0] & 0xFF; byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length); if (params == null) { for (NetworkParameters p : Networks.get()) if (version == p.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(p, bytes); throw new AddressFormatException.InvalidPrefix("No network found for version " + version); } else { if (version == params.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(params, bytes); throw new AddressFormatException.WrongNetwork(version); } } private  DumpedPrivateKey(NetworkParameters params, byte[] bytes);   DumpedPrivateKey(NetworkParameters params, byte[] keyBytes, boolean compressed); static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58); String toBase58(); ECKey getKey(); boolean isPubKeyCompressed(); @Override String toString(); }
DumpedPrivateKey extends PrefixedChecksummedBytes { public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58) throws AddressFormatException, AddressFormatException.WrongNetwork { byte[] versionAndDataBytes = Base58.decodeChecked(base58); int version = versionAndDataBytes[0] & 0xFF; byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length); if (params == null) { for (NetworkParameters p : Networks.get()) if (version == p.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(p, bytes); throw new AddressFormatException.InvalidPrefix("No network found for version " + version); } else { if (version == params.getDumpedPrivateKeyHeader()) return new DumpedPrivateKey(params, bytes); throw new AddressFormatException.WrongNetwork(version); } } private  DumpedPrivateKey(NetworkParameters params, byte[] bytes);   DumpedPrivateKey(NetworkParameters params, byte[] keyBytes, boolean compressed); static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58); String toBase58(); ECKey getKey(); boolean isPubKeyCompressed(); @Override String toString();  }