diff --git a/src/rest.cpp b/src/rest.cpp index 185508d2c9e2f..3cf6ad343c8c5 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -788,15 +788,17 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std:: for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++) { - std::string strTxid = uriParts[i].substr(0, uriParts[i].find('-')); - std::string strOutput = uriParts[i].substr(uriParts[i].find('-')+1); - auto output{ToIntegral(strOutput)}; + const auto txid_out{util::Split(uriParts[i], '-')}; + if (txid_out.size() != 2) { + return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); + } + auto output{ToIntegral(txid_out.at(1))}; - if (!output || !IsHex(strTxid)) { + if (!output || !IsHex(txid_out.at(0))) { return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); } - vOutPoints.emplace_back(TxidFromString(strTxid), *output); + vOutPoints.emplace_back(TxidFromString(txid_out.at(0)), *output); } if (vOutPoints.size() > 0)