Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import-wallet only works when base-dir is relative. #6563

Open
CjS77 opened this issue Sep 13, 2024 · 0 comments
Open

import-wallet only works when base-dir is relative. #6563

CjS77 opened this issue Sep 13, 2024 · 0 comments

Comments

@CjS77
Copy link
Collaborator

CjS77 commented Sep 13, 2024

Describe the bug
You can use the import-paper-wallet command to sweep funds from a wallet into your current wallet.
It does this by creating a temporary wallet using (almost) the same Config as your original wallet.

I say almost, because the data_dir and db_file entries get "absolutised" somewhere during wallet initialisation.

But the temp wallet creation process assumes that paths are relative, based on

new_config.set_base_path(temp_path.clone());

and

    pub fn set_base_path<P: AsRef<Path>>(&mut self, base_path: P) {
        if !self.data_dir.is_absolute() {
            self.data_dir = base_path.as_ref().join(self.data_dir.as_path());
        }
        if !self.config_dir.is_absolute() {
            self.config_dir = base_path.as_ref().join(self.config_dir.as_path());
        }
        if !self.db_file.is_absolute() {
            self.db_file = self.data_dir.join(self.db_file.as_path());
        }
        self.p2p.set_base_path(base_path);
    }

Dumping WalletConfig just before the call to set_pase_path and running the wallet with

./minotari_console_wallet -b ~/.tari import-paper-wallet --seed-words 'my seed phrase`

...


saving temp wallet in: "/home/user/.tari/nextnet/data/wallet/db/temp"

Shutting down wallet... Done.
Invalid command. General error: The application exited. Cannot acquire exclusive file lock, another instance of the application is already running
WalletConfig { override_from: Some("nextnet"),
<snip>
data_dir: "/home/user/.tari/nextnet/data/wallet", config_dir: "//home/user/.tari/nextnet/config/wallet", db_file: "/home/user/.tari/nextnet/data/wallet/db/console_wallet.db", 
<snip>
}

The absolute paths are set, even though the config is set to defaults:

[wallet]
# The relative path to store persistent data (default = "data/wallet")
#data_dir = "data/wallet"
#db_file = "db/console_wallet.db"

If however, use run recovery with relative paths:

./minotari_console_wallet -b ../../.tari import-paper-wallet --seed-words 'my seed phrase`

Then the sweep works as expected

Desktop (please complete the following information):

  • OS & Version: Ubuntu Linux

The fix is presumably either to not "absolutise" the paths in the config, and only do it when needed (path of least surprise)
or override the absolute paths with the expected values in [applications/minotari_console_wallet/src/automation/commands.rs#L1846]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant