Make DecodeBase{32,64} return optional instead of taking bool*

This commit is contained in:
Pieter Wuille
2022-04-04 13:52:06 -04:00
committed by MacroFake
parent a65931e3ce
commit 78f3ac51b7
11 changed files with 57 additions and 77 deletions

View File

@@ -132,10 +132,10 @@ static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUserna
if (strAuth.substr(0, 6) != "Basic ")
return false;
std::string strUserPass64 = TrimString(strAuth.substr(6));
bool invalid;
std::vector<unsigned char> userpass_data = DecodeBase64(strUserPass64, &invalid);
if (invalid) return false;
std::string strUserPass(userpass_data.begin(), userpass_data.end());
auto userpass_data = DecodeBase64(strUserPass64);
std::string strUserPass;
if (!userpass_data) return false;
strUserPass.assign(userpass_data->begin(), userpass_data->end());
if (strUserPass.find(':') != std::string::npos)
strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(':'));