decodeAddr method
Decodes a given blockchain address string.
Throws AddressConverterException on invalid input.
Implementation
@override
BuBytes decodeAddr(String addr, {String? hrp}) {
hrp = AddrKeyValidator.getAddrArg<String>(hrp, "hrp");
final decode = SegwitBech32Decoder.decode(hrp, addr);
final witVerGot = decode.$1;
final addrDecBytes = decode.$2;
AddrDecUtils.validateBytesLength(
addrDecBytes,
EcdsaKeysConst.pubKeyCompressedByteLen - 1,
);
if (witVerGot != P2TRConst.witnessVer) {
throw CoreErrors.addressValidationFailed(
reason: "Invalid address witness version.",
);
}
return addrDecBytes;
}