Browse Source

sending fixed

seed_v14
Dmitry Sorokin 8 years ago
committed by ThomasV
parent
commit
0693403358
  1. 28
      gui/qt/main_window.py
  2. 5
      gui/qt/paytoedit.py
  3. 6
      gui/qt/utxo_list.py
  4. 9
      lib/coinchooser.py
  5. 4
      lib/commands.py
  6. 4
      lib/keystore.py
  7. 2
      lib/transaction.py
  8. 2
      lib/wallet.py

28
gui/qt/main_window.py

@ -22,12 +22,6 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # 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 sys, time, threading
import os, json, traceback import os, json, traceback
import shutil import shutil
@ -44,6 +38,7 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore import PyQt4.QtCore as QtCore
from lib.util import bh2u, bfh
from . import icons_rc from . import icons_rc
from electrum import keystore from electrum import keystore
@ -850,7 +845,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if req.get('exp'): if req.get('exp'):
URI += "&exp=%d"%req.get('exp') URI += "&exp=%d"%req.get('exp')
if req.get('name') and req.get('sig'): 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) sig = bitcoin.base_encode(sig, base=58)
URI += "&name=" + req['name'] + "&sig="+sig URI += "&name=" + req['name'] + "&sig="+sig
return str(URI) return str(URI)
@ -876,7 +871,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
else: else:
return return
def save_payment_request(self): def save_payment_request(self):
addr = str(self.receive_address_e.text()) addr = str(self.receive_address_e.text())
amount = self.receive_amount_e.get_amount() amount = self.receive_amount_e.get_amount()
@ -952,7 +946,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.expires_combo.show() self.expires_combo.show()
def toggle_qr_window(self): def toggle_qr_window(self):
import qrwindow from . import qrwindow
if not self.qr_window: if not self.qr_window:
self.qr_window = qrwindow.QR_Window(self) self.qr_window = qrwindow.QR_Window(self)
self.qr_window.setVisible(True) self.qr_window.setVisible(True)
@ -1646,7 +1640,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.contact_list.update() self.contact_list.update()
self.update_completions() self.update_completions()
def show_invoice(self, key): def show_invoice(self, key):
pr = self.invoices.get(key) pr = self.invoices.get(key)
pr.verify(self.contacts) pr.verify(self.contacts)
@ -1723,8 +1716,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
console.updateNamespace(methods) console.updateNamespace(methods)
def create_status_bar(self): def create_status_bar(self):
sb = QStatusBar() sb = QStatusBar()
@ -1761,7 +1752,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.send_button.setVisible(not self.wallet.is_watching_only()) self.send_button.setVisible(not self.wallet.is_watching_only())
def change_password_dialog(self): def change_password_dialog(self):
from password_dialog import ChangePasswordDialog from .password_dialog import ChangePasswordDialog
d = ChangePasswordDialog(self, self.wallet) d = ChangePasswordDialog(self, self.wallet)
ok, password, new_password, encrypt_file = d.run() ok, password, new_password, encrypt_file = d.run()
if not ok: if not ok:
@ -1823,9 +1814,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if len(mpk_list) > 1: if len(mpk_list) > 1:
def label(key): def label(key):
if isinstance(self.wallet, Multisig_Wallet): if isinstance(self.wallet, Multisig_Wallet):
return _("cosigner") + ' ' + str(i+1) return _("cosigner") + ' ' + str(key+1)
return '' 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()) on_click = lambda clayout: show_mpk(clayout.selected_index())
labels_clayout = ChoicesLayout(_("Master Public Keys"), labels, on_click) labels_clayout = ChoicesLayout(_("Master Public Keys"), labels, on_click)
vbox.addLayout(labels_clayout.layout()) vbox.addLayout(labels_clayout.layout())
@ -1900,6 +1891,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.show_message('Address not in wallet.') self.show_message('Address not in wallet.')
return return
task = partial(self.wallet.sign_message, address, message, password) task = partial(self.wallet.sign_message, address, message, password)
def show_signed_message(sig): def show_signed_message(sig):
signature.setText(base64.b64encode(sig).decode('ascii')) signature.setText(base64.b64encode(sig).decode('ascii'))
self.wallet.thread.add(task, on_success=show_signed_message) 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... # transactions are binary, but qrcode seems to return utf8...
data = data.decode('utf8') data = data.decode('utf8')
z = bitcoin.base_decode(data, length=None, base=43) 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) tx = self.tx_from_text(data)
if not tx: if not tx:
return return
@ -2165,7 +2157,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.show_message(_("Private keys exported.")) self.show_message(_("Private keys exported."))
def do_export_privkeys(self, fileName, pklist, is_csv): def do_export_privkeys(self, fileName, pklist, is_csv):
with open(fileName, "w+") as f: with open(fileName, "w+") as f:
if is_csv: if is_csv:
@ -2177,7 +2168,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
import json import json
f.write(json.dumps(pklist, indent = 4)) f.write(json.dumps(pklist, indent = 4))
def do_import_labels(self): def do_import_labels(self):
labelsFile = self.getOpenFileName(_("Open labels file"), "*.json") labelsFile = self.getOpenFileName(_("Open labels file"), "*.json")
if not labelsFile: return if not labelsFile: return
@ -2204,7 +2194,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
except (IOError, os.error) as reason: except (IOError, os.error) as reason:
self.show_critical(_("Electrum was unable to export your labels.") + "\n" + str(reason)) self.show_critical(_("Electrum was unable to export your labels.") + "\n" + str(reason))
def export_history_dialog(self): def export_history_dialog(self):
d = WindowModalDialog(self, _('Export History')) d = WindowModalDialog(self, _('Export History'))
d.setMinimumSize(400, 200) d.setMinimumSize(400, 200)
@ -2279,7 +2268,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
import json import json
f.write(json.dumps(lines, indent = 4)) f.write(json.dumps(lines, indent = 4))
def sweep_key_dialog(self): def sweep_key_dialog(self):
d = WindowModalDialog(self, title=_('Sweep private keys')) d = WindowModalDialog(self, title=_('Sweep private keys'))
d.setMinimumSize(600, 300) d.setMinimumSize(600, 300)

