commit b2c23f9ac8154367dc1a79cffe38817e3359150a
parent 6be62e44de87c12806bf2c4a7e851c2ffad51039
Author: ecdsa <ecdsa@github>
Date: Thu, 2 May 2013 10:54:48 +0200
deprecate wallet.save() and 'eval' command
Diffstat:
4 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/electrum b/electrum
@@ -188,9 +188,9 @@ if __name__ == '__main__':
if not found:
gui.password_dialog()
- wallet.save()
+ #wallet.save()
gui.main(url)
- wallet.save()
+ #wallet.save()
verifier.stop()
synchronizer.stop()
@@ -267,13 +267,12 @@ if __name__ == '__main__':
interface.start(wait=False)
wallet.synchronize()
wallet.fill_addressbook()
- wallet.save()
+ #wallet.save()
print_msg("Wallet saved in '%s'"%wallet.config.path)
else:
wallet.init_seed(None)
wallet.save_seed()
wallet.synchronize() # there is no wallet thread
- wallet.save()
print_msg("Your wallet generation seed is: " + wallet.seed)
print_msg("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.")
print_msg("Equivalently, your wallet seed can be stored and recovered with the following mnemonic code:")
@@ -381,7 +380,7 @@ if __name__ == '__main__':
synchronizer = WalletSynchronizer(wallet, config)
synchronizer.start()
wallet.update()
- wallet.save()
+ #wallet.save()
# run the command
@@ -395,18 +394,15 @@ if __name__ == '__main__':
if raw_input("Are you sure you want to continue? (y/n) ") in ['y','Y','yes']:
wallet.config.path = ns
wallet.seed = ''
+ wallet.config.set_key('seed', '', True)
wallet.use_encryption = False
- wallet.config.set_key('seed','', True)
+ wallet.config.set_key('use_encryption', wallet.use_encryption, True)
for k in wallet.imported_keys.keys(): wallet.imported_keys[k] = ''
- wallet.save()
+ wallet.config.set_key('imported_keys',wallet.imported_keys, True)
print_msg("Done.")
else:
print_msg("Action canceled.")
- elif cmd == 'eval':
- print_msg(eval(args[1]))
- wallet.save()
-
elif cmd == 'getconfig':
key = args[1]
print_msg(wallet.config.get(key))
diff --git a/lib/commands.py b/lib/commands.py
@@ -48,7 +48,6 @@ register_command('deseed', 0, 0, False, True, 'Remove seed from w
register_command('decoderawtransaction', 1, 1, False, True, 'similar to bitcoind\'s command')
register_command('dumpprivkey', 1, 1, True, True, 'Dumps a specified private key for a given address', 'dumpprivkey <bitcoin address>')
register_command('dumpprivkeys', 0, 0, True, True, 'dump all private keys')
-register_command('eval', 1, 1, False, True, 'Run python eval() on an object', 'eval <expression>\nExample: eval \"wallet.aliases\"')
register_command('freeze', 1, 1, False, True, 'Freeze the funds at one of your wallet\'s addresses', 'freeze <address>')
register_command('getbalance', 0, 1, False, False, 'Return the balance of your wallet, or of one account in your wallet', 'getbalance [<account>]')
register_command('getaddressbalance', 1, 1, False, False, 'Return the balance of an address', 'getbalance <address>')
diff --git a/lib/simple_config.py b/lib/simple_config.py
@@ -200,7 +200,7 @@ a SimpleConfig instance then reads the wallet file.
- def save(self):
+ def save(self, key=None):
self.save_wallet_config()
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -336,7 +336,8 @@ class Wallet:
self.accounts[key][0] = addresses
self.gap_limit = value
- self.save()
+ self.config.set_key('gap_limit', self.gap_limit, True)
+ self.config.set_key('accounts', self.accounts, True)
return True
else:
return False
@@ -405,6 +406,9 @@ class Wallet:
new = []
for account in self.accounts.keys():
new += self.synchronize_account(account)
+ if new:
+ self.config.set_key('accounts', self.accounts, True)
+ self.config.set_key('addr_history', self.history, True)
return new
@@ -670,11 +674,17 @@ class Wallet:
with self.transaction_lock:
self.transactions[tx_hash] = tx
+ self.save_transactions()
if self.verifier and tx_height>0:
self.verifier.add(tx_hash, tx_height)
self.update_tx_outputs(tx_hash)
- self.save()
+
+ def save_transactions(self):
+ tx = {}
+ for k,v in self.transactions.items():
+ tx[k] = str(v)
+ self.config.set_key('transactions', tx, True)
def receive_history_callback(self, addr, hist):
@@ -684,7 +694,7 @@ class Wallet:
with self.lock:
self.history[addr] = hist
- self.save()
+ self.config.set_key('addr_history', history, True)
if hist != ['*']:
for tx_hash, tx_height in hist:
@@ -893,6 +903,7 @@ class Wallet:
def save(self):
+ print_error("Warning: wallet.save() is deprecated")
tx = {}
for k,v in self.transactions.items():
tx[k] = str(v)