1
0

CLI: make 'wallet_path' relative to wallets dir

If the wallet_path passed to the RPC is a simple filename,
interpret it as relative to the user wallets directory,
rather than to the current working directory.

This is a breaking change, it might affect existing scripts
This commit is contained in:
ThomasV
2025-06-04 12:44:07 +02:00
parent 37914d5af0
commit 85c3c77096
3 changed files with 16 additions and 6 deletions

View File

@@ -458,11 +458,20 @@ class SimpleConfig(Logger):
else:
return self.WALLET_BACKUP_DIRECTORY
def maybe_complete_wallet_path(self, path: Optional[str]) -> str:
return self._complete_wallet_path(path) if path is not None else self.get_wallet_path()
def _complete_wallet_path(self, path: str) -> str:
""" add user wallets directory if needed """
if os.path.split(path)[0] == '':
path = os.path.join(self.get_datadir_wallet_path(), path)
return path
def get_wallet_path(self) -> str:
"""Returns the wallet path."""
# command line -w option
if self.get('wallet_path'):
return os.path.join(self.get('cwd', ''), self.get('wallet_path'))
if path:= self.get('wallet_path'):
return self._complete_wallet_path(path)
# current wallet
path = self.CURRENT_WALLET
if path and os.path.exists(path):