prepare: fix mweb wallet generation (#238)

* prepare: fix mweb wallet generation

* Restore interface_type on LTC MWEB and send it through initialiseWallet.

---------

Co-authored-by: tecnovert <tecnovert@tecnovert.net>
This commit is contained in:
nahuhh 2025-01-21 19:09:04 +00:00 committed by GitHub
parent e797e23625
commit 443bd6917f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View file

@ -1303,16 +1303,16 @@ class BasicSwap(BaseApp):
legacy_root_hash = ci.getSeedHash(root_key, 20)
self.setStringKV(key_str, legacy_root_hash.hex(), cursor)
def initialiseWallet(self, coin_type, raise_errors: bool = False) -> None:
if coin_type == Coins.PART:
def initialiseWallet(self, interface_type, raise_errors: bool = False) -> None:
if interface_type == Coins.PART:
return
ci = self.ci(coin_type)
ci = self.ci(interface_type)
db_key_coin_name = ci.coin_name().lower()
self.log.info("Initialising {} wallet.".format(ci.coin_name()))
if coin_type in (Coins.XMR, Coins.WOW):
key_view = self.getWalletKey(coin_type, 1, for_ed25519=True)
key_spend = self.getWalletKey(coin_type, 2, for_ed25519=True)
if interface_type in (Coins.XMR, Coins.WOW):
key_view = self.getWalletKey(interface_type, 1, for_ed25519=True)
key_spend = self.getWalletKey(interface_type, 2, for_ed25519=True)
ci.initialiseWallet(key_view, key_spend)
root_address = ci.getAddressFromKeys(key_view, key_spend)
@ -1320,7 +1320,7 @@ class BasicSwap(BaseApp):
self.setStringKV(key_str, root_address)
return
root_key = self.getWalletKey(coin_type, 1)
root_key = self.getWalletKey(interface_type, 1)
try:
ci.initialiseWallet(root_key)
except Exception as e:
@ -1334,13 +1334,13 @@ class BasicSwap(BaseApp):
try:
cursor = self.openDB()
self.storeSeedIDForCoin(root_key, coin_type, cursor)
self.storeSeedIDForCoin(root_key, interface_type, cursor)
# Clear any saved addresses
self.clearStringKV("receive_addr_" + db_key_coin_name, cursor)
self.clearStringKV("stealth_addr_" + db_key_coin_name, cursor)
coin_id = int(coin_type)
coin_id = int(interface_type)
info_type = 1 # wallet
query_str = "DELETE FROM wallets WHERE coin_id = ? AND balance_type = ?"
cursor.execute(query_str, (coin_id, info_type))

View file

@ -137,7 +137,7 @@ class LTCInterfaceMWEB(LTCInterface):
self.rpc_wallet("walletpassphrase", [password, 100000000])
if self.getWalletSeedID() == "Not found":
self._sc.initialiseWallet(self.coin_type())
self._sc.initialiseWallet(self.interface_type())
# Workaround to trigger mweb_spk_man->LoadMWEBKeychain()
self.rpc("unloadwallet", ["mweb"])