decodeAddr method
Blockchain address decoder for Ada Shelley addresses. This decoder is used to decode payment addresses based on the network tag and address format.
Implementation
@override
List<int> decodeAddr(String addr, [Map<String, dynamic> kwargs = const {}]) {
/// Determine the network tag, defaulting to mainnet if not specified.
final netTag = kwargs["net_tag"] ?? ADANetwork.mainnet;
/// Check if the provided network tag is a valid enum value.
if (netTag is! ADANetwork) {
throw const AddressConverterException(
'Address type is not an enumerative of ADANetwork');
}
// Decode the provided Bech32 address.
final addrDecBytes = Bech32Decoder.decode(
AdaShelleyAddrConst.networkTagToAddrHrp[netTag]!, addr);
/// Validate the byte length of the decoded address.
AddrDecUtils.validateBytesLength(
addrDecBytes, QuickCrypto.blake2b224DigestSize + 1);
/// Encode the address prefix based on the payment header type and network tag.
final prefixByte = AdaShelleyAddrUtils.encodePrefix(
ADAAddressType.enterprise,
netTag.value,
AdaShelleyAddrUtils.decodeCred(addrDecBytes[0], 4));
return AddrDecUtils.validateAndRemovePrefixBytes(addrDecBytes, prefixByte);
}