decodeAddr method
Overrides the base class method to decode a P2TR (Pay-to-Taproot) address.
Implementation
@override
List<int> decodeAddr(String addr, {String? hrp}) {
hrp = AddrKeyValidator.getAddrArg<String>(hrp, "hrp");
/// Decode the Bech32-encoded P2TR address and validate its length.
final decode = SegwitBech32Decoder.decode(hrp, addr);
final witVerGot = decode.$1;
final addrDecBytes = decode.$2;
/// Validate the byte length of the decoded address.
AddrDecUtils.validateBytesLength(
addrDecBytes,
EcdsaKeysConst.pubKeyCompressedByteLen - 1,
);
/// Check the witness version.
if (witVerGot != P2TRConst.witnessVer) {
throw AddressConverterException.addressValidationFailed(
reason: "Invalid address checksum.",
);
}
/// Return the decoded P2TR address as a `List<int>`.
return addrDecBytes;
}