5
gui/qt/paytoedit.py

@ -249,19 +249,18 @@ class PayToEdit(ScanQRTextEdit):
hasModifier = (e.modifiers() != Qt.NoModifier) and not ctrlOrShift hasModifier = (e.modifiers() != Qt.NoModifier) and not ctrlOrShift
completionPrefix = self.textUnderCursor() 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() self.c.popup().hide()
return return
if completionPrefix != self.c.completionPrefix(): if completionPrefix != self.c.completionPrefix():
self.c.setCompletionPrefix(completionPrefix); self.c.setCompletionPrefix(completionPrefix)
self.c.popup().setCurrentIndex(self.c.completionModel().index(0, 0)) self.c.popup().setCurrentIndex(self.c.completionModel().index(0, 0))
cr = self.cursorRect() cr = self.cursorRect()
cr.setWidth(self.c.popup().sizeHintForColumn(0) + self.c.popup().verticalScrollBar().sizeHint().width()) cr.setWidth(self.c.popup().sizeHintForColumn(0) + self.c.popup().verticalScrollBar().sizeHint().width())
self.c.complete(cr) self.c.complete(cr)
def qr_input(self): def qr_input(self):
data = super(PayToEdit,self).qr_input() data = super(PayToEdit,self).qr_input()
if data.startswith("bitcoin:"): if data.startswith("bitcoin:"):

6
gui/qt/utxo_list.py

@ -22,12 +22,6 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # 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 .util import *
from electrum.i18n import _ from electrum.i18n import _
from electrum.bitcoin import is_address from electrum.bitcoin import is_address

9
lib/coinchooser.py

