decode method
Decodes addr, returning the full result (hash bytes + prefix type).
Implementation
XtzAddrDecodedAddress decode(String addr, {XtzAddrPrefixes? addressPrefix}) {
final addrDecBytes = Base58Decoder.decodeWithChecksum(addr);
final t = XtzAddrPrefixes.fromAddrBytes(addrDecBytes);
final expectedLen = t.prefixLen + QuickCrypto.blake2b160DigestSize;
AddrDecUtils.validateBytesLength(addrDecBytes, expectedLen);
final hashBytes = AddrDecUtils.validateAndRemovePrefixBytes(
addrDecBytes,
t.prefix,
);
if (addressPrefix != null && t != addressPrefix) {
throw CoreErrors.addressValidationFailed(
reason: 'Address type mismatch.',
details: {'type': t.name, 'expected': addressPrefix.name},
);
}
return XtzAddrDecodedAddress(bytes: hashBytes, type: t);
}