PaymentCode.fromBase58 constructor

PaymentCode.fromBase58(
  1. String encoded
)

Implementation

factory PaymentCode.fromBase58(String encoded) {
  final decoded = VaultKeeper.vault.codec.base58CheckDecode(encoded);
  if (decoded.isEmpty) {
    throw FormatException('Empty payment code');
  }
  if (decoded[0] != _base58Version) {
    throw FormatException(
        'Invalid payment code version byte: 0x${decoded[0].toRadixString(16)}');
  }
  if (decoded.length != 81) {
    throw FormatException(
        'Payment code must be 81 bytes (1 version + 80 payload), '
        'got ${decoded.length}');
  }
  return PaymentCode(decoded.sublist(1));
}