diff --git a/src/script/sign.h b/src/script/sign.h index 7ade715ee..245b15410 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -188,6 +188,9 @@ template void SerializeHDKeypaths(Stream& s, const std::map>& hd_keypaths, uint8_t type) { for (auto keypath_pair : hd_keypaths) { + if (!keypath_pair.first.IsValid()) { + throw std::ios_base::failure("Invalid CPubKey being serialized"); + } SerializeToVector(s, type, MakeSpan(keypath_pair.first)); WriteCompactSize(s, keypath_pair.second.size() * sizeof(uint32_t)); for (auto& path : keypath_pair.second) {