Skip to content

Commit

Permalink
handle Qt wallet load failure
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamISZ committed Oct 5, 2020
1 parent 202f8ee commit 5af2d49
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions jmbase/jmbase/twisted_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def stop_reactor():
raised by trying to stop the reactor.
"""
try:
if reactor.running:
reactor.stop()
reactor.stop()
except ReactorNotRunning:
pass
7 changes: 7 additions & 0 deletions jmclient/jmclient/wallet_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ def __init__(self, wallet):
self.wallet = wallet
self.synced = False

# used to flag RPC failure at construction of object:
self.rpc_error = False

# keep track of the quasi-real-time blockheight
# (updated in main monitor loop)
self.current_blockheight = None

if self.bci is not None:
if not self.update_blockheight():
# this accounts for the unusual case
Expand All @@ -60,6 +64,9 @@ def __init__(self, wallet):
jlog.error("Failure of RPC connection to Bitcoin Core in "
"wallet service startup. Application cannot "
"continue, shutting down.")
self.rpc_error = ("Failure of RPC connection to Bitcoin "
"Core in wallet service startup.")
# no need to call stopService as it has not yet been started.
stop_reactor()
else:
jlog.warning("No blockchain source available, " +
Expand Down
9 changes: 9 additions & 0 deletions scripts/joinmarket-qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,10 @@ def selectWallet(self, testnet_seed=None):
mbtype='warn',
title="Error")
return
if decrypted == "error":
# special case, not a failure to decrypt the file but
# a failure of wallet loading, give up:
self.close()
else:
if not testnet_seed:
testnet_seed, ok = QInputDialog.getText(self,
Expand Down Expand Up @@ -1887,6 +1891,11 @@ def loadWalletFromBlockchain(self, firstarg=None, pwd=None):
self.walletRefresh.stop()

self.wallet_service = WalletService(wallet)
# in case an RPC error occurs in the constructor:
if self.wallet_service.rpc_error:
JMQtMessageBox(self,self.wallet_service.rpc_error,
mbtype='warn',title="Error")
return "error"

if jm_single().bc_interface is None:
self.centralWidget().widget(0).updateWalletInfo(
Expand Down

0 comments on commit 5af2d49

Please sign in to comment.