convert method
Converts input
and returns the result of the conversion.
Implementation
@override
String convert(Segwit input) {
var version = input.version;
var program = input.program;
if (isInvalidVersion(version)) {
throw InvalidWitnessVersion(version);
}
if (isTooShortProgram(program)) {
throw InvalidProgramLength('too short');
}
if (isTooLongProgram(program)) {
throw InvalidProgramLength('too long');
}
if (isWrongVersion0Program(version, program)) {
throw InvalidProgramLength(
'version $version invalid with length ${program.length}');
}
var data = _convertBits(program, 8, 5, true);
return bech32.encode(Bech32(input.hrp, [version] + data));
}