tutil.Satoshis: note that sometimes this actually has 'msat' precision - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 0723355a0f90aca1e177bb615d44d678c79a73dc (DIR) parent a6302b3a124a2bc9a208e0e78ddcb81d53d6bdf9 (HTM) Author: SomberNight <somber.night@protonmail.com> Date: Mon, 17 Feb 2020 16:52:25 +0100 util.Satoshis: note that sometimes this actually has 'msat' precision Diffstat: M electrum/util.py | 4 +++- M electrum/wallet.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) --- (DIR) diff --git a/electrum/util.py b/electrum/util.py t@@ -208,13 +208,15 @@ class Satoshis(object): def __new__(cls, value): self = super(Satoshis, cls).__new__(cls) + # note: 'value' sometimes has msat precision self.value = value return self def __repr__(self): - return 'Satoshis(%d)'%self.value + return f'Satoshis({self.value})' def __str__(self): + # note: precision is truncated to satoshis here return format_satoshis(self.value) def __eq__(self, other): (DIR) diff --git a/electrum/wallet.py b/electrum/wallet.py t@@ -765,6 +765,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): value += item['bc_value'].value if item.get('ln_value'): value += item.get('ln_value').value + # note: 'value' and 'balance' has msat precision (as LN has msat precision) item['value'] = Satoshis(value) balance += value item['balance'] = Satoshis(balance) t@@ -2426,7 +2427,7 @@ class Wallet(object): This class is actually a factory that will return a wallet of the correct type when passed a WalletStorage instance.""" - def __new__(self, db, storage: WalletStorage, *, config: SimpleConfig): + def __new__(self, db: 'WalletDB', storage: Optional[WalletStorage], *, config: SimpleConfig): wallet_type = db.get('wallet_type') WalletClass = Wallet.wallet_class(wallet_type) wallet = WalletClass(db, storage, config=config)