convertVersion function

String convertVersion(
  1. String str,
  2. Version target
)

Replaces the first 4 bytes of a base58 string with the target's version and returns the new string. Also checks if the input is a correct address.

Implementation

String convertVersion(String str, Version target) {
  try {
    final bytes = bs58check.decode(str);
    final replaced = replaceVersionBytes(bytes.toList(), target);
    return bs58check.encode(replaced);
  } on ArgumentError catch (e) {
    throw configException(e.message);
  }
}