[cli_wallet] Merge imported wallet file on load instead of replacing it
Expected Behavior
Merge new wallet file with old wallet file when invoking load_wallet_file
function:
Replace each member of the old wallet file with the according member from the new wallet file (if its new value is not empty)
Example:
old: { "cipher_keys": "abcdef", "ws_server": "ws://localhost:8090", "ws_password": "test", "ws_user": "test" }
new: { "cipher_keys": "", "ws_server": "ws://localhost:8091", "ws_password": "test2", "ws_user": "test2" }
result: { "cipher_keys": "abcdef", "ws_server": "ws://localhost:8091", "ws_password": "test2", "ws_user": "test2" }
Current Behavior
Replaces each member of the old wallet file with the according member from new wallet file when invoking load_wallet_file
function:
Example:
old: { "cipher_keys": "abcdef", "ws_server": "ws://localhost:8090", "ws_password": "test", "ws_user": "test" }
new: { "cipher_keys": "", "ws_server": "ws://localhost:8091", "ws_password": "test2", "ws_user": "test2" }
result: { "cipher_keys": "", "ws_server": "ws://localhost:8091", "ws_password": "test2", "ws_user": "test2" }
- Note: no cipher_keys
!
Possible Solution
Create a function merging wallet_data
structure as it would be also useful, when dealing with program options (currently when the user provides new endpoint url with already existing wallet file, it is not being updated in configuration, but still connects to the endpoint).
There is even an existing TODO in wallet.cpp:415