electrum

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

commit 0693403358656f1e7d5453679f125ab48d7fb644
parent f02d18226bdf7f9463824e74c411ed9d113fc130
Author: Dmitry Sorokin <asfins@gmail.com>
Date:   Sat,  4 Feb 2017 20:59:22 +0300

sending fixed

Diffstat:
Mgui/qt/main_window.py | 28++++++++--------------------
Mgui/qt/paytoedit.py | 5++---
Mgui/qt/utxo_list.py | 6------
Mlib/coinchooser.py | 9++++++---
Mlib/commands.py | 4++--
Mlib/keystore.py | 4++--
Mlib/transaction.py | 2+-
Mlib/wallet.py | 2+-
8 files changed, 22 insertions(+), 38 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -22,12 +22,6 @@ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -import six import sys, time, threading import os, json, traceback import shutil @@ -44,6 +38,7 @@ from PyQt4.QtGui import * from PyQt4.QtCore import * import PyQt4.QtCore as QtCore +from lib.util import bh2u, bfh from . import icons_rc from electrum import keystore @@ -850,7 +845,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): if req.get('exp'): URI += "&exp=%d"%req.get('exp') if req.get('name') and req.get('sig'): - sig = req.get('sig').decode('hex') + sig = bfh(req.get('sig')) sig = bitcoin.base_encode(sig, base=58) URI += "&name=" + req['name'] + "&sig="+sig return str(URI) @@ -876,7 +871,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): else: return - def save_payment_request(self): addr = str(self.receive_address_e.text()) amount = self.receive_amount_e.get_amount() @@ -952,7 +946,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.expires_combo.show() def toggle_qr_window(self): - import qrwindow + from . import qrwindow if not self.qr_window: self.qr_window = qrwindow.QR_Window(self) self.qr_window.setVisible(True) @@ -1646,7 +1640,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.contact_list.update() self.update_completions() - def show_invoice(self, key): pr = self.invoices.get(key) pr.verify(self.contacts) @@ -1723,8 +1716,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): console.updateNamespace(methods) - - def create_status_bar(self): sb = QStatusBar() @@ -1761,7 +1752,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.send_button.setVisible(not self.wallet.is_watching_only()) def change_password_dialog(self): - from password_dialog import ChangePasswordDialog + from .password_dialog import ChangePasswordDialog d = ChangePasswordDialog(self, self.wallet) ok, password, new_password, encrypt_file = d.run() if not ok: @@ -1823,9 +1814,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): if len(mpk_list) > 1: def label(key): if isinstance(self.wallet, Multisig_Wallet): - return _("cosigner") + ' ' + str(i+1) + return _("cosigner") + ' ' + str(key+1) return '' - labels = [ label(i) for i in range(len(mpk_list))] + labels = [label(i) for i in range(len(mpk_list))] on_click = lambda clayout: show_mpk(clayout.selected_index()) labels_clayout = ChoicesLayout(_("Master Public Keys"), labels, on_click) vbox.addLayout(labels_clayout.layout()) @@ -1900,6 +1891,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.show_message('Address not in wallet.') return task = partial(self.wallet.sign_message, address, message, password) + def show_signed_message(sig): signature.setText(base64.b64encode(sig).decode('ascii')) self.wallet.thread.add(task, on_success=show_signed_message) @@ -2049,7 +2041,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): # transactions are binary, but qrcode seems to return utf8... data = data.decode('utf8') z = bitcoin.base_decode(data, length=None, base=43) - data = ''.join(chr(ord(b)) for b in z).encode('hex') + data = bh2u(''.join(chr(ord(b)) for b in z)) tx = self.tx_from_text(data) if not tx: return @@ -2165,7 +2157,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.show_message(_("Private keys exported.")) - def do_export_privkeys(self, fileName, pklist, is_csv): with open(fileName, "w+") as f: if is_csv: @@ -2177,7 +2168,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): import json f.write(json.dumps(pklist, indent = 4)) - def do_import_labels(self): labelsFile = self.getOpenFileName(_("Open labels file"), "*.json") if not labelsFile: return @@ -2204,7 +2194,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): except (IOError, os.error) as reason: self.show_critical(_("Electrum was unable to export your labels.") + "\n" + str(reason)) - def export_history_dialog(self): d = WindowModalDialog(self, _('Export History')) d.setMinimumSize(400, 200) @@ -2279,7 +2268,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): import json f.write(json.dumps(lines, indent = 4)) - def sweep_key_dialog(self): d = WindowModalDialog(self, title=_('Sweep private keys')) d.setMinimumSize(600, 300) diff --git a/gui/qt/paytoedit.py b/gui/qt/paytoedit.py @@ -249,19 +249,18 @@ class PayToEdit(ScanQRTextEdit): hasModifier = (e.modifiers() != Qt.NoModifier) and not ctrlOrShift completionPrefix = self.textUnderCursor() - if hasModifier or not e.text() or completionPrefix.length() < 1 or eow.contains(e.text().right(1)): + if hasModifier or not e.text() or len(completionPrefix) < 1 or eow.find(e.text()[-1]) >= 0: self.c.popup().hide() return if completionPrefix != self.c.completionPrefix(): - self.c.setCompletionPrefix(completionPrefix); + self.c.setCompletionPrefix(completionPrefix) self.c.popup().setCurrentIndex(self.c.completionModel().index(0, 0)) cr = self.cursorRect() cr.setWidth(self.c.popup().sizeHintForColumn(0) + self.c.popup().verticalScrollBar().sizeHint().width()) self.c.complete(cr) - def qr_input(self): data = super(PayToEdit,self).qr_input() if data.startswith("bitcoin:"): diff --git a/gui/qt/utxo_list.py b/gui/qt/utxo_list.py @@ -22,12 +22,6 @@ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -import six from .util import * from electrum.i18n import _ from electrum.bitcoin import is_address diff --git a/lib/coinchooser.py b/lib/coinchooser.py @@ -102,7 +102,7 @@ class CoinChooserBase(PrintError): value = sum(coin['value'] for coin in coins) return Bucket(desc, size, value, coins) - return map(make_Bucket, buckets.keys(), buckets.values()) + return list(map(make_Bucket, buckets.keys(), buckets.values())) def penalty_func(self, tx): def penalty(candidate): @@ -128,7 +128,7 @@ class CoinChooserBase(PrintError): s = str(val) return len(s) - len(s.rstrip('0')) - zeroes = map(trailing_zeroes, output_amounts) + zeroes = [trailing_zeroes(i) for i in output_amounts] min_zeroes = min(zeroes) max_zeroes = max(zeroes) zeroes = range(max(0, min_zeroes - 1), (max_zeroes + 1) + 1) @@ -137,7 +137,7 @@ class CoinChooserBase(PrintError): remaining = change_amount amounts = [] while n > 1: - average = remaining // n + average = remaining / n amount = self.p.randint(int(average * 0.7), int(average * 1.3)) precision = min(self.p.choice(zeroes), int(floor(log10(amount)))) amount = int(round(amount, -precision)) @@ -214,6 +214,9 @@ class CoinChooserBase(PrintError): return tx + def choose_buckets(self, buckets, sufficient_funds, penalty_func): + raise NotImplemented('To be subclassed') + class CoinChooserOldestFirst(CoinChooserBase): '''Maximize transaction priority. Select the oldest unspent transaction outputs in your wallet, that are sufficient to cover diff --git a/lib/commands.py b/lib/commands.py @@ -602,8 +602,8 @@ class Commands: else: f = None if f is not None: - out = filter(lambda x: x.get('status')==f, out) - return map(self._format_request, out) + out = list(filter(lambda x: x.get('status')==f, out)) + return list(map(self._format_request, out)) @command('w') def getunusedaddress(self,force=False): diff --git a/lib/keystore.py b/lib/keystore.py @@ -57,7 +57,7 @@ class KeyStore(PrintError): if num_sig is None: continue x_signatures = txin['signatures'] - signatures = filter(None, x_signatures) + signatures = [sig for sig in x_signatures if sig] if len(signatures) == num_sig: # input is complete continue @@ -667,7 +667,7 @@ def is_address_list(text): def get_private_keys(text): parts = text.split('\n') parts = map(lambda x: ''.join(x.split()), parts) - parts = filter(bool, parts) + parts = list(filter(bool, parts)) if bool(parts) and all(bitcoin.is_private_key(x) for x in parts): return parts diff --git a/lib/transaction.py b/lib/transaction.py @@ -814,7 +814,7 @@ class Transaction: num = txin['num_sig'] pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin) for j, x_pubkey in enumerate(x_pubkeys): - signatures = filter(None, txin['signatures']) + signatures = list(filter(None, txin['signatures'])) if len(signatures) == num: # txin is complete break diff --git a/lib/wallet.py b/lib/wallet.py @@ -1028,7 +1028,7 @@ class Abstract_Wallet(PrintError): txin['signatures'] = [None] * len(txin['signatures']) self.add_input_info(txin) # use own outputs - s = filter(lambda x: self.is_mine(x[1]), outputs) + s = list(filter(lambda x: self.is_mine(x[1]), outputs)) # ... unless there is none if not s: s = outputs