Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pooler committed Oct 23, 2017
2 parents cec5c02 + fe82a79 commit f0b28e2
Show file tree
Hide file tree
Showing 34 changed files with 293 additions and 207 deletions.
2 changes: 1 addition & 1 deletion contrib/build-wine/build-electrum-git.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# You probably need to update only this link
ELECTRUM_GIT_URL=git://github.com/pooler/electrum-ltc.git
ELECTRUM_GIT_URL=https://github.com/pooler/electrum-ltc.git
BRANCH=master
NAME_ROOT=electrum-ltc
PYTHON_VERSION=3.5.4
Expand Down
10 changes: 5 additions & 5 deletions contrib/build-wine/prepare-hw.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

TREZOR_GIT_URL=git://github.com/trezor/python-trezor.git
KEEPKEY_GIT_URL=git://github.com/keepkey/python-keepkey.git
BTCHIP_GIT_URL=git://github.com/LedgerHQ/btchip-python.git
TREZOR_GIT_URL=https://github.com/trezor/python-trezor.git
KEEPKEY_GIT_URL=https://github.com/keepkey/python-keepkey.git
BTCHIP_GIT_URL=https://github.com/LedgerHQ/btchip-python.git

BRANCH=master

Expand All @@ -20,8 +20,8 @@ set -e

cd tmp

# downoad mingw-get-setup.exe
#wget http://downloads.sourceforge.net/project/mingw/Installer/mingw-get-setup.exe
# download mingw-get-setup.exe
#wget https://downloads.sourceforge.net/project/mingw/Installer/mingw-get-setup.exe
#wine mingw-get-setup.exe

#echo "add c:\MinGW\bin to PATH using regedit" in HKEY_CURRENT_USER/Environment
Expand Down
41 changes: 36 additions & 5 deletions contrib/build-wine/prepare-wine.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

# Please update these carefully, some versions won't work under Wine
NSIS_URL=http://prdownloads.sourceforge.net/nsis/nsis-3.02.1-setup.exe?download
NSIS_URL=https://prdownloads.sourceforge.net/nsis/nsis-3.02.1-setup.exe?download
NSIS_SHA256=736c9062a02e297e335f82252e648a883171c98e0d5120439f538c81d429552e
PYTHON_VERSION=3.5.4

## These settings probably don't need change
Expand All @@ -11,6 +12,30 @@ export WINEPREFIX=/opt/wine64
PYHOME=c:/python$PYTHON_VERSION
PYTHON="wine $PYHOME/python.exe -OO -B"


# based on https://superuser.com/questions/497940/script-to-verify-a-signature-with-gpg
verify_signature() {
local file=$1 keyring=$2 out=
if out=$(gpg --no-default-keyring --keyring "$keyring" --status-fd 1 --verify "$file" 2>/dev/null) &&
echo "$out" | grep -qs "^\[GNUPG:\] VALIDSIG "; then
return 0
else
echo "$out" >&2
exit 0
fi
}

verify_hash() {
local file=$1 expected_hash=$2 out=
actual_hash=$(sha256sum $file | awk '{print $1}')
if [ "$actual_hash" == "$expected_hash" ]; then
return 0
else
echo "$file $actual_hash (unexpected hash)" >&2
exit 0
fi
}

# Let's begin!
cd `dirname $0`
set -e
Expand All @@ -30,9 +55,15 @@ echo "done"
cd tmp

# Install Python
# note: you might need "sudo apt-get install dirmngr" for the following
# keys from https://www.python.org/downloads/#pubkeys
KEYRING_PYTHON_DEV=keyring-electrum-build-python-dev.gpg
gpg --no-default-keyring --keyring $KEYRING_PYTHON_DEV --recv-keys 531F072D39700991925FED0C0EDDC5F26A45C816 26DEA9D4613391EF3E25C9FF0A5B101836580288 CBC547978A3964D14B9AB36A6AF053F07D9DC8D2 C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF 12EF3DC38047DA382D18A5B999CDEA9DA4135B38 8417157EDBE73D9EAC1E539B126EB563A74B06BF DBBF2EEBF925FAADCF1F3FFFD9866941EA5BBD71 2BA0DB82515BBB9EFFAC71C5C9BE28DEE6DF025C 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D C9B104B3DD3AA72D7CCB1066FB9921286F5E1540 97FC712E4C024BBEA48A61ED3A5CA953F73C700D 7ED10B6531D7C8E1BC296021FC624643487034E5
for msifile in core dev exe lib pip tools; do
echo "Installing $msifile..."
wget "https://www.python.org/ftp/python/$PYTHON_VERSION/win32/${msifile}.msi"
wget "https://www.python.org/ftp/python/$PYTHON_VERSION/win32/${msifile}.msi.asc"
verify_signature "${msifile}.msi.asc" $KEYRING_PYTHON_DEV
wine msiexec /i "${msifile}.msi" /qb TARGETDIR=C:/python$PYTHON_VERSION
done

Expand All @@ -49,7 +80,7 @@ $PYTHON -m pip install PyQt5
$PYTHON -m pip install pyinstaller==3.3

# Install ZBar
#wget -q -O zbar.exe "http://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download"
#wget -q -O zbar.exe "https://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download"
#wine zbar.exe

# install Cryptodome
Expand All @@ -70,12 +101,12 @@ $PYTHON -m pip install websocket-client
$PYTHON -m pip install setuptools --upgrade

# Install NSIS installer
echo "Make sure to untick 'Start NSIS' and 'Show release notes'"
wget -q -O nsis.exe "$NSIS_URL"
wine nsis.exe
verify_hash nsis.exe $NSIS_SHA256
wine nsis.exe /S

# Install UPX
#wget -O upx.zip "http://upx.sourceforge.net/download/upx308w.zip"
#wget -O upx.zip "https://downloads.sourceforge.net/project/upx/upx/3.08/upx308w.zip"
#unzip -o upx.zip
#cp upx*/upx.exe .

Expand Down
4 changes: 2 additions & 2 deletions contrib/make_locale
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ if crowdin_api_key:
requests.request('POST', url, files=files)
# Build translations
print('Build translations')
response = requests.request('GET', 'http://api.crowdin.com/api/project/' + crowdin_identifier + '/export?key=' + crowdin_api_key).content
response = requests.request('GET', 'https://api.crowdin.com/api/project/' + crowdin_identifier + '/export?key=' + crowdin_api_key).content
print(response)

# Download & unzip
print('Download translations')
s = requests.request('GET', 'http://crowdin.com/download/project/' + crowdin_identifier + '.zip').content
s = requests.request('GET', 'https://crowdin.com/download/project/' + crowdin_identifier + '.zip').content
zfobj = zipfile.ZipFile(io.BytesIO(s))

print('Unzip translations')
Expand Down
2 changes: 1 addition & 1 deletion electrum-ltc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def check_imports():
import google.protobuf
import jsonrpclib
except ImportError as e:
sys.exit("Error: %s. Try 'sudo pip install <module-name>'"%e.message)
sys.exit("Error: %s. Try 'sudo pip install <module-name>'"%str(e))
# the following imports are for pyinstaller
from google.protobuf import descriptor
from google.protobuf import message
Expand Down
7 changes: 4 additions & 3 deletions gui/kivy/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def toggle_auto_connect(self, x):
self.auto_connect = not self.auto_connect

def choose_server_dialog(self, popup):
from uix.dialogs.choice_dialog import ChoiceDialog
from .uix.dialogs.choice_dialog import ChoiceDialog
protocol = 's'
def cb2(host):
from electrum_ltc.network import DEFAULT_PORTS
Expand All @@ -104,7 +104,7 @@ def cb2(host):
ChoiceDialog(_('Choose a server'), sorted(servers), popup.ids.host.text, cb2).open()

def choose_blockchain_dialog(self, dt):
from uix.dialogs.choice_dialog import ChoiceDialog
from .uix.dialogs.choice_dialog import ChoiceDialog
chains = self.network.get_blockchains()
def cb(name):
for index, b in self.network.blockchains.items():
Expand Down Expand Up @@ -305,8 +305,9 @@ def on_qr(self, data):
return
# try to decode transaction
from electrum_ltc.transaction import Transaction
from electrum_ltc.util import bh2u
try:
text = base_decode(data, None, base=43).encode('hex')
text = bh2u(base_decode(data, None, base=43))
tx = Transaction(text)
tx.deserialize()
except:
Expand Down
9 changes: 4 additions & 5 deletions gui/kivy/uix/dialogs/fee_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def __init__(self, app, config, callback):
Factory.Popup.__init__(self)
self.app = app
self.config = config
self.fee_step = self.config.max_fee_rate() / 10
self.fee_rate = self.config.fee_per_kb()
self.callback = callback
self.dynfees = self.config.get('dynamic_fees', True)
Expand All @@ -77,9 +76,9 @@ def update_slider(self):
slider.step = 1
slider.value = self.config.get('fee_level', 2)
else:
slider.range = (1, 10)
slider.range = (0, 9)
slider.step = 1
slider.value = min(self.fee_rate / self.fee_step, 10)
slider.value = self.config.static_fee_index(self.fee_rate)

