electrum

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

commit 626828e98071db132595b99460858e4e8c539497
parent 4d43d12abf5413bf24b18025510c1d14e4599078
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon,  1 Oct 2018 05:16:03 +0200

fix sweeping

Diffstat:
Melectrum/gui/qt/main_window.py | 2+-
Melectrum/tests/test_wallet_vertical.py | 6+++++-
Melectrum/wallet.py | 2+-
3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -2583,7 +2583,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.spend_max() self.payto_e.setFrozen(True) self.amount_e.setFrozen(True) - except BaseException as e: + except Exception as e: # FIXME too broad... self.show_message(str(e)) return self.warn_if_watching_only() diff --git a/electrum/tests/test_wallet_vertical.py b/electrum/tests/test_wallet_vertical.py @@ -2,6 +2,7 @@ from unittest import mock import shutil import tempfile from typing import Sequence +import asyncio from electrum import storage, bitcoin, keystore from electrum import Transaction @@ -997,7 +998,10 @@ class TestWalletSending(TestCaseForTestnet): class NetworkMock: relay_fee = 1000 def get_local_height(self): return 1325785 - def listunspent_for_scripthash(self, scripthash): + def run_from_another_thread(self, coro): + loop = asyncio.get_event_loop() + return loop.run_until_complete(coro) + async def listunspent_for_scripthash(self, scripthash): if scripthash == '460e4fb540b657d775d84ff4955c9b13bd954c2adc26a6b998331343f85b6a45': return [{'tx_hash': 'ac24de8b58e826f60bd7b9ba31670bdfc3e8aedb2f28d0e91599d741569e3429', 'tx_pos': 1, 'height': 1325785, 'value': 1000000}] else: diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -87,7 +87,7 @@ def append_utxos_to_inputs(inputs, network, pubkey, txin_type, imax): scripthash = bitcoin.script_to_scripthash(script) address = '(pubkey)' - u = network.listunspent_for_scripthash(scripthash) + u = network.run_from_another_thread(network.listunspent_for_scripthash(scripthash)) for item in u: if len(inputs) >= imax: break