From 845143e720635eb68c5ff367e7d0f99914d50020 Mon Sep 17 00:00:00 2001 From: DiThi Date: Sat, 11 Feb 2012 05:50:07 +0100 Subject: [PATCH 1/2] Fixed last fix. --- client/electrum | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/electrum b/client/electrum index 8d42841f..f90af824 100755 --- a/client/electrum +++ b/client/electrum @@ -315,6 +315,8 @@ if __name__ == '__main__': if not wallet.import_key(keypair,password): print "invalid key pair" exit(1) + wallet.history[from_addr] = interface.retrieve_history(from_addr) + wallet.update_tx_history() is_temporary = True else: from_addr = None @@ -345,6 +347,7 @@ if __name__ == '__main__': if is_temporary: wallet.imported_keys.pop(from_addr) + del(wallet.history[from_addr]) wallet.save() elif cmd == 'sendtx': From 6525189fe0ce568e875528a8981a03ac08f5e572 Mon Sep 17 00:00:00 2001 From: DiThi Date: Sat, 11 Feb 2012 06:48:44 +0100 Subject: [PATCH 2/2] When using --from_addr: - change is sent to itself as stated in help text (feature was removed in ThomasV's last commit). - if the wallet is encrypted it doesn't ask for the password. --- client/electrum | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/client/electrum b/client/electrum index f90af824..e066763d 100755 --- a/client/electrum +++ b/client/electrum @@ -159,9 +159,17 @@ if __name__ == '__main__': interface.update_wallet(wallet) wallet.save() + # check if --from_addr not in wallet (for mktx/payto) + is_temporary = False + from_addr = None + if options.from_addr: + from_addr = options.from_addr + if from_addr not in wallet.all_addresses(): + is_temporary = True + # commands needing password if cmd in ['payto', 'password', 'mktx', 'seed', 'import','signmessage' ] or ( cmd=='addresses' and options.show_keys): - password = getpass.getpass('Password:') if wallet.use_encryption else None + password = getpass.getpass('Password:') if wallet.use_encryption and not is_temporary else None # check password try: wallet.pw_decode( wallet.seed, password) @@ -303,23 +311,18 @@ if __name__ == '__main__': wallet.save() elif cmd in ['payto', 'mktx']: - is_temporary = False - if options.from_addr: - from_addr = options.from_addr - if from_addr not in wallet.all_addresses(): - if from_addr.find(":") == -1: - keypair = from_addr + ":" + getpass.getpass('Private key:') - else: - keypair = from_addr - from_addr = keypair.split(':')[0] - if not wallet.import_key(keypair,password): - print "invalid key pair" - exit(1) - wallet.history[from_addr] = interface.retrieve_history(from_addr) - wallet.update_tx_history() - is_temporary = True - else: - from_addr = None + if from_addr and is_temporary: + if from_addr.find(":") == -1: + keypair = from_addr + ":" + getpass.getpass('Private key:') + else: + keypair = from_addr + from_addr = keypair.split(':')[0] + if not wallet.import_key(keypair,password): + print "invalid key pair" + exit(1) + wallet.history[from_addr] = interface.retrieve_history(from_addr) + wallet.update_tx_history() + change_addr = from_addr if options.change_addr: change_addr = options.change_addr