dash: Fix initialiseWallet

Only the upgradetohd command sets the hdseed
upgradetohd can only run once the chain is synced

Basicswap stores the hash of the root_key in it's db to check for the expected seed.
Prefer not to store the real key.
This commit is contained in:
tecnovert
2022-10-21 13:00:28 +02:00
parent 4866ff4db8
commit aa14da27af
7 changed files with 31 additions and 6 deletions

View File

@@ -293,6 +293,9 @@ class BTCInterface(CoinInterface):
def getWalletSeedID(self):
return self.rpc_callback('getwalletinfo')['hdseedid']
def checkExpectedSeed(self, expect_seedid):
return expect_seedid == self.getWalletSeedID()
def getNewAddress(self, use_segwit, label='swap_receive'):
args = [label]
if use_segwit:

View File

@@ -7,6 +7,7 @@
from .btc import BTCInterface
from basicswap.chainparams import Coins
from mnemonic import Mnemonic
class DASHInterface(BTCInterface):
@@ -15,7 +16,18 @@ class DASHInterface(BTCInterface):
return Coins.DASH
def initialiseWallet(self, key):
raise ValueError('Load seed with with -hdseed daemon argument')
words = Mnemonic('english').to_mnemonic(key)
self.rpc_callback('upgradetohd', [words, ])
def checkExpectedSeed(self, key_hash):
try:
rv = self.rpc_callback('dumphdinfo')
entropy = Mnemonic('english').to_entropy(rv['mnemonic'].split(' '))
entropy_hash = self.getAddressHashFromKey(entropy)[::-1].hex()
return entropy_hash == key_hash
except Exception as e:
self._log.warning('checkExpectedSeed failed: {}'.format(str(e)))
return False
def withdrawCoin(self, value, addr_to, subfee):
params = [addr_to, value, '', '', subfee]