HomePhabricator

[electrum] don't use magic values for decimal_point and num_zeros

Description

[electrum] don't use magic values for decimal_point and num_zeros

Summary:
The pattern self.config.get("decimal_point", 2) is repeated a lot in the codebase, and this is error prone. A typo in the config key will not raise any error, and the default value is repeated everywhere.

Add two getters in SimpleConfig to centralize the keys and default values.

Also remove the defensive int(...) conversion that was done inconsistently. The values are always stored as numbers in the json file for as long as I remember. If something corupts the config file, it is unlikely that the int conversion will not raise an error (the only thing it could handle is a proper string representation, e.g. "2")

Test Plan: run ./electrum-abc and cehck that all displayed amounts are correct based on the base unit selected in the menu

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
PiRKAuthored on Mon, Nov 24, 15:01
PiRKPushed on Tue, Nov 25, 07:34
Reviewer
Restricted Project
Differential Revision
D18988: [electrum] don't use magic values for decimal_point and num_zeros
Parents
rABC8aafa64105bd: [Chronik] Add `WsSubTxs` subscription
Branches
Unknown
Tags
Unknown