mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 17:55:20 +00:00
Better looking set_path(wallet_path) method. Flattened function that's easier to read.
This commit is contained in:
parent
25ad5fcd06
commit
5c4be3196a
1 changed files with 14 additions and 12 deletions
|
@ -362,19 +362,21 @@ class Wallet:
|
||||||
"""Set the path of the wallet."""
|
"""Set the path of the wallet."""
|
||||||
if wallet_path is not None:
|
if wallet_path is not None:
|
||||||
self.path = wallet_path
|
self.path = wallet_path
|
||||||
|
return
|
||||||
|
# Look for wallet file in the default data directory.
|
||||||
|
# Keeps backwards compatibility.
|
||||||
|
if "HOME" in os.environ:
|
||||||
|
wallet_dir = os.path.join(os.environ["HOME"], ".electrum")
|
||||||
|
elif "LOCALAPPDATA" in os.environ:
|
||||||
|
wallet_dir = os.path.join(os.environ["LOCALAPPDATA"], "Electrum")
|
||||||
|
elif "APPDATA" in os.environ:
|
||||||
|
wallet_dir = os.path.join(os.environ["APPDATA"], "Electrum")
|
||||||
else:
|
else:
|
||||||
# backward compatibility: look for wallet file in the default data directory
|
raise BaseException("No home directory found in environment variables.")
|
||||||
if "HOME" in os.environ:
|
# Make wallet directory if it does not yet exist.
|
||||||
wallet_dir = os.path.join( os.environ["HOME"], '.electrum')
|
if not os.path.exists(wallet_dir):
|
||||||
elif "LOCALAPPDATA" in os.environ:
|
os.mkdir(wallet_dir)
|
||||||
wallet_dir = os.path.join( os.environ["LOCALAPPDATA"], 'Electrum' )
|
self.path = os.path.join(wallet_dir, "electrum.dat")
|
||||||
elif "APPDATA" in os.environ:
|
|
||||||
wallet_dir = os.path.join( os.environ["APPDATA"], 'Electrum' )
|
|
||||||
else:
|
|
||||||
raise BaseException("No home directory found in environment variables.")
|
|
||||||
|
|
||||||
if not os.path.exists( wallet_dir ): os.mkdir( wallet_dir )
|
|
||||||
self.path = os.path.join( wallet_dir, 'electrum.dat' )
|
|
||||||
|
|
||||||
def import_key(self, keypair, password):
|
def import_key(self, keypair, password):
|
||||||
address, key = keypair.split(':')
|
address, key = keypair.split(':')
|
||||||
|
|
Loading…
Add table
Reference in a new issue