checkPublicKey function

String checkPublicKey(
  1. String publicKey
)

Implementation

String checkPublicKey(String publicKey) {
  if (publicKey.length == 66 &&
      (publicKey.startsWith('02') || publicKey.startsWith('03'))) {
    return publicKey;
  } else if (publicKey.length > 66 && publicKey.startsWith('04')) {
    return publicKey;
  } else if (publicKey.length == 64) {
    return '02$publicKey';
  }
  throw Exception('Invalid Public Key');
}