Allow Decred wallets derived from the legacy extkey.

When importing from seed dcrwallet creates two accounts, one each on coin_id 20 and 42.

Can't see how to force slip44 upgrade to run in dcrwallet, checking for either key instead.
This commit is contained in:
tecnovert
2024-05-27 15:44:48 +02:00
parent 57bc1d5ccf
commit b077561a6f
5 changed files with 24 additions and 6 deletions

View File

@@ -1055,11 +1055,21 @@ class BasicSwap(BaseApp):
self.log.error(traceback.format_exc())
return
legacy_root_hash = None
if coin_type == Coins.DCR:
legacy_root_hash = ci.getSeedHash(root_key, 20)
try:
session = self.openSession()
key_str = 'main_wallet_seedid_' + db_key_coin_name
self.setStringKV(key_str, root_hash.hex(), session)
if coin_type == Coins.DCR:
# TODO: How to force getmasterpubkey to always return the new slip44 (42) key
key_str = 'main_wallet_seedid_alt_' + db_key_coin_name
self.setStringKV(key_str, legacy_root_hash.hex(), session)
session.commit() # else get error database is locked!?
# Clear any saved addresses
self.clearStringKV('receive_addr_' + db_key_coin_name, session)
self.clearStringKV('stealth_addr_' + db_key_coin_name, session)
@@ -2035,6 +2045,13 @@ class BasicSwap(BaseApp):
if ci.checkExpectedSeed(expect_seedid):
ci.setWalletSeedWarning(False)
return True
if c == Coins.DCR:
# Try the legacy extkey
expect_seedid = self.getStringKV('main_wallet_seedid_alt_' + ci.coin_name().lower())
if ci.checkExpectedSeed(expect_seedid):
ci.setWalletSeedWarning(False)
self.log.warning('{} is using the legacy extkey.'.format(ci.coin_name()))
return True
self.log.warning('Wallet for coin {} not derived from swap seed.'.format(ci.coin_name()))
return False