use of org.bitcoinj.core.WrongNetworkException in project sentinel-android by Samourai-Wallet.
the class FormatsUtil method isValidBitcoinAddress.
public boolean isValidBitcoinAddress(final String address) {
boolean ret = false;
Address addr = null;
if (address.toLowerCase().startsWith("bc")) {
try {
Pair<Byte, byte[]> pair = Bech32Segwit.decode(address.substring(0, 2), address);
if (pair.getLeft() == null || pair.getRight() == null) {
;
} else {
ret = true;
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
addr = new Address(MainNetParams.get(), address);
if (addr != null) {
ret = true;
}
} catch (WrongNetworkException wne) {
ret = false;
} catch (AddressFormatException afe) {
ret = false;
}
}
return ret;
}
use of org.bitcoinj.core.WrongNetworkException in project samourai-wallet-android by Samourai-Wallet.
the class FormatsUtil method isValidBitcoinAddress.
public boolean isValidBitcoinAddress(final String address) {
boolean ret = false;
Address addr = null;
if ((!SamouraiWallet.getInstance().isTestNet() && address.toLowerCase().startsWith("bc")) || (SamouraiWallet.getInstance().isTestNet() && address.toLowerCase().startsWith("tb"))) {
try {
Pair<Byte, byte[]> pair = Bech32Segwit.decode(address.substring(0, 2), address);
if (pair.getLeft() == null || pair.getRight() == null) {
;
} else {
ret = true;
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
addr = new Address(SamouraiWallet.getInstance().getCurrentNetworkParams(), address);
if (addr != null) {
ret = true;
}
} catch (WrongNetworkException wne) {
ret = false;
} catch (AddressFormatException afe) {
ret = false;
}
}
return ret;
}
Aggregations