feat(wallet): add delete_wallet RPC#2497
Merged
Conversation
This commit introduces the delete_wallet RPC endpoint, which allows users to delete a specified wallet after password confirmation. It also refactors the passphrase loading mechanism for better clarity and explicit behavior. The function read_and_decrypt_passphrase_if_available is now try_load_wallet_passphrase and requires a wallet_name, decoupling storage access from the active wallet context. A new helper, try_load_active_wallet_passphrase, is introduced to handle operations on the current wallet.
This commit introduces comprehensive integration tests for the `delete_wallet` RPC endpoint to ensure its functionality is robust and correct. Tests have been implemented for both native and WASM environments, covering the following scenarios: - Successful deletion of an inactive wallet. - Failure when attempting to delete the currently active wallet. - Failure when providing an incorrect password. - Failure when targeting a non-existent wallet. Additionally, a new test helper function, `delete_wallet`, has been added to `mm2_test_helpers` to streamline the process of calling the RPC endpoint within the tests.
…r handling The `test_change_mnemonic_password_rpc` integration test was failing due to an incorrect status code assertion. The test previously expected a `500 INTERNAL_SERVER_ERROR` when an invalid `current_password` was supplied. This failure was introduced by a recent refactoring that improved error propagation for passphrase handling. The system now correctly identifies an invalid password during mnemonic decryption and returns a `MnemonicRpcError::InvalidPassword`, which corresponds to a `400 BAD_REQUEST` HTTP status. This commit updates the test to assert for `StatusCode::BAD_REQUEST`, ensuring it aligns with the corrected and more precise error-handling behavior of the RPC endpoint.
delete_wallet RPCdelete_wallet RPC
The `get_wallet_names` RPC guarantees an alphabetically sorted list. This commit updates the test assertion to match the expected order, fixing the failure.
The test_delete_wallet_rpc was failing on the wasm32 target due to an incorrect assertion on the HTTP status code. The test expected a 400 BAD_REQUEST, but the wasm test harness does not reliably propagate specific HTTP status codes for RPC errors. This commit modifies the test to no longer check the StatusCode. Instead, it now deserializes the JSON error response and asserts directly on the error_type and error_data fields. This approach provides more precise validation of the error condition and makes the test more resilient to the specifics of the wasm RPC transport layer.
b8bf52c to
319fbf6
Compare
No need to continue support for QRC20 anymore
|
Docs PR at GLEECBTC/komodo-docs-mdx#529 |
Collaborator
mariocynicys
left a comment
There was a problem hiding this comment.
Perfect! Thanks!
got only a single Q regarding the no-login mode (and could such mode be tested).
p.s. no idea how the no login mode works xD
A seed node (i_am_seed: true) requires a persistent private key to establish its P2P identity. Previously, a seed node could start without a passphrase, leading to a bad state. This commit adds a pre-check to ensure CryptoCtx is initialized for seed nodes, causing startup to fail with a clear error if no wallet identity is present. Additionally, this commit includes: - A new test (test_delete_wallet_in_no_login_mode) to verify wallet deletion works correctly in no login mdoe - A safeguard in the no_login_node test helper to enforce valid test configurations.
smk762
previously approved these changes
Jun 24, 2025
smk762
left a comment
There was a problem hiding this comment.
LGTM. Docs PR approved, will be merged later this week.
Tests passed:
- attempt to delete non-existent wallet
- attempt to delete active wallet
- attempt to delete with wrong password
- attempt to delete non-active wallet with correct password.
All responded as expected.
onur-ozkan
reviewed
Jun 24, 2025
…d of panic for no_login_node test helper
dimxy
pushed a commit
to dimxy/komodo-defi-framework
that referenced
this pull request
Jun 27, 2025
* dev: (30 commits) chore(core): replace hash_raw_entry with stable entry() API (GLEECBTC#2473) chore(core): adapt `MmError` and usages for compatibility with new rustc versions (GLEECBTC#2443) feat(wallet): add `delete_wallet` RPC (GLEECBTC#2497) chore(release): add changelog entries for v2.5.0-beta (GLEECBTC#2494) chore(release): bump kdf version to 2.5.0-beta (GLEECBTC#2492) feat(tests): zcoin unit test to validate dex fee (GLEECBTC#2460) fix(zcoin): correctly track unconfirmed z-coin notes (GLEECBTC#2331) improvement(orders): remove BTC specific volume from min_trading_vol logic (GLEECBTC#2483) feat(ibc-routing-part-2): supporting entire Cosmos network for swaps (GLEECBTC#2476) fix(startup): don't initialize WalletConnect during startup (GLEECBTC#2485) fix(dns): better ip resolution (GLEECBTC#2487) improvement(event-streaming): strong type streamer IDs (GLEECBTC#2441) bump timed-map to `1.4.1` (GLEECBTC#2481) improvement(RPC): unified interface for legacy and current RPC interfaces (GLEECBTC#2450) improvement(tendermint): `tendermint_tx_internal_id` helper (GLEECBTC#2438) feat(walletconnect): add WalletConnect v2 support for EVM and Cosmos (GLEECBTC#2223) feat(ibc-routing-part-1): supporting entire Cosmos network for swaps (GLEECBTC#2459) fix(test): fix HD Wallet message signing tests (GLEECBTC#2474) improvement(builds): enable static CRT linking for MSVC builds (GLEECBTC#2464) feat(wallet): implement HD multi-address support for message signing (GLEECBTC#2432) ... # Conflicts: # mm2src/coins/qrc20.rs # mm2src/mm2_main/src/lp_swap/maker_swap.rs
dimxy
pushed a commit
that referenced
this pull request
Jun 27, 2025
* dev: chore(core): replace hash_raw_entry with stable entry() API (#2473) chore(core): adapt `MmError` and usages for compatibility with new rustc versions (#2443) feat(wallet): add `delete_wallet` RPC (#2497) chore(release): add changelog entries for v2.5.0-beta (#2494) chore(release): bump kdf version to 2.5.0-beta (#2492) feat(tests): zcoin unit test to validate dex fee (#2460) # Conflicts: # mm2src/coins/qrc20.rs # mm2src/mm2_main/src/lp_swap/maker_swap.rs
dimxy
pushed a commit
to dimxy/komodo-defi-framework
that referenced
this pull request
Jul 16, 2025
* refactor-gas-fee-policy: (30 commits) revert change in test_enable_custom_erc20 fix(test) disable get_swap_gas_fee_policy for tests (no platform coin in tests) revert tokio test and use block_on for eth docker test Refactor gas fee code: get max_eth_tx_type from platform coin, add gas fee adjust coin params, rename "set_swap_transaction_fee_policy" rpc to "set_swap_gas_fee_policy", force set_swap_gas_fee_policy to store policy in the platform coin fix(eth): Propagate structured EIP-1559 fee errors (GLEECBTC#2532) fix(eth): Correctly implement ETH max withdrawal logic (GLEECBTC#2531) feat(use-clap-for-cli): use clap to parse CLI-Args GLEECBTC#2215 (GLEECBTC#2510) feat(orderbook): expirable maker orders (GLEECBTC#2516) improvement(eth): drop parity support (GLEECBTC#2527) chore(release): finalize changelog for v2.5.0-beta (GLEECBTC#2524) chore(toolchain): upgrade toolchain to nightly 1.86.0 (GLEECBTC#2444) feat(swap): rpc to find best swap with liquidity routing for ask (GLEECBTC#2362) fix(kdf_walletconnect): apply explicit MmError mapping (GLEECBTC#2514) fix(walletconnect): centralize connection and retry logic (GLEECBTC#2508) fix(hw-wallet): avoid calling `get_enabled_address` in trezor-based coin init (GLEECBTC#2504) chore(core): replace hash_raw_entry with stable entry() API (GLEECBTC#2473) chore(core): adapt `MmError` and usages for compatibility with new rustc versions (GLEECBTC#2443) feat(wallet): add `delete_wallet` RPC (GLEECBTC#2497) chore(release): add changelog entries for v2.5.0-beta (GLEECBTC#2494) chore(release): bump kdf version to 2.5.0-beta (GLEECBTC#2492) ... # Conflicts: # mm2src/coins/eth.rs # mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs # mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs # mm2src/coins/eth/eth_utils.rs # mm2src/coins/eth/eth_withdraw.rs # mm2src/coins/eth/v2_activation.rs # mm2src/coins/lp_coins.rs # mm2src/coins/qrc20.rs # mm2src/coins/qrc20/swap.rs # mm2src/coins_activation/src/platform_coin_with_tokens.rs # mm2src/coins_activation/src/token.rs # mm2src/mm2_main/src/lp_swap/check_balance.rs # mm2src/mm2_main/src/lp_swap/maker_swap.rs # mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs # mm2src/mm2_main/src/rpc/lp_commands/ext_api/ext_api_types.rs # mm2src/mm2_main/src/rpc/lp_commands/mod.rs # mm2src/mm2_main/src/rpc/lp_commands/one_inch/errors.rs # mm2src/mm2_main/src/rpc/lp_commands/one_inch/rpcs.rs # mm2src/mm2_main/src/rpc/lp_commands/tokens.rs # mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs # mm2src/trading_api/src/one_inch_api/classic_swap_types.rs # mm2src/trading_api/src/one_inch_api/client.rs # mm2src/trading_api/src/one_inch_api/portfolio_types.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the
delete_walletRPC endpoint, allowing for the secure deletion of wallets with password confirmation.To Test:
wallet-to-delete(password: pass1) andactive-wallet(password: pass2).active-walletto make it the active session.get_wallet_names.Attempt to delete the active wallet (should fail):
{ "userpass": "your_rpc_password", "method": "delete_wallet", "mmrpc": "2.0", "params": { "wallet_name": "active-wallet", "password": "pass2" } }Expected Error: Cannot delete wallet 'active-wallet' as it is currently active.
Attempt to delete with an incorrect password (should fail):
{ "userpass": "your_rpc_password", "method": "delete_wallet", "mmrpc": "2.0", "params": { "wallet_name": "wallet-to-delete", "password": "wrong_password" } }Expected Error: Invalid password
Attempt to delete a non-existent wallet (should fail):
{ "userpass": "your_rpc_password", "method": "delete_wallet", "mmrpc": "2.0", "params": { "wallet_name": "non-existent-wallet", "password": "any_password" } }Expected Error: Wallet 'non-existent-wallet' not found.
Successfully delete an inactive wallet
{ "userpass": "your_rpc_password", "method": "delete_wallet", "mmrpc": "2.0", "params": { "wallet_name": "wallet-to-delete", "password": "pass1" } }Expected Response: A successful result
({"result":null}).Verify deletion:
Call
get_wallet_namesagain. The response should now only list active-wallet.Test deletion in no-login mode:
Create wallets again and test deleting them in no-login mode when there is no active one, this mimics what will happen in GUIs.