mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Fix intermittent DASH addcoin issue.
This commit is contained in:
@@ -2042,7 +2042,7 @@ class BasicSwap(BaseApp):
|
|||||||
self.setStringKV(db_key, main_address, session)
|
self.setStringKV(db_key, main_address, session)
|
||||||
return main_address
|
return main_address
|
||||||
|
|
||||||
def checkWalletSeed(self, c):
|
def checkWalletSeed(self, c) -> bool:
|
||||||
ci = self.ci(c)
|
ci = self.ci(c)
|
||||||
if c == Coins.PART:
|
if c == Coins.PART:
|
||||||
ci.setWalletSeedWarning(False) # All keys should be be derived from the Particl mnemonic
|
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:
|
def initialiseWallet(self, key_bytes: bytes) -> None:
|
||||||
key_wif = self.encodeKey(key_bytes)
|
key_wif = self.encodeKey(key_bytes)
|
||||||
self.rpc_wallet('sethdseed', [True, key_wif])
|
self.rpc_wallet('sethdseed', [True, key_wif])
|
||||||
|
self._have_checked_seed = False
|
||||||
|
|
||||||
def getWalletInfo(self):
|
def getWalletInfo(self):
|
||||||
rv = self.rpc_wallet('getwalletinfo')
|
rv = self.rpc_wallet('getwalletinfo')
|
||||||
@@ -368,8 +369,10 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
return 'Not found' if 'hdseedid' not in wi else wi['hdseedid']
|
return 'Not found' if 'hdseedid' not in wi else wi['hdseedid']
|
||||||
|
|
||||||
def checkExpectedSeed(self, expect_seedid: str) -> bool:
|
def checkExpectedSeed(self, expect_seedid: str) -> bool:
|
||||||
|
wallet_seed_id = self.getWalletSeedID()
|
||||||
self._expect_seedid_hex = expect_seedid
|
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:
|
def getNewAddress(self, use_segwit: bool, label: str = 'swap_receive') -> str:
|
||||||
args = [label]
|
args = [label]
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class DASHInterface(BTCInterface):
|
|||||||
return Mnemonic('english').to_mnemonic(key)
|
return Mnemonic('english').to_mnemonic(key)
|
||||||
|
|
||||||
def initialiseWallet(self, key_bytes: bytes) -> None:
|
def initialiseWallet(self, key_bytes: bytes) -> None:
|
||||||
|
self._have_checked_seed = False
|
||||||
if self._wallet_v20_compatible:
|
if self._wallet_v20_compatible:
|
||||||
self._log.warning('Generating wallet compatible with v20 seed.')
|
self._log.warning('Generating wallet compatible with v20 seed.')
|
||||||
words = self.entropyToMnemonic(key_bytes)
|
words = self.entropyToMnemonic(key_bytes)
|
||||||
@@ -57,9 +58,11 @@ class DASHInterface(BTCInterface):
|
|||||||
if rv['mnemonic'] != '':
|
if rv['mnemonic'] != '':
|
||||||
entropy = Mnemonic('english').to_entropy(rv['mnemonic'].split(' '))
|
entropy = Mnemonic('english').to_entropy(rv['mnemonic'].split(' '))
|
||||||
entropy_hash = self.getAddressHashFromKey(entropy)[::-1].hex()
|
entropy_hash = self.getAddressHashFromKey(entropy)[::-1].hex()
|
||||||
return expect_seedid == entropy_hash
|
have_expected_seed: bool = expect_seedid == entropy_hash
|
||||||
else:
|
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):
|
def withdrawCoin(self, value, addr_to, subfee):
|
||||||
params = [addr_to, value, '', '', subfee, False, False, self._conf_target]
|
params = [addr_to, value, '', '', subfee, False, False, self._conf_target]
|
||||||
@@ -94,10 +97,15 @@ class DASHInterface(BTCInterface):
|
|||||||
|
|
||||||
def unlockWallet(self, password: str):
|
def unlockWallet(self, password: str):
|
||||||
super().unlockWallet(password)
|
super().unlockWallet(password)
|
||||||
# Store password for initialiseWallet
|
if self._wallet_v20_compatible:
|
||||||
self._wallet_passphrase = password
|
# Store password for initialiseWallet
|
||||||
|
self._wallet_passphrase = password
|
||||||
if not self._have_checked_seed:
|
if not self._have_checked_seed:
|
||||||
self._sc.checkWalletSeed(self.coin_type())
|
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):
|
def lockWallet(self):
|
||||||
super().lockWallet()
|
super().lockWallet()
|
||||||
|
|||||||
@@ -372,7 +372,9 @@ class DCRInterface(Secp256k1Interface):
|
|||||||
|
|
||||||
def checkExpectedSeed(self, expect_seedid) -> bool:
|
def checkExpectedSeed(self, expect_seedid) -> bool:
|
||||||
self._expect_seedid_hex = expect_seedid
|
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):
|
def getDaemonVersion(self):
|
||||||
return self.rpc('getnetworkinfo')['version']
|
return self.rpc('getnetworkinfo')['version']
|
||||||
|
|||||||
Reference in New Issue
Block a user