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 Nov 6, 2017
2 parents 861b980 + d599f11 commit 7fbacb5
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 30 deletions.
22 changes: 22 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>litecoin</string>
<key>CFBundleURLSchemes</key>
<array>
<string>litecoin</string>
</array>
</dict>
</array>
<key>LSArchitecturePriority</key>
<array>
<string>x86_64</string>
<string>i386</string>
</array>
</dict>
</plist>
4 changes: 4 additions & 0 deletions RELEASE-NOTES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 3.0.1
* minor bug and usability fixes


# Release 3.0 - Uncanny Valley (November 1st, 2017)

* The project was migrated to Python3 and Qt5. Python2 is no longer
Expand Down
20 changes: 14 additions & 6 deletions gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2119,17 +2119,25 @@ def read_tx_from_file(self):
return self.tx_from_text(file_content)

def do_process_from_text(self):
from electrum.transaction import SerializationError
text = text_dialog(self, _('Input raw transaction'), _("Transaction:"), _("Load transaction"))
if not text:
return
tx = self.tx_from_text(text)
if tx:
self.show_transaction(tx)
try:
tx = self.tx_from_text(text)
if tx:
self.show_transaction(tx)
except SerializationError as e:
self.show_critical(_("Electrum was unable to deserialize the transaction:") + "\n" + str(e))

def do_process_from_file(self):
tx = self.read_tx_from_file()
if tx:
self.show_transaction(tx)
from electrum.transaction import SerializationError
try:
tx = self.read_tx_from_file()
if tx:
self.show_transaction(tx)
except SerializationError as e:
self.show_critical(_("Electrum was unable to deserialize the transaction:") + "\n" + str(e))

def do_process_from_txid(self):
from electrum_ltc import transaction
Expand Down
2 changes: 1 addition & 1 deletion gui/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, config, daemon, plugins):
self.config = config
self.network = daemon.network
storage = WalletStorage(config.get_wallet_path())
if not storage.file_exists:
if not storage.file_exists():
print("Wallet not found. try 'electrum-ltc create'")
exit()
if storage.is_encrypted():
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_compact_size(self):
for v in values:
self.assertEqual(s.read_compact_size(), v)

with self.assertRaises(IndexError):
with self.assertRaises(transaction.SerializationError):
s.read_compact_size()

def test_string(self):
Expand Down
33 changes: 18 additions & 15 deletions lib/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def read_string(self, encoding='ascii'):
if self.input is None:
raise SerializationError("call write(bytes) before trying to deserialize")

try:
length = self.read_compact_size()
except IndexError:
raise SerializationError("attempt to read past end of buffer")
length = self.read_compact_size()

return self.read_bytes(length).decode(encoding)

Expand Down Expand Up @@ -117,15 +114,18 @@ def write_int64(self, val): return self._write_num('<q', val)
def write_uint64(self, val): return self._write_num('<Q', val)

def read_compact_size(self):
size = self.input[self.read_cursor]
self.read_cursor += 1
if size == 253:
size = self._read_num('<H')
elif size == 254:
size = self._read_num('<I')
elif size == 255:
size = self._read_num('<Q')
return size
try:
size = self.input[self.read_cursor]
self.read_cursor += 1
if size == 253:
size = self._read_num('<H')
elif size == 254:
size = self._read_num('<I')
elif size == 255:
size = self._read_num('<Q')
return size
except IndexError:
raise SerializationError("attempt to read past end of buffer")

def write_compact_size(self, size):
if size < 0:
Expand All @@ -143,8 +143,11 @@ def write_compact_size(self, size):
self._write_num('<Q', size)

def _read_num(self, format):
(i,) = struct.unpack_from(format, self.input, self.read_cursor)
self.read_cursor += struct.calcsize(format)
try:
(i,) = struct.unpack_from(format, self.input, self.read_cursor)
self.read_cursor += struct.calcsize(format)
except Exception as e:
raise SerializationError(e)
return i

def _write_num(self, format, num):
Expand Down
2 changes: 1 addition & 1 deletion lib/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ELECTRUM_VERSION = '3.0' # version of the client package
ELECTRUM_VERSION = '3.0.1' # version of the client package
PROTOCOL_VERSION = '1.1' # protocol version requested

# The hash of the mnemonic seed must begin with this
Expand Down
9 changes: 3 additions & 6 deletions plugins/ledger/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def decrypt_message(self, pubkey, message, password):

def sign_message(self, sequence, message, password):
self.signing = True
message = message.encode('utf8')
# prompt for the PIN before displaying the dialog if necessary
client = self.get_client()
address_path = self.get_derivation()[2:] + "/%d/%d"%sequence
Expand All @@ -243,9 +244,7 @@ def sign_message(self, sequence, message, password):
finally:
self.handler.clear_dialog()
self.signing = False

# Parse the ASN.1 signature

rLength = signature[3]
r = signature[4 : 4 + rLength]
sLength = signature[4 + rLength + 1]
Expand All @@ -254,11 +253,9 @@ def sign_message(self, sequence, message, password):
r = r[1:]
if sLength == 33:
s = s[1:]
r = str(r)
s = str(s)

# And convert it
return chr(27 + 4 + (signature[0] & 0x01)) + r + s
return bytes([27 + 4 + (signature[0] & 0x01)]) + r + s


def sign_transaction(self, tx, password):
if tx.is_complete():
Expand Down

0 comments on commit 7fbacb5

Please sign in to comment.