matchBech32Format function

bool matchBech32Format(
  1. String? str
)

Returns true if the provided str is a valid bech32 string (no checksum check is done). See: https://en.bitcoin.it/wiki/Bech32

Implementation

bool matchBech32Format(String? str) {
  if (str == null) {
    throw ArgumentError('(str) must not be null');
  }

  if (str.length < 8 || str.length > 90) {
    return false;
  }

  final regExp = RegExp(r'^(\S{1,83})(1)([^1bio]{6,88})$');

  return regExp.hasMatch(str);
}