decodeAddr method

  1. @override
List<int> decodeAddr(
  1. String addr, {
  2. List<int>? netVersion,
  3. Base58Alphabets alphabet = Base58Alphabets.bitcoin,
})
override

Overrides the base class method to decode a P2PKH (Pay-to-Public-Key-Hash) address.

Implementation

@override
List<int> decodeAddr(
  String addr, {
  List<int>? netVersion,
  Base58Alphabets alphabet = Base58Alphabets.bitcoin,
}) {
  final List<int> netVarBytes = AddrKeyValidator.getAddrArg(
    netVersion,
    "netVersion",
  );

  /// Decode the address using the specified Base58 alphabet.
  final List<int> addrDecBytes = Base58Decoder.checkDecode(addr, alphabet);

  /// Validate the length of the decoded address and its network version.
  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    QuickCrypto.hash160DigestSize + netVarBytes.length,
  );

  /// Remove and validate the network version prefix bytes.
  return AddrDecUtils.validateAndRemovePrefixBytes(addrDecBytes, netVarBytes);
}