Page MenuHomePhabricator

[refactor] replace duplicated AmountFromValue function with Amount::Amount(UniValue T)
AbandonedPublic

Authored by majcosta on Jun 6 2021, 06:01.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Summary

The AmountFromValue function is defined twice, one of which is only used in bitcoin-tx, once.

The difference between them is that in rpc/util.cpp it throws a UniValue and the bitcoin-tx version throws a std::runtime_error. This deduplicates the code and makes it into a user-defined conversion on the Amount class which throws 'UniValue' as that was the one most used.

Tests are updated to conform to the simpler syntax.
Added a catch block in bitcoin-tx to handle possible UniValue throw there.

Test Plan
ninja all check-all
cmake .. -GNinja -DENABLE_SANITIZERS='undefined,address,fuzzer' -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
ninja bitcoin-fuzzers && ./src/test/fuzz/parse_univalue

Diff Detail