checkBtcAddress static method

bool checkBtcAddress(
  1. String address, [
  2. NetworkType? networkType
])

Implementation

static bool checkBtcAddress(String address,
    [bitcoin.NetworkType? networkType]) {
  try {
    if (networkType?.prefix == 'bitcoincash' &&
        !address.startsWith('1') &&
        !address.startsWith('3')) {
      return checkStandardBase32(address);
    }
    if (address.startsWith('bc')) {
      return checkBech32Address(address, 'bc', address.length - 3);
    }
    bitcoin.Address.addressToOutputScript(address, networkType);
    return true;
  } catch (error) {
    return false;
  }
}