electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 4524c107cf867eec17c1d1f2cd51d872ca79914f
parent 2c0814f0d38aa97f84623267fba9860d79c453ed
Author: ThomasV <thomasv@gitorious>
Date:   Tue, 24 Sep 2013 16:55:25 +0200

add account menus and details window

Diffstat:
Mgui/qt/main_window.py | 59++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mgui/qt/transaction_dialog.py | 2+-
Micons.qrc | 1+
Mlib/wallet.py | 14++++++++++++++
4 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1034,6 +1034,22 @@ class ElectrumWindow(QMainWindow): self.update_receive_tab() self.update_history_tab() + def edit_account_label(self, k): + text, ok = QInputDialog.getText(self, _('Rename account'), _('Name') + ':') + if ok: + label = unicode(text) + self.set_label(k,label) + self.update_receive_tab() + + def create_account_menu(self, position, k, item): + menu = QMenu() + if item.isExpanded(): + menu.addAction(_("Reduce"), lambda: item.setExpanded(False)) + else: + menu.addAction(_("Expand"), lambda: item.setExpanded(True)) + menu.addAction(_("Rename"), lambda: self.edit_account_label(k)) + menu.addAction(_("View details"), lambda: self.show_account_details(k)) + menu.exec_(self.receive_list.viewport().mapToGlobal(position)) def create_receive_menu(self, position): # fixme: this function apparently has a side effect. @@ -1042,10 +1058,16 @@ class ElectrumWindow(QMainWindow): item = self.receive_list.itemAt(position) if not item: return + addr = unicode(item.text(0)) if not is_valid(addr): - item.setExpanded(not item.isExpanded()) + k = str(item.data(0,32).toString()) + if k: + self.create_account_menu(position, k, item) + else: + item.setExpanded(not item.isExpanded()) return + menu = QMenu() menu.addAction(_("Copy to clipboard"), lambda: self.app.clipboard().setText(addr)) menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")) ) @@ -1144,6 +1166,11 @@ class ElectrumWindow(QMainWindow): account_item = QTreeWidgetItem( [ name, '', self.format_amount(c+u), ''] ) l.addTopLevelItem(account_item) account_item.setExpanded(True) + account_item.setData(0, 32, k) + + if not self.wallet.is_seeded(k): + icon = QIcon(":icons/key.png") + account_item.setIcon(0, icon) for is_change in ([0,1] if self.expert_mode else [0]): if self.expert_mode: @@ -1965,3 +1992,33 @@ class ElectrumWindow(QMainWindow): vbox.addLayout(close_button(d)) d.exec_() + + + def show_account_details(self, k): + d = QDialog(self) + d.setWindowTitle(_('Account Details')) + d.setModal(1) + + vbox = QVBoxLayout(d) + roots = self.wallet.get_roots(k) + + name = self.wallet.get_account_name(k) + label = QLabel('Name: ' + name) + vbox.addWidget(label) + + acctype = '2 of 2' if len(roots) == 2 else '2 of 3' if len(roots) == 3 else 'Single key' + vbox.addWidget(QLabel('Type: ' + acctype)) + + label = QLabel('Derivation: ' + k) + vbox.addWidget(label) + + #for root in roots: + # mpk = self.wallet.master_public_keys[root] + # text = QTextEdit() + # text.setReadOnly(True) + # text.setMaximumHeight(120) + # text.setText(repr(mpk)) + # vbox.addWidget(text) + + vbox.addLayout(close_button(d)) + d.exec_() diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py @@ -34,7 +34,7 @@ from PyQt4.QtCore import * import PyQt4.QtCore as QtCore from electrum import transaction -from qt_util import MyTreeWidget +from util import MyTreeWidget class TxDialog(QDialog): diff --git a/icons.qrc b/icons.qrc @@ -7,6 +7,7 @@ <file>icons/clock4.png</file> <file>icons/clock5.png</file> <file>icons/confirmed.png</file> + <file>icons/key.png</file> <file>icons/lock.png</file> <file>icons/unlock.png</file> <file>icons/preferences.png</file> diff --git a/lib/wallet.py b/lib/wallet.py @@ -491,6 +491,20 @@ class Wallet: raise BaseException("Address not found", address) + def get_roots(self, account): + roots = [] + for a in account.split('&'): + s = a.strip() + m = re.match("(m/\d+'/)(\d+)", s) + roots.append( m.group(1) ) + return roots + + def is_seeded(self, account): + for root in self.get_roots(account): + if root not in self.master_private_keys.keys(): + return False + return True + def rebase_sequence(self, account, sequence): c, i = sequence dd = []