diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index c847f3d..0052099 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -704,7 +704,7 @@ class BasicSwap(BaseApp): if synced < 1.0: raise ValueError('{} chain is still syncing, currently at {}.'.format(self.coin_clients[c]['name'], synced)) - def initialiseWallet(self, coin_type): + def initialiseWallet(self, coin_type, raise_errors=False): if coin_type == Coins.PART: return ci = self.ci(coin_type) @@ -722,7 +722,14 @@ class BasicSwap(BaseApp): root_key = self.getWalletKey(coin_type, 1) root_hash = ci.getAddressHashFromKey(root_key)[::-1] - ci.initialiseWallet(root_key) + + try: + ci.initialiseWallet(root_key) + except Exception as e: + # < 0.21: sethdseed cannot set a new HD seed while still in Initial Block Download. + self._log.error('initialiseWallet failed: {}'.format(str(e))) + if raise_errors: + raise e key_str = 'main_wallet_seedid_' + ci.coin_name().lower() self.setStringKV(key_str, root_hash.hex()) @@ -1499,7 +1506,7 @@ class BasicSwap(BaseApp): if ci.knownWalletSeed(): raise ValueError('{} wallet seed is already derived from the particl mnemonic'.format(ci.coin_name())) - self.initialiseWallet(coin_type) + self.initialiseWallet(coin_type, raise_errors=True) # TODO: How to scan pruned blocks? diff --git a/basicswap/interface/btc.py b/basicswap/interface/btc.py index 85c06df..e3cf450 100644 --- a/basicswap/interface/btc.py +++ b/basicswap/interface/btc.py @@ -259,11 +259,7 @@ class BTCInterface(CoinInterface): def initialiseWallet(self, key_bytes): key_wif = self.encodeKey(key_bytes) - try: - self.rpc_callback('sethdseed', [True, key_wif]) - except Exception as e: - # < 0.21: Cannot set a new HD seed while still in Initial Block Download. - self._log.error('sethdseed failed: {}'.format(str(e))) + self.rpc_callback('sethdseed', [True, key_wif]) def getWalletInfo(self): return self.rpc_callback('getwalletinfo') diff --git a/basicswap/templates/wallet.html b/basicswap/templates/wallet.html index b53d613..b8f72df 100644 --- a/basicswap/templates/wallet.html +++ b/basicswap/templates/wallet.html @@ -177,7 +177,7 @@