Browse Source

deprecate wallet.save() and 'eval' command

283
ecdsa 12 years ago
parent
commit
b2c23f9ac8
  1. 18
      electrum
  2. 1
      lib/commands.py
  3. 2
      lib/simple_config.py
  4. 17
      lib/wallet.py

18
electrum

@ -188,9 +188,9 @@ if __name__ == '__main__':
if not found: if not found:
gui.password_dialog() gui.password_dialog()
wallet.save() #wallet.save()
gui.main(url) gui.main(url)
wallet.save() #wallet.save()
verifier.stop() verifier.stop()
synchronizer.stop() synchronizer.stop()
@ -267,13 +267,12 @@ if __name__ == '__main__':
interface.start(wait=False) interface.start(wait=False)
wallet.synchronize() wallet.synchronize()
wallet.fill_addressbook() wallet.fill_addressbook()
wallet.save() #wallet.save()
print_msg("Wallet saved in '%s'"%wallet.config.path) print_msg("Wallet saved in '%s'"%wallet.config.path)
else: else:
wallet.init_seed(None) wallet.init_seed(None)
wallet.save_seed() wallet.save_seed()
wallet.synchronize() # there is no wallet thread wallet.synchronize() # there is no wallet thread
wallet.save()
print_msg("Your wallet generation seed is: " + wallet.seed) 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("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:") 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 = WalletSynchronizer(wallet, config)
synchronizer.start() synchronizer.start()
wallet.update() wallet.update()
wallet.save() #wallet.save()
# run the command # 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']: if raw_input("Are you sure you want to continue? (y/n) ") in ['y','Y','yes']:
wallet.config.path = ns wallet.config.path = ns
wallet.seed = '' wallet.seed = ''
wallet.config.set_key('seed', '', True)
wallet.use_encryption = False 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] = '' 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.") print_msg("Done.")
else: else:
print_msg("Action canceled.") print_msg("Action canceled.")
elif cmd == 'eval':
print_msg(eval(args[1]))
wallet.save()
elif cmd == 'getconfig': elif cmd == 'getconfig':
key = args[1] key = args[1]
print_msg(wallet.config.get(key)) print_msg(wallet.config.get(key))

1
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('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('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('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('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('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>') register_command('getaddressbalance', 1, 1, False, False, 'Return the balance of an address', 'getbalance <address>')

2
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() self.save_wallet_config()

17
lib/wallet.py

@ -336,7 +336,8 @@ class Wallet:
self.accounts[key][0] = addresses self.accounts[key][0] = addresses
self.gap_limit = value 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 return True
else: else:
return False return False
@ -405,6 +406,9 @@ class Wallet:
new = [] new = []
for account in self.accounts.keys(): for account in self.accounts.keys():
new += self.synchronize_account(account) 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 return new
@ -670,11 +674,17 @@ class Wallet:
with self.transaction_lock: with self.transaction_lock:
self.transactions[tx_hash] = tx self.transactions[tx_hash] = tx
self.save_transactions()
if self.verifier and tx_height>0: if self.verifier and tx_height>0:
self.verifier.add(tx_hash, tx_height) self.verifier.add(tx_hash, tx_height)
self.update_tx_outputs(tx_hash) 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): def receive_history_callback(self, addr, hist):
@ -684,7 +694,7 @@ class Wallet:
with self.lock: with self.lock:
self.history[addr] = hist self.history[addr] = hist
self.save() self.config.set_key('addr_history', history, True)
if hist != ['*']: if hist != ['*']:
for tx_hash, tx_height in hist: for tx_hash, tx_height in hist:
@ -893,6 +903,7 @@ class Wallet:
def save(self): def save(self):
print_error("Warning: wallet.save() is deprecated")
tx = {} tx = {}
for k,v in self.transactions.items(): for k,v in self.transactions.items():
tx[k] = str(v) tx[k] = str(v)

Loading…
Cancel
Save