|
31 | 31 | from chia.util.errors import KeychainIsLocked |
32 | 32 | from chia.util.hash import std_hash |
33 | 33 | from chia.util.keychain import bytes_to_mnemonic, generate_mnemonic |
34 | | -from chia.util.path import path_from_root |
35 | 34 | from chia.util.streamable import Streamable, UInt32Range, streamable |
36 | 35 | from chia.util.ws_message import WsRpcMessage, create_payload_dict |
37 | 36 | from chia.wallet.cat_wallet.cat_constants import DEFAULT_CATS |
|
104 | 103 | from chia.wallet.wallet_coin_record import WalletCoinRecord |
105 | 104 | from chia.wallet.wallet_coin_store import CoinRecordOrder, GetCoinRecords, unspent_range |
106 | 105 | from chia.wallet.wallet_info import WalletInfo |
107 | | -from chia.wallet.wallet_node import WalletNode |
| 106 | +from chia.wallet.wallet_node import WalletNode, get_wallet_db_path |
108 | 107 | from chia.wallet.wallet_protocol import WalletProtocol |
109 | 108 | from chia.wallet.wallet_request_types import ( |
110 | 109 | AddKey, |
@@ -835,9 +834,10 @@ async def delete_key(self, request: DeleteKey) -> Empty: |
835 | 834 | except Exception as e: |
836 | 835 | log.error(f"Failed to delete key by fingerprint: {e}") |
837 | 836 | raise e |
838 | | - path = path_from_root( |
| 837 | + path = get_wallet_db_path( |
839 | 838 | self.service.root_path, |
840 | | - f"{self.service.config['database_path']}-{request.fingerprint}", |
| 839 | + self.service.config, |
| 840 | + str(request.fingerprint), |
841 | 841 | ) |
842 | 842 | if path.exists(): |
843 | 843 | path.unlink() |
@@ -925,14 +925,20 @@ async def check_delete_key(self, request: CheckDeleteKey) -> CheckDeleteKeyRespo |
925 | 925 | @marshal |
926 | 926 | async def delete_all_keys(self, request: Empty) -> Empty: |
927 | 927 | await self._stop_wallet() |
| 928 | + all_key_datas = await self.service.keychain_proxy.get_keys() |
928 | 929 | try: |
929 | 930 | await self.service.keychain_proxy.delete_all_keys() |
930 | 931 | except Exception as e: |
931 | 932 | log.error(f"Failed to delete all keys: {e}") |
932 | 933 | raise e |
933 | | - path = path_from_root(self.service.root_path, self.service.config["database_path"]) |
934 | | - if path.exists(): |
935 | | - path.unlink() |
| 934 | + for key_data in all_key_datas: |
| 935 | + path = get_wallet_db_path( |
| 936 | + self.service.root_path, |
| 937 | + self.service.config, |
| 938 | + str(key_data.fingerprint), |
| 939 | + ) |
| 940 | + if path.exists(): |
| 941 | + path.unlink() |
936 | 942 | return Empty() |
937 | 943 |
|
938 | 944 | ########################################################################################## |
|
0 commit comments