Browse Source

util.Satoshis: note that sometimes this actually has 'msat' precision

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
0723355a0f
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/util.py
  2. 3
      electrum/wallet.py

4
electrum/util.py

@ -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):

3
electrum/wallet.py

@ -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)
@ -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)

Loading…
Cancel
Save