diff --git a/jmclient/jmclient/blockchaininterface.py b/jmclient/jmclient/blockchaininterface.py index d9e272a..777530a 100644 --- a/jmclient/jmclient/blockchaininterface.py +++ b/jmclient/jmclient/blockchaininterface.py @@ -168,8 +168,10 @@ class BitcoinCoreInterface(BlockchainInterface): if not blockchainInfo: # see note in BitcoinCoreInterface.rpc - here # we have to create this object before reactor start, - # so sys.exit *is* the right call: - sys.exit(EXIT_FAILURE) + # so reactor is not stopped, so we override the 'swallowing' + # of the Exception that happened in self.rpc(): + raise JsonRpcConnectionError("RPC connection to Bitcoin Core " + "was not established successfully.") actualNet = blockchainInfo['chain'] netmap = {'main': 'mainnet', 'test': 'testnet', 'regtest': 'regtest'} diff --git a/jmclient/jmclient/wallet_service.py b/jmclient/jmclient/wallet_service.py index 01b1e2c..25118af 100644 --- a/jmclient/jmclient/wallet_service.py +++ b/jmclient/jmclient/wallet_service.py @@ -41,16 +41,27 @@ class WalletService(Service): # the JM wallet object. self.bci = jm_single().bc_interface + # main loop used to check for transactions, instantiated + # after wallet is synced: + self.monitor_loop = None + self.wallet = wallet + self.synced = False + # keep track of the quasi-real-time blockheight # (updated in main monitor loop) self.current_blockheight = None if self.bci is not None: - self.update_blockheight() + if not self.update_blockheight(): + # this accounts for the unusual case + # where the application started up with + # a functioning blockchain interface, but + # that bci is now failing when we are starting + # the wallet service. + raise Exception("WalletService failed to start " + "due to inability to query block height.") else: jlog.warning("No blockchain source available, " + "wallet tools will not show correct balances.") - self.wallet = wallet - self.synced = False # Dicts of registered callbacks, by type # and then by txinfo, for events @@ -119,7 +130,8 @@ class WalletService(Service): should *not* be restarted, instead a new WalletService instance should be created. """ - self.monitor_loop.stop() + if self.monitor_loop: + self.monitor_loop.stop() self.wallet.close() super(WalletService, self).stopService() diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index 8cebd2d..7e42e48 100755 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -1753,7 +1753,6 @@ class JMMainWindow(QMainWindow): # add information callbacks: self.wallet_service.add_restart_callback(self.restartWithMsg) self.wallet_service.autofreeze_warning_cb = self.autofreeze_warning_cb - self.wallet_service.startService() self.syncmsg = "" self.walletRefresh = task.LoopingCall(self.updateWalletInfo)