Page MenuHomePhabricator

univalue: Remove confusing getBool method
ClosedPublic

Authored by Fabien on Jun 5 2024, 19:54.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC238a16e2413b: univalue: Remove confusing getBool method
Summary
Drop UniValue::getBool method because it is easy to confuse with the
UniValue::get_bool method, and could potentially cause bugs. Unlike get_bool,
getBool doesn't ensure that the value is a boolean and returns false for all
integer, string, array, and object values instead of throwing an exceptions.

The getBool method is also redundant because it is an alias for isTrue. There
were only 5 getBool() calls in the codebase, so this commit replaces them with
isTrue() or get_bool() calls as appropriate.

These changes were originally made by MarcoFalke in
https://github.com/bitcoin/bitcoin/pull/26213 but were dropped to limit the
scope of that PR.

Backport of core#26673.

Depends on D16290.

Test Plan
ninja all check-all