electrum

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

commit 8ca7964dac5232d218a51bc3f533260406eebb30
parent 7335a9936e080cb41e55d6f842ec42c80dcf96ef
Author: ThomasV <thomasv@gitorious>
Date:   Mon,  5 May 2014 09:58:29 +0200

address_field in sweep dialog

Diffstat:
Mgui/qt/main_window.py | 28+++++++++++++++++++++++-----
Mgui/qt/util.py | 21+++++++++++++++++++++
2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1905,9 +1905,12 @@ class ElectrumWindow(QMainWindow): private_keys = {} addresses = self.wallet.addresses(True) + done = False def privkeys_thread(): for addr in addresses: time.sleep(0.1) + if done: + break private_keys[addr] = "\n".join(self.wallet.get_private_key(addr, password)) d.emit(SIGNAL('computing_privkeys')) d.emit(SIGNAL('show_privkeys')) @@ -1922,6 +1925,7 @@ class ElectrumWindow(QMainWindow): threading.Thread(target=privkeys_thread).start() if not d.exec_(): + done = True return filename = filename_e.text() @@ -2028,6 +2032,7 @@ class ElectrumWindow(QMainWindow): def sweep_key_dialog(self): d = QDialog(self) d.setWindowTitle(_('Sweep private keys')) + d.setMinimumSize(600, 300) vbox = QVBoxLayout(d) vbox.addWidget(QLabel(_("Enter private keys"))) @@ -2035,20 +2040,33 @@ class ElectrumWindow(QMainWindow): keys_e = QTextEdit() keys_e.setTabChangesFocus(True) vbox.addWidget(keys_e) + + h, address_e = address_field(self.wallet.addresses()) + vbox.addLayout(h) + vbox.addStretch(1) hbox, button = ok_cancel_buttons2(d, _('Sweep')) vbox.addLayout(hbox) button.setEnabled(False) - keys_e.textChanged.connect(lambda: button.setEnabled(Wallet.is_private_key(str(keys_e.toPlainText()).strip()))) + def get_address(): + addr = str(address_e.text()) + if bitcoin.is_address(addr): + return addr + + def get_pk(): + pk = str(keys_e.toPlainText()).strip() + if Wallet.is_private_key(pk): + return pk.split() + + f = lambda: button.setEnabled(get_address() is not None and get_pk() is not None) + keys_e.textChanged.connect(f) + address_e.textChanged.connect(f) if not d.exec_(): return - text = str(keys_e.toPlainText()).strip() - privkeys = text.split() - to_address = self.wallet.addresses()[0] fee = self.wallet.fee - tx = Transaction.sweep(privkeys, self.network, to_address, fee) + tx = Transaction.sweep(get_pk(), self.network, get_address(), fee) self.show_transaction(tx) diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -78,6 +78,27 @@ def text_dialog(parent, title, label, ok_label, default=None): return unicode(txt.toPlainText()) + + +def address_field(addresses): + hbox = QHBoxLayout() + address_e = QLineEdit() + if addresses: + address_e.setText(addresses[0]) + def func(): + i = addresses.index(str(address_e.text())) + 1 + i = i % len(addresses) + address_e.setText(addresses[i]) + button = QPushButton(_('Address')) + button.clicked.connect(func) + hbox.addWidget(button) + hbox.addWidget(address_e) + return hbox, address_e + + + + + class MyTreeWidget(QTreeWidget): def __init__(self, parent): QTreeWidget.__init__(self, parent)