encodeKey method

  1. @override
String encodeKey(
  1. List<int> pubKey, {
  2. List<int>? netVersion,
  3. Base58Alphabets alphabet = Base58Alphabets.bitcoin,
  4. CryptoKeyEncoding pubKeyMode = CryptoKeyEncoding.base,
})
override

Encodes a public key or address bytes into a blockchain address.

Throws AddressConverterException on invalid input.

Implementation

@override
String encodeKey(
  List<int> pubKey, {
  List<int>? netVersion,
  Base58Alphabets alphabet = Base58Alphabets.bitcoin,
  CryptoKeyEncoding pubKeyMode = CryptoKeyEncoding.base,
}) {
  final List<int> netVerBytes = AddrKeyValidator.getAddrArg(
    netVersion,
    "netVersion",
  );
  // Address bytes = network version prefix + pubkey hash160.
  return Base58Encoder.encodeWithChecksum([
    ...netVerBytes,
    ...validateAndHashKey(pubKey, pubKeyMode: pubKeyMode),
  ], alphabet);
}