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

@@ -69,12 +69,11 @@ static std::string SwapBase64(const std::string& from)
static Binary DecodeI2PBase64(const std::string& i2p_b64)
{
const std::string& std_b64 = SwapBase64(i2p_b64);
bool invalid;
Binary decoded = DecodeBase64(std_b64, &invalid);
if (invalid) {
auto decoded = DecodeBase64(std_b64);
if (!decoded) {
throw std::runtime_error(strprintf("Cannot decode Base64: \"%s\"", i2p_b64));
}
return decoded;
return std::move(*decoded);
}
/**