fix sweeping

This commit is contained in:
SomberNight 2018-10-01 05:16:03 +02:00
parent 4d43d12abf
commit 626828e980
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
3 changed files with 7 additions and 3 deletions

View File

@ -2583,7 +2583,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.spend_max() self.spend_max()
self.payto_e.setFrozen(True) self.payto_e.setFrozen(True)
self.amount_e.setFrozen(True) self.amount_e.setFrozen(True)
except BaseException as e: except Exception as e: # FIXME too broad...
self.show_message(str(e)) self.show_message(str(e))
return return
self.warn_if_watching_only() self.warn_if_watching_only()

View File

@ -2,6 +2,7 @@ from unittest import mock
import shutil import shutil
import tempfile import tempfile
from typing import Sequence from typing import Sequence
import asyncio
from electrum import storage, bitcoin, keystore from electrum import storage, bitcoin, keystore
from electrum import Transaction from electrum import Transaction
@ -997,7 +998,10 @@ class TestWalletSending(TestCaseForTestnet):
class NetworkMock: class NetworkMock:
relay_fee = 1000 relay_fee = 1000
def get_local_height(self): return 1325785 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': if scripthash == '460e4fb540b657d775d84ff4955c9b13bd954c2adc26a6b998331343f85b6a45':
return [{'tx_hash': 'ac24de8b58e826f60bd7b9ba31670bdfc3e8aedb2f28d0e91599d741569e3429', 'tx_pos': 1, 'height': 1325785, 'value': 1000000}] return [{'tx_hash': 'ac24de8b58e826f60bd7b9ba31670bdfc3e8aedb2f28d0e91599d741569e3429', 'tx_pos': 1, 'height': 1325785, 'value': 1000000}]
else: else:

View File

@ -87,7 +87,7 @@ def append_utxos_to_inputs(inputs, network, pubkey, txin_type, imax):
scripthash = bitcoin.script_to_scripthash(script) scripthash = bitcoin.script_to_scripthash(script)
address = '(pubkey)' address = '(pubkey)'
u = network.listunspent_for_scripthash(scripthash) u = network.run_from_another_thread(network.listunspent_for_scripthash(scripthash))
for item in u: for item in u:
if len(inputs) >= imax: if len(inputs) >= imax:
break break