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