convert method

  1. @override
Segwit convert(
  1. String input
)
override

Converts input and returns the result of the conversion.

Implementation

@override
Segwit convert(String input) {
  var decoded = bech32.decode(input);

  if (isEmptyProgram(decoded.data)) {
    throw InvalidProgramLength('empty');
  }

  var program = _convertBits(decoded.data, 5, 8, false);

  if (isTooShortProgram(program)) {
    throw InvalidProgramLength('too short');
  }

  if (isTooLongProgram(program)) {
    throw InvalidProgramLength('too long');
  }

  return Segwit(decoded.hrp, program);
}