@ -102,7 +102,7 @@ class CoinChooserBase(PrintError):
value = sum(coin['value'] for coin in coins) value = sum(coin['value'] for coin in coins)
return Bucket(desc, size, value, 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_func(self, tx):
def penalty(candidate): def penalty(candidate):
@ -128,7 +128,7 @@ class CoinChooserBase(PrintError):
s = str(val) s = str(val)
return len(s) - len(s.rstrip('0')) 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) min_zeroes = min(zeroes)
max_zeroes = max(zeroes) max_zeroes = max(zeroes)
zeroes = range(max(0, min_zeroes - 1), (max_zeroes + 1) + 1) zeroes = range(max(0, min_zeroes - 1), (max_zeroes + 1) + 1)
@ -137,7 +137,7 @@ class CoinChooserBase(PrintError):
remaining = change_amount remaining = change_amount
amounts = [] amounts = []
while n > 1: while n > 1:
average = remaining // n average = remaining / n
amount = self.p.randint(int(average * 0.7), int(average * 1.3)) amount = self.p.randint(int(average * 0.7), int(average * 1.3))
precision = min(self.p.choice(zeroes), int(floor(log10(amount)))) precision = min(self.p.choice(zeroes), int(floor(log10(amount))))
amount = int(round(amount, -precision)) amount = int(round(amount, -precision))
@ -214,6 +214,9 @@ class CoinChooserBase(PrintError):
return tx return tx
def choose_buckets(self, buckets, sufficient_funds, penalty_func):
raise NotImplemented('To be subclassed')
class CoinChooserOldestFirst(CoinChooserBase): class CoinChooserOldestFirst(CoinChooserBase):
'''Maximize transaction priority. Select the oldest unspent '''Maximize transaction priority. Select the oldest unspent
transaction outputs in your wallet, that are sufficient to cover transaction outputs in your wallet, that are sufficient to cover

4
lib/commands.py

@ -602,8 +602,8 @@ class Commands:
else: else:
f = None f = None
if f is not None: if f is not None:
out = filter(lambda x: x.get('status')==f, out) out = list(filter(lambda x: x.get('status')==f, out))
return map(self._format_request, out) return list(map(self._format_request, out))
@command('w') @command('w')
def getunusedaddress(self,force=False): def getunusedaddress(self,force=False):

4
lib/keystore.py

@ -57,7 +57,7 @@ class KeyStore(PrintError):
if num_sig is None: if num_sig is None:
continue continue
x_signatures = txin['signatures'] x_signatures = txin['signatures']
signatures = filter(None, x_signatures) signatures = [sig for sig in x_signatures if sig]
if len(signatures) == num_sig: if len(signatures) == num_sig:
# input is complete # input is complete
continue continue
@ -667,7 +667,7 @@ def is_address_list(text):
def get_private_keys(text): def get_private_keys(text):
parts = text.split('\n') parts = text.split('\n')
parts = map(lambda x: ''.join(x.split()), parts) 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): if bool(parts) and all(bitcoin.is_private_key(x) for x in parts):
return parts return parts

2
lib/transaction.py

@ -814,7 +814,7 @@ class Transaction:
num = txin['num_sig'] num = txin['num_sig']
pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin) pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin)
for j, x_pubkey in enumerate(x_pubkeys): for j, x_pubkey in enumerate(x_pubkeys):
signatures = filter(None, txin['signatures']) signatures = list(filter(None, txin['signatures']))
if len(signatures) == num: if len(signatures) == num:
# txin is complete # txin is complete
break break

2
lib/wallet.py

@ -1028,7 +1028,7 @@ class Abstract_Wallet(PrintError):
txin['signatures'] = [None] * len(txin['signatures']) txin['signatures'] = [None] * len(txin['signatures'])
self.add_input_info(txin) self.add_input_info(txin)
# use own outputs # 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 # ... unless there is none
if not s: if not s:
s = outputs s = outputs

Loading…
Cancel
Save