encodeKey method

  1. @override
String encodeKey(
  1. List<int> pubKey, {
  2. List<int>? netVersion,
  3. String? hrp,
})
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, String? hrp}) {
  hrp = AddrKeyValidator.getAddrArg<String>(hrp, "hrp");
  netVersion = AddrKeyValidator.getAddrArg<List<int>>(
    netVersion,
    "netVersion",
  );

  final IPublicKey pubKeyObj = AddrKeyValidator.validateAndGetSecp256k1Key(
    pubKey,
  );
  return BchBech32Encoder.encode(
    hrp,
    netVersion,
    _P2SHAddrUtils.addScriptSig(pubKeyObj),
  );
}