@Test(expected = AddressFormatException.InvalidPrefix.class) public void fromBech32_invalidHrp() { SegwitAddress.fromBech32(null, "tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty"); }
public static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32) throws AddressFormatException { Bech32.Bech32Data bechData = Bech32.decode(bech32); if (params == null) { for (NetworkParameters p : Networks.get()) { if (bechData.hrp.equals(p.getSegwitAddressHrp())) return new SegwitAddress(p, bechData.data); } throw new AddressFormatException.InvalidPrefix("No network found for " + bech32); } else { if (bechData.hrp.equals(params.getSegwitAddressHrp())) return new SegwitAddress(params, bechData.data); throw new AddressFormatException.WrongNetwork(bechData.hrp); } }
SegwitAddress extends Address { public static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32) throws AddressFormatException { Bech32.Bech32Data bechData = Bech32.decode(bech32); if (params == null) { for (NetworkParameters p : Networks.get()) { if (bechData.hrp.equals(p.getSegwitAddressHrp())) return new SegwitAddress(p, bechData.data); } throw new AddressFormatException.InvalidPrefix("No network found for " + bech32); } else { if (bechData.hrp.equals(params.getSegwitAddressHrp())) return new SegwitAddress(params, bechData.data); throw new AddressFormatException.WrongNetwork(bechData.hrp); } } }
SegwitAddress extends Address { public static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32) throws AddressFormatException { Bech32.Bech32Data bechData = Bech32.decode(bech32); if (params == null) { for (NetworkParameters p : Networks.get()) { if (bechData.hrp.equals(p.getSegwitAddressHrp())) return new SegwitAddress(p, bechData.data); } throw new AddressFormatException.InvalidPrefix("No network found for " + bech32); } else { if (bechData.hrp.equals(params.getSegwitAddressHrp())) return new SegwitAddress(params, bechData.data); throw new AddressFormatException.WrongNetwork(bechData.hrp); } } private  SegwitAddress(NetworkParameters params, int witnessVersion, byte[] witnessProgram); private  SegwitAddress(NetworkParameters params, byte[] data); }
SegwitAddress extends Address { public static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32) throws AddressFormatException { Bech32.Bech32Data bechData = Bech32.decode(bech32); if (params == null) { for (NetworkParameters p : Networks.get()) { if (bechData.hrp.equals(p.getSegwitAddressHrp())) return new SegwitAddress(p, bechData.data); } throw new AddressFormatException.InvalidPrefix("No network found for " + bech32); } else { if (bechData.hrp.equals(params.getSegwitAddressHrp())) return new SegwitAddress(params, bechData.data); throw new AddressFormatException.WrongNetwork(bechData.hrp); } } private  SegwitAddress(NetworkParameters params, int witnessVersion, byte[] witnessProgram); private  SegwitAddress(NetworkParameters params, byte[] data); int getWitnessVersion(); byte[] getWitnessProgram(); @Override byte[] getHash(); @Override Script.ScriptType getOutputScriptType(); @Override String toString(); static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32); static SegwitAddress fromHash(NetworkParameters params, byte[] hash); static SegwitAddress fromKey(NetworkParameters params, ECKey key); String toBech32(); @Override int compareTo(Address o); }
SegwitAddress extends Address { public static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32) throws AddressFormatException { Bech32.Bech32Data bechData = Bech32.decode(bech32); if (params == null) { for (NetworkParameters p : Networks.get()) { if (bechData.hrp.equals(p.getSegwitAddressHrp())) return new SegwitAddress(p, bechData.data); } throw new AddressFormatException.InvalidPrefix("No network found for " + bech32); } else { if (bechData.hrp.equals(params.getSegwitAddressHrp())) return new SegwitAddress(params, bechData.data); throw new AddressFormatException.WrongNetwork(bechData.hrp); } } private  SegwitAddress(NetworkParameters params, int witnessVersion, byte[] witnessProgram); private  SegwitAddress(NetworkParameters params, byte[] data); int getWitnessVersion(); byte[] getWitnessProgram(); @Override byte[] getHash(); @Override Script.ScriptType getOutputScriptType(); @Override String toString(); static SegwitAddress fromBech32(@Nullable NetworkParameters params, String bech32); static SegwitAddress fromHash(NetworkParameters params, byte[] hash); static SegwitAddress fromKey(NetworkParameters params, ECKey key); String toBech32(); @Override int compareTo(Address o); static final int WITNESS_PROGRAM_LENGTH_PKH; static final int WITNESS_PROGRAM_LENGTH_SH; static final int WITNESS_PROGRAM_MIN_LENGTH; static final int WITNESS_PROGRAM_MAX_LENGTH; }