id method

String id()

Implementation

String id() {
    if (aresamebytes(this.subaccount, Uint8List(32))) {
        return this.owner.text;
    }

    Crc32 crc32 = Crc32();
    crc32.add(this.owner.bytes);
    crc32.add(this.subaccount);
    Uint8List calculate_crc32 = Uint8List.fromList(crc32.close());
    String checksum_fmt = base32.encode(calculate_crc32);
    if (checksum_fmt.contains('=')) { checksum_fmt = checksum_fmt.substring(0, checksum_fmt.indexOf('=')); } // remove padding

    String subaccount_fmt = bytesasahexstring(this.subaccount);
    while (subaccount_fmt[0] == '0') { subaccount_fmt = subaccount_fmt.substring(1); }

    return '${owner.text}-${checksum_fmt}.${subaccount_fmt}'.toLowerCase();
}