decodeAddr method
Decodes a given blockchain address string.
Throws AddressConverterException on invalid input.
Implementation
@override
BuBytes decodeAddr(String addr, {List<int>? netVersion, String? hrp}) {
hrp = AddrKeyValidator.getAddrArg<String>(hrp, "hrp");
netVersion = AddrKeyValidator.getAddrArg<List<int>>(
netVersion,
"netVersion",
);
final result = BchBech32Decoder.decode(hrp, addr);
final BuBytes netVerBytesGot = result.$1;
final BuBytes addrDecBytes = result.$2;
// Decoded network version must match the one requested.
if (!BytesUtils.bytesEqual(netVersion, netVerBytesGot)) {
throw CoreErrors.addressKeyValidationFailed(
reason: "Invalid address network version.",
);
}
AddrDecUtils.validateBytesLength(
addrDecBytes,
QuickCrypto.hash160DigestSize,
);
return addrDecBytes;
}