trivial wallet clean-up
This commit is contained in:
@@ -745,13 +745,14 @@ class AddressSynchronizer(PrintError):
|
||||
return result
|
||||
|
||||
@with_local_height_cached
|
||||
def get_utxos(self, domain=None, excluded=None, mature=False, confirmed_only=False, nonlocal_only=False):
|
||||
def get_utxos(self, domain=None, *, excluded=None,
|
||||
mature_only: bool = False, confirmed_only: bool = False, nonlocal_only: bool = False):
|
||||
coins = []
|
||||
if domain is None:
|
||||
domain = self.get_addresses()
|
||||
domain = set(domain)
|
||||
if excluded:
|
||||
domain = set(domain) - excluded
|
||||
domain = set(domain) - set(excluded)
|
||||
for addr in domain:
|
||||
utxos = self.get_addr_utxo(addr)
|
||||
for x in utxos.values():
|
||||
@@ -759,7 +760,7 @@ class AddressSynchronizer(PrintError):
|
||||
continue
|
||||
if nonlocal_only and x['height'] == TX_HEIGHT_LOCAL:
|
||||
continue
|
||||
if mature and x['coinbase'] and x['height'] + COINBASE_MATURITY > self.get_local_height():
|
||||
if mature_only and x['coinbase'] and x['height'] + COINBASE_MATURITY > self.get_local_height():
|
||||
continue
|
||||
coins.append(x)
|
||||
continue
|
||||
|
||||
@@ -218,7 +218,7 @@ class AddressList(MyTreeView):
|
||||
else:
|
||||
menu.addAction(_("Unfreeze"), lambda: self.parent.set_frozen_state([addr], False))
|
||||
|
||||
coins = self.wallet.get_utxos(addrs)
|
||||
coins = self.wallet.get_spendable_coins(addrs, config=self.config)
|
||||
if coins:
|
||||
menu.addAction(_("Spend from"), lambda: self.parent.spend_coins(coins))
|
||||
|
||||
|
||||
@@ -1314,10 +1314,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||
if self.not_enough_funds:
|
||||
amt_color, fee_color = ColorScheme.RED, ColorScheme.RED
|
||||
feerate_color = ColorScheme.RED
|
||||
text = _( "Not enough funds" )
|
||||
text = _("Not enough funds")
|
||||
c, u, x = self.wallet.get_frozen_balance()
|
||||
if c+u+x:
|
||||
text += ' (' + self.format_amount(c+u+x).strip() + ' ' + self.base_unit() + ' ' +_("are frozen") + ')'
|
||||
text += " ({} {} {})".format(
|
||||
self.format_amount(c + u + x).strip(), self.base_unit(), _("are frozen")
|
||||
)
|
||||
|
||||
# blue color denotes auto-filled values
|
||||
elif self.fee_e.isModified():
|
||||
@@ -1850,7 +1852,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||
self.update_status()
|
||||
run_hook('do_clear', self)
|
||||
|
||||
def set_frozen_state(self, addrs, freeze):
|
||||
def set_frozen_state(self, addrs, freeze: bool):
|
||||
self.wallet.set_frozen_state(addrs, freeze)
|
||||
self.address_list.update()
|
||||
self.utxo_list.update()
|
||||
|
||||
@@ -397,7 +397,7 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||
confirmed_only = config.get('confirmed_only', False)
|
||||
return self.get_utxos(domain,
|
||||
excluded=self.frozen_addresses,
|
||||
mature=True,
|
||||
mature_only=True,
|
||||
confirmed_only=confirmed_only,
|
||||
nonlocal_only=nonlocal_only)
|
||||
|
||||
@@ -740,7 +740,7 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||
def is_frozen(self, addr):
|
||||
return addr in self.frozen_addresses
|
||||
|
||||
def set_frozen_state(self, addrs, freeze):
|
||||
def set_frozen_state(self, addrs, freeze: bool):
|
||||
'''Set frozen state of the addresses to FREEZE, True or False'''
|
||||
if all(self.is_mine(addr) for addr in addrs):
|
||||
if freeze:
|
||||
|
||||
Reference in New Issue
Block a user