diff options
author | fanquake <fanquake@gmail.com> | 2021-06-11 12:33:20 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2021-08-04 19:48:24 +0800 |
commit | 5ef2738089efd396186775ad23aaec71ea44ebb1 (patch) | |
tree | 78b1d357ae955c7481f6dee1d15217a7271b2ecd /src/bitcoin-tx.cpp | |
parent | 3308c61091b6b7cb22569f3abadea6d001295c90 (diff) |
util: make ParseMoney return a std::optional<CAmount>
Diffstat (limited to 'src/bitcoin-tx.cpp')
-rw-r--r-- | src/bitcoin-tx.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 3fc87ae1ff..cd2cdf01f2 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -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) |