encodePrefix static method
List<int>
encodePrefix(
- ADAAddressType hdrType,
- int netTag,
- AdaStakeCredType credType, {
- AdaStakeCredType? stakeType,
Encodes the address prefix based on the header type and network tag. The prefix is a combination of the header type and network tag.
Parameters:
hdrType
: The header type used for encoding (e.g., payment or reward).netTag
: The network tag representing the network (e.g., mainnet or testnet).
Returns: A byte array representing the address prefix.
Implementation
static List<int> encodePrefix(
ADAAddressType hdrType, int netTag, AdaStakeCredType credType,
{AdaStakeCredType? stakeType}) {
int hdr = (hdrType.header << 4) | credType.value << 4;
if (hdrType == ADAAddressType.base && stakeType != null) {
hdr |= stakeType.value << 5;
}
hdr += netTag;
return IntUtils.toBytes(hdr,
length: IntUtils.bitlengthInBytes(hdr), byteOrder: Endian.little);
}