@ -9,6 +9,7 @@ import copy
from electrum import storage , bitcoin , keystore , bip32 , slip39 , wallet
from electrum import storage , bitcoin , keystore , bip32 , slip39 , wallet
from electrum import Transaction
from electrum import Transaction
from electrum import SimpleConfig
from electrum import SimpleConfig
from electrum import util
from electrum . address_synchronizer import TX_HEIGHT_UNCONFIRMED , TX_HEIGHT_UNCONF_PARENT
from electrum . address_synchronizer import TX_HEIGHT_UNCONFIRMED , TX_HEIGHT_UNCONF_PARENT
from electrum . wallet import ( sweep , Multisig_Wallet , Standard_Wallet , Imported_Wallet ,
from electrum . wallet import ( sweep , Multisig_Wallet , Standard_Wallet , Imported_Wallet ,
restore_wallet_from_text , Abstract_Wallet , BumpFeeStrategy )
restore_wallet_from_text , Abstract_Wallet , BumpFeeStrategy )
@ -18,6 +19,7 @@ from electrum.util import (
from electrum . transaction import ( TxOutput , Transaction , PartialTransaction , PartialTxOutput ,
from electrum . transaction import ( TxOutput , Transaction , PartialTransaction , PartialTxOutput ,
PartialTxInput , tx_from_any , TxOutpoint )
PartialTxInput , tx_from_any , TxOutpoint )
from electrum . mnemonic import seed_type
from electrum . mnemonic import seed_type
from electrum . network import Network
from electrum . plugins . trustedcoin import trustedcoin
from electrum . plugins . trustedcoin import trustedcoin
@ -699,8 +701,14 @@ class TestWalletSending(TestCaseForTestnet):
def setUp ( self ) :
def setUp ( self ) :
super ( ) . setUp ( )
super ( ) . setUp ( )
self . asyncio_loop , self . _stop_loop , self . _loop_thread = util . create_and_start_event_loop ( )
self . config = SimpleConfig ( { ' electrum_path ' : self . electrum_path } )
self . config = SimpleConfig ( { ' electrum_path ' : self . electrum_path } )
def tearDown ( self ) :
self . asyncio_loop . call_soon_threadsafe ( self . _stop_loop . set_result , 1 )
self . _loop_thread . join ( timeout = 1 )
super ( ) . tearDown ( )
def create_standard_wallet_from_seed ( self , seed_words , * , config = None , gap_limit = 2 ) :
def create_standard_wallet_from_seed ( self , seed_words , * , config = None , gap_limit = 2 ) :
if config is None :
if config is None :
config = self . config
config = self . config
@ -1369,14 +1377,7 @@ class TestWalletSending(TestCaseForTestnet):
raise Exception ( " unexpected txid " )
raise Exception ( " unexpected txid " )
def has_internet_connection ( self ) :
def has_internet_connection ( self ) :
return True
return True
def run_from_another_thread ( self , coro , * , timeout = None ) :
run_from_another_thread = Network . run_from_another_thread
loop , stop_loop , loop_thread = create_and_start_event_loop ( )
fut = asyncio . run_coroutine_threadsafe ( coro , loop )
try :
return fut . result ( timeout )
finally :
loop . call_soon_threadsafe ( stop_loop . set_result , 1 )
loop_thread . join ( timeout = 1 )
def get_local_height ( self ) :
def get_local_height ( self ) :
return 0
return 0
def blockchain ( self ) :
def blockchain ( self ) :
@ -1429,14 +1430,7 @@ class TestWalletSending(TestCaseForTestnet):
raise Exception ( " unexpected txid " )
raise Exception ( " unexpected txid " )
def has_internet_connection ( self ) :
def has_internet_connection ( self ) :
return True
return True
def run_from_another_thread ( self , coro , * , timeout = None ) :
run_from_another_thread = Network . run_from_another_thread
loop , stop_loop , loop_thread = create_and_start_event_loop ( )
fut = asyncio . run_coroutine_threadsafe ( coro , loop )
try :
return fut . result ( timeout )
finally :
loop . call_soon_threadsafe ( stop_loop . set_result , 1 )
loop_thread . join ( timeout = 1 )
def get_local_height ( self ) :
def get_local_height ( self ) :
return 0
return 0
def blockchain ( self ) :
def blockchain ( self ) :
@ -1844,8 +1838,8 @@ class TestWalletSending(TestCaseForTestnet):
network = NetworkMock ( )
network = NetworkMock ( )
dest_addr = ' tb1q3ws2p0qjk5vrravv065xqlnkckvzcpclk79eu2 '
dest_addr = ' tb1q3ws2p0qjk5vrravv065xqlnkckvzcpclk79eu2 '
sweep_coro = sweep ( privkeys , network = network , config = self . config , to_address = dest_addr , fee = 5000 , locktime = 1325785 , tx_version = 1 )
sweep_coro = sweep ( privkeys , network = network , config = self . config , to_address = dest_addr , fee = 5000 , locktime = 1325785 , tx_version = 1 )
loop = asyncio . get_event _loop( )
loop = util . get_asyncio _loop( )
tx = loop . run_until_complet e( sweep_coro )
tx = asyncio . run_coroutine_threadsaf e( sweep_coro , loop ) . result ( )
tx_copy = tx_from_any ( tx . serialize ( ) )
tx_copy = tx_from_any ( tx . serialize ( ) )
self . assertEqual ( ' 010000000129349e5641d79915e9d0282fdbaee8c3df0b6731bab9d70bf626e8588bde24ac010000004847304402206bf0d0a93abae0d5873a62ebf277a5dd2f33837821e8b93e74d04e19d71b578002201a6d729bc159941ef5c4c9e5fe13ece9fc544351ba531b00f68ba549c8b38a9a01fdffffff01b82e0f00000000001600148ba0a0bc12b51831f58c7ea8607e76c5982c071fd93a1400 ' ,
self . assertEqual ( ' 010000000129349e5641d79915e9d0282fdbaee8c3df0b6731bab9d70bf626e8588bde24ac010000004847304402206bf0d0a93abae0d5873a62ebf277a5dd2f33837821e8b93e74d04e19d71b578002201a6d729bc159941ef5c4c9e5fe13ece9fc544351ba531b00f68ba549c8b38a9a01fdffffff01b82e0f00000000001600148ba0a0bc12b51831f58c7ea8607e76c5982c071fd93a1400 ' ,
@ -2199,14 +2193,7 @@ class TestWalletSending(TestCaseForTestnet):
raise Exception ( " unexpected txid " )
raise Exception ( " unexpected txid " )
def has_internet_connection ( self ) :
def has_internet_connection ( self ) :
return True
return True
def run_from_another_thread ( self , coro , * , timeout = None ) :
run_from_another_thread = Network . run_from_another_thread
loop , stop_loop , loop_thread = create_and_start_event_loop ( )
fut = asyncio . run_coroutine_threadsafe ( coro , loop )
try :
return fut . result ( timeout )
finally :
loop . call_soon_threadsafe ( stop_loop . set_result , 1 )
loop_thread . join ( timeout = 1 )
def get_local_height ( self ) :
def get_local_height ( self ) :
return 0
return 0
def blockchain ( self ) :
def blockchain ( self ) :
@ -3284,8 +3271,14 @@ class TestWalletHistory_DoubleSpend(TestCaseForTestnet):
def setUp ( self ) :
def setUp ( self ) :
super ( ) . setUp ( )
super ( ) . setUp ( )
self . asyncio_loop , self . _stop_loop , self . _loop_thread = util . create_and_start_event_loop ( )
self . config = SimpleConfig ( { ' electrum_path ' : self . electrum_path } )
self . config = SimpleConfig ( { ' electrum_path ' : self . electrum_path } )
def tearDown ( self ) :
self . asyncio_loop . call_soon_threadsafe ( self . _stop_loop . set_result , 1 )
self . _loop_thread . join ( timeout = 1 )
super ( ) . tearDown ( )
@mock . patch . object ( wallet . Abstract_Wallet , ' save_db ' )
@mock . patch . object ( wallet . Abstract_Wallet , ' save_db ' )
def test_restoring_wallet_without_manual_delete ( self , mock_save_db ) :
def test_restoring_wallet_without_manual_delete ( self , mock_save_db ) :
w = restore_wallet_from_text ( " small rapid pattern language comic denial donate extend tide fever burden barrel " ,
w = restore_wallet_from_text ( " small rapid pattern language comic denial donate extend tide fever burden barrel " ,