HomePhabricator

univalue: Remove confusing getBool method

Description

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

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16291

Details

Provenance
Ryan Ofsky <ryan@ofsky.org>Authored on Sep 30 2022, 13:05
FabienCommitted on Jun 6 2024, 09:26
FabienPushed on Jun 6 2024, 09:26
Reviewer
Restricted Project
Differential Revision
D16291: univalue: Remove confusing getBool method
Parents
rABC5fa3c03af21b: rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR
Branches
Unknown
Tags
Unknown