Browse Source

show UTXOs in address tab

283
ThomasV 9 years ago
parent
commit
18a2498b76
  1. 32
      gui/qt/main_window.py
  2. 33
      lib/wallet.py

32
gui/qt/main_window.py

@ -1498,7 +1498,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return w
def create_addresses_tab(self):
l = MyTreeWidget(self, self.create_receive_menu, [ _('Address'), _('Label'), _('Balance'), _('Tx')], 1)
l = MyTreeWidget(self, self.create_address_menu, [ _('Address'), _('Label'), _('Balance'), _('Tx')], 1)
l.setSelectionMode(QAbstractItemView.ExtendedSelection)
l.on_update = self.update_address_tab
self.address_list = l
@ -1560,7 +1560,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
menu.addAction(_("View details"), lambda: self.show_account_details(k))
menu.exec_(self.address_list.viewport().mapToGlobal(position))
def create_receive_menu(self, position):
def create_address_menu(self, position):
selected = self.address_list.selectedItems()
multi_select = len(selected) > 1
addrs = [unicode(item.text(0)) for item in selected]
@ -1576,7 +1576,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
else:
item.setExpanded(not item.isExpanded())
return
menu = QMenu()
if not multi_select:
menu.addAction(_("Copy to clipboard"), lambda: self.app.clipboard().setText(addr))
@ -1799,23 +1798,32 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
label = self.wallet.labels.get(address,'')
c, u, x = self.wallet.get_addr_balance(address)
balance = self.format_amount(c + u + x)
item = QTreeWidgetItem([address, label, balance, "%d"%num])
item.setFont(0, QFont(MONOSPACE_FONT))
item.setData(0, Qt.UserRole, address)
item.setData(0, Qt.UserRole+1, True) # label can be edited
address_item = QTreeWidgetItem([address, label, balance, "%d"%num])
address_item.setFont(0, QFont(MONOSPACE_FONT))
address_item.setData(0, Qt.UserRole, address)
address_item.setData(0, Qt.UserRole+1, True) # label can be edited
if self.wallet.is_frozen(address):
item.setBackgroundColor(0, QColor('lightblue'))
address_item.setBackgroundColor(0, QColor('lightblue'))
if self.wallet.is_beyond_limit(address, account, is_change):
item.setBackgroundColor(0, QColor('red'))
address_item.setBackgroundColor(0, QColor('red'))
if is_used:
if not used_flag:
seq_item.insertChild(0, used_item)
used_flag = True
used_item.addChild(item)
used_item.addChild(address_item)
else:
seq_item.addChild(item)
seq_item.addChild(address_item)
if address == current_address:
l.setCurrentItem(item)
l.setCurrentItem(address_item)
# add utxos
utxos = self.wallet.get_addr_utxo(address)
for x in utxos:
h = x.get('prevout_hash')
s = h + ":%d"%x.get('prevout_n')
label = self.wallet.get_label(h)
utxo_item = QTreeWidgetItem([s, label, self.format_amount(x['value'])])
utxo_item.setFont(0, QFont(MONOSPACE_FONT))
address_item.addChild(utxo_item)
def update_contacts_tab(self):

33
lib/wallet.py

@ -612,7 +612,20 @@ class Abstract_Wallet(PrintError):
coins, spent = self.get_addr_io(address)
for txi in spent:
coins.pop(txi)
return coins
out = []
for txo, v in coins.items():
tx_height, value, is_cb = v
prevout_hash, prevout_n = txo.split(':')
x = {
'address':address,
'value':value,
'prevout_n':int(prevout_n),
'prevout_hash':prevout_hash,
'height':tx_height,
'coinbase':is_cb
}
out.append(x)
return out
# return the total amount ever received by an address
def get_addr_received(self, address):
@ -645,21 +658,11 @@ class Abstract_Wallet(PrintError):
if exclude_frozen:
domain = set(domain) - self.frozen_addresses
for addr in domain:
c = self.get_addr_utxo(addr)
for txo, v in c.items():
tx_height, value, is_cb = v
if is_cb and tx_height + COINBASE_MATURITY > self.get_local_height():
utxos = self.get_addr_utxo(addr)
for x in utxos:
if x['coinbase'] and x['tx_height'] + COINBASE_MATURITY > self.get_local_height():
continue
prevout_hash, prevout_n = txo.split(':')
output = {
'address':addr,
'value':value,
'prevout_n':int(prevout_n),
'prevout_hash':prevout_hash,
'height':tx_height,
'coinbase':is_cb
}
coins.append(output)
coins.append(x)
continue
return coins

Loading…
Cancel
Save