XRPAddress.fromBase58 constructor

XRPAddress.fromBase58(
  1. String base58
)

must be valid base58

Implementation

factory XRPAddress.fromBase58(String base58) {
  try {
    final prefix = base58.substring(0, 1).toLowerCase();
    if (base58.length != 34 || (prefix != "r" && prefix != "x")) {
      throw ArgumentError(
          "Invalid ripple address. address should be 34 charcter start with X or r");
    }
    final tob64 = bs58.xrplBase58.decode(base58);

    if (tob64.length != 25) {
      throw ArgumentError("Invalid ripple address");
    }
    return XRPAddress._(base58);
    // ignore: empty_catches
  } catch (e) {}
  throw ArgumentError("Invalid ripple address");
}