Page MenuHomePhabricator

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

Authored by PiRK on Mon, Nov 24, 15:34.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
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

Event Timeline

PiRK requested review of this revision.Mon, Nov 24, 15:34
Fabien added a subscriber: Fabien.
Fabien added inline comments.
electrum/electrumabc/amount.py
156

I don't understand this max(). Unrelated to this diff though

This revision is now accepted and ready to land.Mon, Nov 24, 20:44