def get_fee_text(self, value):
if self.ids.dynfees.active:
Expand All @@ -88,7 +87,7 @@ def get_fee_text(self, value):
dynfee = self.config.dynfee(value)
tooltip += '\n' + (self.app.format_amount_and_units(dynfee)) + '/kB'
else:
fee_rate = value * self.fee_step
fee_rate = self.config.static_fee(value)
tooltip = self.app.format_amount_and_units(fee_rate) + '/kB'
if self.config.has_fee_estimates():
i = self.config.reverse_dynfee(fee_rate)
Expand All @@ -101,7 +100,7 @@ def on_ok(self):
if self.dynfees:
self.config.set_key('fee_level', value, True)
else:
self.config.set_key('fee_per_kb', value * self.fee_step, True)
self.config.set_key('fee_per_kb', self.config.static_fee(value), True)
self.callback()

def on_slider(self, value):
Expand Down
2 changes: 1 addition & 1 deletion gui/kivy/uix/dialogs/installwizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def do_share(self):
self.app.do_share(self.xpub, _("Master Public Key"))

def do_qr(self):
from qr_dialog import QRDialog
from .qr_dialog import QRDialog
popup = QRDialog(_("Master Public Key"), self.xpub, True)
popup.open()

Expand Down
8 changes: 4 additions & 4 deletions gui/kivy/uix/dialogs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def callback(popup):
self._proxy_dialog.open()

def plugin_dialog(self, name, label, dt):
from checkbox_dialog import CheckBoxDialog
from .checkbox_dialog import CheckBoxDialog
def callback(status):
self.plugins.enable(name) if status else self.plugins.disable(name)
label.status = 'ON' if status else 'OFF'
Expand All @@ -209,14 +209,14 @@ def fee_status(self):

def fee_dialog(self, label, dt):
if self._fee_dialog is None:
from fee_dialog import FeeDialog
from .fee_dialog import FeeDialog
def cb():
label.status = self.fee_status()
self._fee_dialog = FeeDialog(self.app, self.config, cb)
self._fee_dialog.open()

def boolean_dialog(self, name, title, message, dt):
from checkbox_dialog import CheckBoxDialog
from .checkbox_dialog import CheckBoxDialog
CheckBoxDialog(title, message, getattr(self.app, name), lambda x: setattr(self.app, name, x)).open()

def fx_status(self):
Expand All @@ -230,7 +230,7 @@ def fx_status(self):

def fx_dialog(self, label, dt):
if self._fx_dialog is None:
from fx_dialog import FxDialog
from .fx_dialog import FxDialog
def cb():
label.status = self.fx_status()
self._fx_dialog = FxDialog(self.app, self.plugins, self.config, cb)
Expand Down
6 changes: 3 additions & 3 deletions gui/kivy/uix/dialogs/tx_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def update(self):
self.ids.output_list.update(self.tx.outputs())

def do_rbf(self):
from bump_fee_dialog import BumpFeeDialog
from .bump_fee_dialog import BumpFeeDialog
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(self.tx)
size = self.tx.estimated_size()
d = BumpFeeDialog(self.app, fee, size, self._do_rbf)
Expand Down Expand Up @@ -171,7 +171,7 @@ def do_broadcast(self):
self.app.broadcast(self.tx)

def show_qr(self):
from electrum_ltc.bitcoin import base_encode
text = str(self.tx).decode('hex')
from electrum_ltc.bitcoin import base_encode, bfh
text = bfh(str(self.tx))
text = base_encode(text, base=43)
self.app.qr_dialog(_("Raw Transaction"), text)
10 changes: 6 additions & 4 deletions gui/kivy/uix/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def show_tx(self, obj):
self.app.tx_dialog(tx)

