URI: 
       tMerge branch 'master' of github.com:spesmilo/electrum - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 66ff854d785169619cd7655707968fd37f51f5ff
   DIR parent fb9ca46019970bb66085bd15464783cc9583923d
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Mon,  6 Nov 2017 19:04:19 +0100
       
       Merge branch 'master' of github.com:spesmilo/electrum
       
       Diffstat:
         M gui/qt/main_window.py               |      20 ++++++++++++++------
         M gui/text.py                         |       2 +-
         M lib/tests/test_transaction.py       |       2 +-
         M lib/transaction.py                  |      33 +++++++++++++++++--------------
       
       4 files changed, 34 insertions(+), 23 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -2119,17 +2119,25 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                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 import transaction
   DIR diff --git a/gui/text.py b/gui/text.py
       t@@ -25,7 +25,7 @@ class ElectrumGui:
                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 create'")
                    exit()
                if storage.is_encrypted():
   DIR diff --git a/lib/tests/test_transaction.py b/lib/tests/test_transaction.py
       t@@ -30,7 +30,7 @@ class TestBCDataStream(unittest.TestCase):
                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):
   DIR diff --git a/lib/transaction.py b/lib/transaction.py
       t@@ -77,10 +77,7 @@ class BCDataStream(object):
                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)
        
       t@@ -117,15 +114,18 @@ class BCDataStream(object):
            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:
       t@@ -143,8 +143,11 @@ class BCDataStream(object):
                    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):