Browse Source

Qt error display if fatal sync error happens in qt

master
Kristaps Kaupe 7 years ago
parent
commit
3fa08046a5
  1. 20
      jmclient/jmclient/blockchaininterface.py
  2. 8
      scripts/joinmarket-qt.py

20
jmclient/jmclient/blockchaininterface.py

@ -351,7 +351,7 @@ class BitcoinCoreInterface(BlockchainInterface):
res = self.jsonRpc.call(method, args)
return res
def import_addresses(self, addr_list, wallet_name):
def import_addresses(self, addr_list, wallet_name, restart_cb=None):
"""Imports addresses in a batch during initial sync.
Refuses to proceed if keys are found to be under control
of another account/label (see console output), and quits.
@ -377,12 +377,16 @@ class BitcoinCoreInterface(BlockchainInterface):
# don't try/catch, assume failure always has error message
log.warn(row['error']['message'])
if num_failed > 0:
log.warn("Fatal sync error: import of {} address(es) failed for "
"some reason. To prevent coin or privacy loss, "
"Joinmarket will not load a wallet in this conflicted "
"state. Try using a new Bitcoin Core wallet to sync this "
"Joinmarket wallet, or use a new Joinmarket wallet."
"".format(num_failed))
fatal_msg = ("Fatal sync error: import of {} address(es) failed for "
"some reason. To prevent coin or privacy loss, "
"Joinmarket will not load a wallet in this conflicted "
"state. Try using a new Bitcoin Core wallet to sync this "
"Joinmarket wallet, or use a new Joinmarket wallet."
"".format(num_failed))
if restart_cb:
restart_cb(fatal_msg)
else:
jmprint(fatal_msg, "important")
sys.exit(1)
def add_watchonly_addresses(self, addr_list, wallet_name, restart_cb=None):
@ -391,7 +395,7 @@ class BitcoinCoreInterface(BlockchainInterface):
but in some cases a rescan is not required (if the address is known
to be new/unused). For that case use import_addresses instead.
"""
self.import_addresses(addr_list, wallet_name)
self.import_addresses(addr_list, wallet_name, restart_cb)
if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") != 'regtest': #pragma: no cover
#Exit conditions cannot be included in tests

8
scripts/joinmarket-qt.py

@ -1458,7 +1458,7 @@ class JMMainWindow(QMainWindow):
mn_extension = pp_field.text()
return message_e.toPlainText(), mn_extension
def restartForScan(self, msg):
def restartWithMsg(self, msg):
JMQtMessageBox(self, msg, mbtype='info',
title="Restart")
self.close()
@ -1477,7 +1477,7 @@ class JMMainWindow(QMainWindow):
return
JMQtMessageBox(self, 'Wallet saved to ' + self.walletname,
title="Wallet created")
self.initWallet(seed=self.walletname, restart_cb=self.restartForScan)
self.initWallet(seed=self.walletname, restart_cb=self.restartWithMsg)
def selectWallet(self, testnet_seed=None):
if jm_single().config.get("BLOCKCHAIN", "blockchain_source") != "regtest":
@ -1501,7 +1501,7 @@ class JMMainWindow(QMainWindow):
if not ok:
return
pwd = str(text).strip()
decrypted = self.loadWalletFromBlockchain(firstarg[0], pwd, restart_cb=self.restartForScan)
decrypted = self.loadWalletFromBlockchain(firstarg[0], pwd, restart_cb=self.restartWithMsg)
else:
if not testnet_seed:
testnet_seed, ok = QInputDialog.getText(self,
@ -1586,7 +1586,7 @@ class JMMainWindow(QMainWindow):
seed = self.getTestnetSeed()
self.selectWallet(testnet_seed=seed)
else:
self.initWallet(restart_cb=self.restartForScan)
self.initWallet(restart_cb=self.restartWithMsg)
def getTestnetSeed(self):
text, ok = QInputDialog.getText(

Loading…
Cancel
Save