encodeKey method

  1. @override
String encodeKey(
  1. List<int> pubKey, [
  2. Map<String, dynamic> kwargs = const {}
])
override

Encodes an Ada Byron address with the provided public key and chain code.

The pubKey parameter is the public key to be encoded. The optional kwargs parameter is a map of additional arguments, where "chain_code" can be set to specify the chain code.

Returns a string representing the encoded Ada Byron address.

Throws an ArgumentException if the provided chain code is invalid.

Implementation

@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
  List<int> chainCodeBytes;
  final chainCode = kwargs["chain_code"];
  if (chainCode is Bip32ChainCode) {
    chainCodeBytes = chainCode.toBytes();
  } else if (chainCode is List<int>) {
    chainCodeBytes = chainCode;
  } else {
    throw ArgumentException("invalid chaincode ");
  }
  final pubkeyBytes =
      AddrKeyValidator.validateAndGetEd25519Key(pubKey).compressed;

  return _AdaByronAddrUtils.encodeKey(
      pubkeyBytes, chainCodeBytes, AdaByronAddrTypes.publicKey);
}