commit 1d15286015a3b3cac4a1e1eb666cdb150527963a
parent 946bcb316ad0983b694c77420d7b0bae970076cc
Author: thomasv <thomasv@gitorious>
Date: Sat, 11 Feb 2012 11:20:21 +0100
Merge commit 'refs/merge-requests/7' of git://gitorious.org/electrum/electrum into merge-requests/7
Diffstat:
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git 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,21 +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)
- 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
@@ -345,6 +350,7 @@ if __name__ == '__main__':
if is_temporary:
wallet.imported_keys.pop(from_addr)
+ del(wallet.history[from_addr])
wallet.save()
elif cmd == 'sendtx':