### Question:
LegacyAddress extends Address { public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException { return LegacyAddress.fromBase58(null, address).getParameters(); } private  LegacyAddress(NetworkParameters params, boolean p2sh, byte[] hash160); static LegacyAddress fromPubKeyHash(NetworkParameters params, byte[] hash160); static LegacyAddress fromKey(NetworkParameters params, ECKey key); static LegacyAddress fromScriptHash(NetworkParameters params, byte[] hash160); static LegacyAddress fromBase58(@Nullable NetworkParameters params, String base58); int getVersion(); String toBase58(); @Override byte[] getHash(); @Override ScriptType getOutputScriptType(); static NetworkParameters getParametersFromAddress(String address); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override LegacyAddress clone(); @Override int compareTo(Address o); static final int LENGTH; final boolean p2sh; }### Answer:
@Test public void getNetwork() { NetworkParameters params = LegacyAddress.getParametersFromAddress("17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL"); assertEquals(MAINNET.getId(), params.getId()); params = LegacyAddress.getParametersFromAddress("n4eA2nbYqErp7H6jebchxAN59DmNpksexv"); assertEquals(TESTNET.getId(), params.getId()); }
@Test public void getAltNetwork() { class AltNetwork extends MainNetParams { AltNetwork() { super(); id = "alt.network"; addressHeader = 48; p2shHeader = 5; } } AltNetwork altNetwork = new AltNetwork(); Networks.register(altNetwork); NetworkParameters params = LegacyAddress.getParametersFromAddress("LLxSnHLN2CYyzB5eWTR9K9rS9uWtbTQFb6"); assertEquals(altNetwork.getId(), params.getId()); params = LegacyAddress.getParametersFromAddress("17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL"); assertEquals(MAINNET.getId(), params.getId()); Networks.unregister(altNetwork); try { LegacyAddress.getParametersFromAddress("LLxSnHLN2CYyzB5eWTR9K9rS9uWtbTQFb6"); fail(); } catch (AddressFormatException e) { } }