def label_dialog(self, obj):
from dialogs.label_dialog import LabelDialog
from .dialogs.label_dialog import LabelDialog
key = obj.tx_hash
text = self.app.wallet.get_label(key)
def callback(text):
Expand Down Expand Up @@ -264,7 +264,7 @@ def do_send(self):
message = self.screen.message
amount = sum(map(lambda x:x[2], outputs))
if self.app.electrum_config.get('use_rbf'):
from dialogs.question import Question
from .dialogs.question import Question
d = Question(_('Should this transaction be replaceable?'), lambda b: self._do_send(amount, message, outputs, b))
d.open()
else:
Expand Down Expand Up @@ -296,6 +296,8 @@ def _do_send(self, amount, message, outputs, rbf):
self.app.protected('\n'.join(msg), self.send_tx, (tx, message))

def send_tx(self, tx, message, password):
if self.app.wallet.has_password() and password is None:
return
def on_success(tx):
if tx.is_complete():
self.app.broadcast(tx, self.payment_request)
Expand Down Expand Up @@ -467,7 +469,7 @@ def do_view(self, obj):
self.app.show_pr_details(pr.get_dict(), obj.status, True)

def do_delete(self, obj):
from dialogs.question import Question
from .dialogs.question import Question
def cb(result):
if result:
self.app.wallet.invoices.remove(obj.key)
Expand Down Expand Up @@ -537,7 +539,7 @@ def do_view(self, obj):
self.app.show_pr_details(req, status, False)

def do_delete(self, obj):
from dialogs.question import Question
from .dialogs.question import Question
def cb(result):
if result:
self.app.wallet.remove_payment_request(obj.address, self.app.electrum_config)
Expand Down
9 changes: 7 additions & 2 deletions gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from electrum_ltc import SimpleConfig, Wallet, WalletStorage
from electrum_ltc.synchronizer import Synchronizer
from electrum_ltc.verifier import SPV
from electrum_ltc.util import DebugMem, UserCancelled, InvalidPassword
from electrum_ltc.util import DebugMem, UserCancelled, InvalidPassword, print_error
from electrum_ltc.wallet import Abstract_Wallet

from .installwizard import InstallWizard, GoBack
Expand Down Expand Up @@ -194,7 +194,12 @@ def start_new_window(self, path, uri):
if not wallet:
storage = WalletStorage(path)
wizard = InstallWizard(self.config, self.app, self.plugins, storage)
wallet = wizard.run_and_get_wallet()
try:
wallet = wizard.run_and_get_wallet()
except UserCancelled:
pass
except GoBack as e:
print_error('[start_new_window] Exception caught (GoBack)', e)
wizard.terminate()
if not wallet:
return
Expand Down
2 changes: 1 addition & 1 deletion gui/qt/contact_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_menu(self, position):
selected = self.selectedItems()
if not selected:
menu.addAction(_("New contact"), lambda: self.parent.new_contact_dialog())
menu.addAction(_("Import file"), lambda: self.parent.import_contacts())
menu.addAction(_("Import file"), lambda: self.import_contacts())
else:
names = [item.text(0) for item in selected]
keys = [item.text(1) for item in selected]
Expand Down
9 changes: 4 additions & 5 deletions gui/qt/fee_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def __init__(self, window, config, callback):

def moved(self, pos):
with self.lock:
fee_rate = self.config.dynfee(pos) if self.dyn else pos * self.fee_step
fee_rate = self.config.dynfee(pos) if self.dyn else self.config.static_fee(pos)
tooltip = self.get_tooltip(pos, fee_rate)
QToolTip.showText(QCursor.pos(), tooltip, self)
self.setToolTip(tooltip)
self.callback(self.dyn, pos, fee_rate)

def get_tooltip(self, pos, fee_rate):
from electrum_ltc.util import fee_levels
rate_str = self.window.format_amount(fee_rate) + ' ' + self.window.base_unit() + '/kB'
rate_str = self.window.format_fee_rate(fee_rate) if fee_rate else _('unknown')
if self.dyn:
tooltip = fee_levels[pos] + '\n' + rate_str
else:
Expand All @@ -55,10 +55,9 @@ def update(self):
self.setRange(0, 4)
self.setValue(pos)
else:
self.fee_step = self.config.max_fee_rate() / 10
fee_rate = self.config.fee_per_kb()
pos = min(fee_rate / self.fee_step, 10)
self.setRange(1, 10)
pos = self.config.static_fee_index(fee_rate)
self.setRange(0, 9)
self.setValue(pos)
tooltip = self.get_tooltip(pos, fee_rate)
self.setToolTip(tooltip)
Loading

0 comments on commit f0b28e2

Please sign in to comment.