URI: 
       tbetter error messages - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit dceb4b04eaa19606634e720f9531f13516d9e84c
   DIR parent 6143625f41b7926e5195326453680418e8a75651
  HTML Author: thomasv <thomasv@gitorious>
       Date:   Wed, 30 May 2012 14:42:30 +0200
       
       better error messages
       
       Diffstat:
         D app.fil                             |       2 --
         M electrum                            |       9 +++++----
         M lib/wallet.py                       |      10 ++++++----
       
       3 files changed, 11 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/app.fil b/app.fil
       t@@ -1,2 +0,0 @@
       -lib/gui_qt.py
       -lib/gui.py
   DIR diff --git a/electrum b/electrum
       t@@ -215,11 +215,12 @@ if __name__ == '__main__':
        
            if cmd == 'import':
                keypair = args[1]
       -        if wallet.import_key(keypair,password):
       +        try:
       +            wallet.import_key(keypair,password)
       +            wallet.save()
                    print "keypair imported"
       -        else:
       -            print "error"
       -        wallet.save()
       +        except BaseException, e:
       +            print( 'Error:' + str(e) )
        
            if cmd=='help':
                cmd2 = firstarg
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -326,17 +326,19 @@ class Wallet:
        
            def import_key(self, keypair, password):
                address, key = keypair.split(':')
       -        if not self.is_valid(address): return False
       -        if address in self.all_addresses(): return False
       +        if not self.is_valid(address):
       +            raise BaseException('Invalid Bitcoin address')
       +        if address in self.all_addresses():
       +            raise BaseException('Address already in wallet')
                b = ASecretToSecret( key )
                if not b: return False
                secexp = int( b.encode('hex'), 16)
                private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve=SECP256k1 )
                # sanity check
                public_key = private_key.get_verifying_key()
       -        if not address == public_key_to_bc_address( '04'.decode('hex') + public_key.to_string() ): return False
       +        if not address == public_key_to_bc_address( '04'.decode('hex') + public_key.to_string() ):
       +            raise BaseException('Address does not match private key')
                self.imported_keys[address] = self.pw_encode( key, password )
       -        return True
        
            def new_seed(self, password):
                seed = "%032x"%ecdsa.util.randrange( pow(2,128) )