From 0c01dcf2f5c00303d9aacf4e137d9669a8db7417 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Tue, 7 Jan 2025 18:39:13 +0200 Subject: [PATCH] api: getcoinseed shows expected seed ids. --- basicswap/js_server.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/basicswap/js_server.py b/basicswap/js_server.py index 34a924a..0e06431 100644 --- a/basicswap/js_server.py +++ b/basicswap/js_server.py @@ -832,28 +832,32 @@ def js_getcoinseed(self, url_split, post_string, is_json) -> bytes: raise ValueError("Particl wallet seed is set from the Basicswap mnemonic.") ci = swap_client.ci(coin) + rv = {"coin": ci.ticker()} if coin in (Coins.XMR, Coins.WOW): key_view = swap_client.getWalletKey(coin, 1, for_ed25519=True) key_spend = swap_client.getWalletKey(coin, 2, for_ed25519=True) address = ci.getAddressFromKeys(key_view, key_spend) - return bytes( - json.dumps( - { - "coin": ci.ticker(), - "key_view": ci.encodeKey(key_view), - "key_spend": ci.encodeKey(key_spend), - "address": address, - } - ), - "UTF-8", - ) - seed_key = swap_client.getWalletKey(coin, 1) - seed_id = ci.getSeedHash(seed_key) + expect_address = self.getCachedMainWalletAddress(ci) + rv.update({ + "key_view": ci.encodeKey(key_view), + "key_spend": ci.encodeKey(key_spend), + "address": address, + "expected_address": "Unset" if expect_address is None else expect_address + }) + else: + seed_key = swap_client.getWalletKey(coin, 1) + seed_id = ci.getSeedHash(seed_key) + expect_seedid = swap_client.getStringKV("main_wallet_seedid_" + ci.coin_name().lower()) + + rv.update({ + "seed": seed_key.hex(), + "seed_id": seed_id.hex(), + "expected_seed_id": "Unset" if expect_seedid is None else expect_seedid + }) + return bytes( - json.dumps( - {"coin": ci.ticker(), "seed": seed_key.hex(), "seed_id": seed_id.hex()} - ), + json.dumps(rv), "UTF-8", )