electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 5c4be3196a8e16a0048caf9a649db5338297f6ed
parent 25ad5fcd06e09bf9f59905dd78a9ee0b3857c655
Author: Amir Taaki <genjix@riseup.net>
Date:   Fri, 24 Aug 2012 09:34:30 +0100

Better looking set_path(wallet_path) method. Flattened function that's easier to read.

Diffstat:
Mlib/wallet.py | 26++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/wallet.py b/lib/wallet.py @@ -362,19 +362,21 @@ class Wallet: """Set the path of the wallet.""" if wallet_path is not None: 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: - # backward compatibility: look for wallet file in the default data directory - 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: - 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' ) + raise BaseException("No home directory found in environment variables.") + # Make wallet directory if it does not yet exist. + 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): address, key = keypair.split(':')