mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 08:21:27 +00:00
util.Satoshis: note that sometimes this actually has 'msat' precision
This commit is contained in:
parent
a6302b3a12
commit
0723355a0f
2 changed files with 5 additions and 2 deletions
|
@ -208,13 +208,15 @@ class Satoshis(object):
|
||||||
|
|
||||||
def __new__(cls, value):
|
def __new__(cls, value):
|
||||||
self = super(Satoshis, cls).__new__(cls)
|
self = super(Satoshis, cls).__new__(cls)
|
||||||
|
# note: 'value' sometimes has msat precision
|
||||||
self.value = value
|
self.value = value
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Satoshis(%d)'%self.value
|
return f'Satoshis({self.value})'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
# note: precision is truncated to satoshis here
|
||||||
return format_satoshis(self.value)
|
return format_satoshis(self.value)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
|
|
@ -765,6 +765,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
value += item['bc_value'].value
|
value += item['bc_value'].value
|
||||||
if item.get('ln_value'):
|
if item.get('ln_value'):
|
||||||
value += item.get('ln_value').value
|
value += item.get('ln_value').value
|
||||||
|
# note: 'value' and 'balance' has msat precision (as LN has msat precision)
|
||||||
item['value'] = Satoshis(value)
|
item['value'] = Satoshis(value)
|
||||||
balance += value
|
balance += value
|
||||||
item['balance'] = Satoshis(balance)
|
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
|
This class is actually a factory that will return a wallet of the correct
|
||||||
type when passed a WalletStorage instance."""
|
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')
|
wallet_type = db.get('wallet_type')
|
||||||
WalletClass = Wallet.wallet_class(wallet_type)
|
WalletClass = Wallet.wallet_class(wallet_type)
|
||||||
wallet = WalletClass(db, storage, config=config)
|
wallet = WalletClass(db, storage, config=config)
|
||||||
|
|
Loading…
Add table
Reference in a new issue