util: make ParseMoney return a std::optional<CAmount>

This commit is contained in:
fanquake
2021-06-11 12:33:20 +08:00
parent 3308c61091
commit 5ef2738089
9 changed files with 119 additions and 140 deletions

View File

@ -188,10 +188,11 @@ static void RegisterLoad(const std::string& strInput)
static CAmount ExtractAndValidateValue(const std::string& strValue)
{
CAmount value;
if (!ParseMoney(strValue, value))
if (std::optional<CAmount> parsed = ParseMoney(strValue)) {
return parsed.value();
} else {
throw std::runtime_error("invalid TX output value");
return value;
}
}
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)