mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-17 00:07:56 +00:00
Fix intermittent DASH addcoin issue.
Some checks are pending
lint / build (3.12) (push) Waiting to run
Some checks are pending
lint / build (3.12) (push) Waiting to run
This commit is contained in:
parent
c9b99dd67a
commit
8081f22e92
4 changed files with 21 additions and 8 deletions
|
@ -2042,7 +2042,7 @@ class BasicSwap(BaseApp):
|
|||
self.setStringKV(db_key, main_address, session)
|
||||
return main_address
|
||||
|
||||
def checkWalletSeed(self, c):
|
||||
def checkWalletSeed(self, c) -> bool:
|
||||
ci = self.ci(c)
|
||||
if c == Coins.PART:
|
||||
ci.setWalletSeedWarning(False) # All keys should be be derived from the Particl mnemonic
|
||||
|
|
|
@ -331,6 +331,7 @@ class BTCInterface(Secp256k1Interface):
|
|||
def initialiseWallet(self, key_bytes: bytes) -> None:
|
||||
key_wif = self.encodeKey(key_bytes)
|
||||
self.rpc_wallet('sethdseed', [True, key_wif])
|
||||
self._have_checked_seed = False
|
||||
|
||||
def getWalletInfo(self):
|
||||
rv = self.rpc_wallet('getwalletinfo')
|
||||
|
@ -368,8 +369,10 @@ class BTCInterface(Secp256k1Interface):
|
|||
return 'Not found' if 'hdseedid' not in wi else wi['hdseedid']
|
||||
|
||||
def checkExpectedSeed(self, expect_seedid: str) -> bool:
|
||||
wallet_seed_id = self.getWalletSeedID()
|
||||
self._expect_seedid_hex = expect_seedid
|
||||
return expect_seedid == self.getWalletSeedID()
|
||||
self._have_checked_seed = True
|
||||
return expect_seedid == wallet_seed_id
|
||||
|
||||
def getNewAddress(self, use_segwit: bool, label: str = 'swap_receive') -> str:
|
||||
args = [label]
|
||||
|
|
|
@ -38,6 +38,7 @@ class DASHInterface(BTCInterface):
|
|||
return Mnemonic('english').to_mnemonic(key)
|
||||
|
||||
def initialiseWallet(self, key_bytes: bytes) -> None:
|
||||
self._have_checked_seed = False
|
||||
if self._wallet_v20_compatible:
|
||||
self._log.warning('Generating wallet compatible with v20 seed.')
|
||||
words = self.entropyToMnemonic(key_bytes)
|
||||
|
@ -57,9 +58,11 @@ class DASHInterface(BTCInterface):
|
|||
if rv['mnemonic'] != '':
|
||||
entropy = Mnemonic('english').to_entropy(rv['mnemonic'].split(' '))
|
||||
entropy_hash = self.getAddressHashFromKey(entropy)[::-1].hex()
|
||||
return expect_seedid == entropy_hash
|
||||
have_expected_seed: bool = expect_seedid == entropy_hash
|
||||
else:
|
||||
return expect_seedid == self.getWalletSeedID()
|
||||
have_expected_seed: bool = expect_seedid == self.getWalletSeedID()
|
||||
self._have_checked_seed = True
|
||||
return have_expected_seed
|
||||
|
||||
def withdrawCoin(self, value, addr_to, subfee):
|
||||
params = [addr_to, value, '', '', subfee, False, False, self._conf_target]
|
||||
|
@ -94,10 +97,15 @@ class DASHInterface(BTCInterface):
|
|||
|
||||
def unlockWallet(self, password: str):
|
||||
super().unlockWallet(password)
|
||||
if self._wallet_v20_compatible:
|
||||
# Store password for initialiseWallet
|
||||
self._wallet_passphrase = password
|
||||
if not self._have_checked_seed:
|
||||
try:
|
||||
self._sc.checkWalletSeed(self.coin_type())
|
||||
except Exception as ex:
|
||||
# dumphdinfo can fail if the wallet is not initialised
|
||||
self._log.debug(f'DASH checkWalletSeed failed: {ex}.')
|
||||
|
||||
def lockWallet(self):
|
||||
super().lockWallet()
|
||||
|
|
|
@ -372,7 +372,9 @@ class DCRInterface(Secp256k1Interface):
|
|||
|
||||
def checkExpectedSeed(self, expect_seedid) -> bool:
|
||||
self._expect_seedid_hex = expect_seedid
|
||||
return expect_seedid == self.getWalletSeedID()
|
||||
rv: bool = expect_seedid == self.getWalletSeedID()
|
||||
self._have_checked_seed = True
|
||||
return rv
|
||||
|
||||
def getDaemonVersion(self):
|
||||
return self.rpc('getnetworkinfo')['version']
|
||||
|
|
Loading…
Reference in a new issue