do not pass config to storage. request height from network_proxy if connected
This commit is contained in:
parent
6035fe974c
commit
c2a4252065
2
electrum
2
electrum
|
@ -296,7 +296,7 @@ if __name__ == '__main__':
|
||||||
cmd = known_commands[cmd]
|
cmd = known_commands[cmd]
|
||||||
|
|
||||||
# instanciate wallet for command-line
|
# instanciate wallet for command-line
|
||||||
storage = WalletStorage(config)
|
storage = WalletStorage(config.get_wallet_path())
|
||||||
|
|
||||||
if cmd.name in ['create', 'restore']:
|
if cmd.name in ['create', 'restore']:
|
||||||
if storage.file_exists:
|
if storage.file_exists:
|
||||||
|
|
|
@ -907,7 +907,7 @@ class ElectrumGui:
|
||||||
|
|
||||||
contacts = util.StoreDict(config, 'contacts')
|
contacts = util.StoreDict(config, 'contacts')
|
||||||
|
|
||||||
storage = WalletStorage(config)
|
storage = WalletStorage(config.get_wallet_path())
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
action = self.restore_or_create()
|
action = self.restore_or_create()
|
||||||
if not action:
|
if not action:
|
||||||
|
|
|
@ -1290,7 +1290,7 @@ class ElectrumGui():
|
||||||
|
|
||||||
def main(self, url=None):
|
def main(self, url=None):
|
||||||
|
|
||||||
storage = WalletStorage(self.config)
|
storage = WalletStorage(self.config.get_wallet_path())
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
action = self.restore_or_create()
|
action = self.restore_or_create()
|
||||||
if not action:
|
if not action:
|
||||||
|
|
|
@ -179,7 +179,7 @@ class ElectrumGui:
|
||||||
if os.path.exists(last_wallet):
|
if os.path.exists(last_wallet):
|
||||||
self.config.read_only_options['default_wallet_path'] = last_wallet
|
self.config.read_only_options['default_wallet_path'] = last_wallet
|
||||||
try:
|
try:
|
||||||
storage = WalletStorage(self.config)
|
storage = WalletStorage(self.config.get_wallet_path())
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
QMessageBox.warning(None, _('Warning'), str(e), _('OK'))
|
QMessageBox.warning(None, _('Warning'), str(e), _('OK'))
|
||||||
self.config.set_key('gui_last_wallet', None)
|
self.config.set_key('gui_last_wallet', None)
|
||||||
|
|
|
@ -264,7 +264,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
if not filename:
|
if not filename:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
storage = WalletStorage({'wallet_path': filename})
|
storage = WalletStorage(filename)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ElectrumGui:
|
||||||
def __init__(self, config, network):
|
def __init__(self, config, network):
|
||||||
self.network = network
|
self.network = network
|
||||||
self.config = config
|
self.config = config
|
||||||
storage = WalletStorage(config)
|
storage = WalletStorage(config.get_wallet_path())
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
print "Wallet not found. try 'electrum create'"
|
print "Wallet not found. try 'electrum create'"
|
||||||
exit()
|
exit()
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ElectrumGui:
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.network = network
|
self.network = network
|
||||||
storage = WalletStorage(config)
|
storage = WalletStorage(config.get_wallet_path())
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
print "Wallet not found. try 'electrum create'"
|
print "Wallet not found. try 'electrum create'"
|
||||||
exit()
|
exit()
|
||||||
|
|
|
@ -146,6 +146,35 @@ class SimpleConfig(object):
|
||||||
import stat
|
import stat
|
||||||
os.chmod(path, stat.S_IREAD | stat.S_IWRITE)
|
os.chmod(path, stat.S_IREAD | stat.S_IWRITE)
|
||||||
|
|
||||||
|
def get_wallet_path(self):
|
||||||
|
"""Set the path of the wallet."""
|
||||||
|
|
||||||
|
# command line -w option
|
||||||
|
path = self.get('wallet_path')
|
||||||
|
if path:
|
||||||
|
return path
|
||||||
|
|
||||||
|
# path in config file
|
||||||
|
path = self.get('default_wallet_path')
|
||||||
|
if path and os.path.exists(path):
|
||||||
|
return path
|
||||||
|
|
||||||
|
# default path
|
||||||
|
dirpath = os.path.join(self.path, "wallets")
|
||||||
|
if not os.path.exists(dirpath):
|
||||||
|
os.mkdir(dirpath)
|
||||||
|
|
||||||
|
new_path = os.path.join(self.path, "wallets", "default_wallet")
|
||||||
|
|
||||||
|
# default path in pre 1.9 versions
|
||||||
|
old_path = os.path.join(self.path, "electrum.dat")
|
||||||
|
if os.path.exists(old_path) and not os.path.exists(new_path):
|
||||||
|
os.rename(old_path, new_path)
|
||||||
|
|
||||||
|
return new_path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def read_system_config(path=SYSTEM_CONFIG_PATH):
|
def read_system_config(path=SYSTEM_CONFIG_PATH):
|
||||||
"""Parse and return the system config settings in /etc/electrum.conf."""
|
"""Parse and return the system config settings in /etc/electrum.conf."""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
|
@ -48,43 +48,15 @@ IMPORTED_ACCOUNT = '/x'
|
||||||
|
|
||||||
class WalletStorage(object):
|
class WalletStorage(object):
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, path):
|
||||||
self.lock = threading.RLock()
|
self.lock = threading.RLock()
|
||||||
self.config = config
|
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
self.path = path
|
||||||
self.file_exists = False
|
self.file_exists = False
|
||||||
self.path = self.init_path(config)
|
|
||||||
print_error( "wallet path", self.path )
|
print_error( "wallet path", self.path )
|
||||||
if self.path:
|
if self.path:
|
||||||
self.read(self.path)
|
self.read(self.path)
|
||||||
|
|
||||||
def init_path(self, config):
|
|
||||||
"""Set the path of the wallet."""
|
|
||||||
|
|
||||||
# command line -w option
|
|
||||||
path = config.get('wallet_path')
|
|
||||||
if path:
|
|
||||||
return path
|
|
||||||
|
|
||||||
# path in config file
|
|
||||||
path = config.get('default_wallet_path')
|
|
||||||
if path and os.path.exists(path):
|
|
||||||
return path
|
|
||||||
|
|
||||||
# default path
|
|
||||||
dirpath = os.path.join(config.path, "wallets")
|
|
||||||
if not os.path.exists(dirpath):
|
|
||||||
os.mkdir(dirpath)
|
|
||||||
|
|
||||||
new_path = os.path.join(config.path, "wallets", "default_wallet")
|
|
||||||
|
|
||||||
# default path in pre 1.9 versions
|
|
||||||
old_path = os.path.join(config.path, "electrum.dat")
|
|
||||||
if os.path.exists(old_path) and not os.path.exists(new_path):
|
|
||||||
os.rename(old_path, new_path)
|
|
||||||
|
|
||||||
return new_path
|
|
||||||
|
|
||||||
def read(self, path):
|
def read(self, path):
|
||||||
"""Read the contents of the wallet file."""
|
"""Read the contents of the wallet file."""
|
||||||
try:
|
try:
|
||||||
|
@ -425,8 +397,9 @@ class Abstract_Wallet(object):
|
||||||
return txs
|
return txs
|
||||||
|
|
||||||
def get_local_height(self):
|
def get_local_height(self):
|
||||||
'''This does not require a network so works in offline mode'''
|
""" todo: fetch height in offline mode """
|
||||||
return self.storage.config.height
|
return self.network.get_local_height() if self.network else 0
|
||||||
|
|
||||||
|
|
||||||
def get_confirmations(self, tx):
|
def get_confirmations(self, tx):
|
||||||
""" return the number of confirmations of a monitored transaction. """
|
""" return the number of confirmations of a monitored transaction. """
|
||||||
|
@ -1484,7 +1457,8 @@ class BIP32_Wallet(Deterministic_Wallet):
|
||||||
return Mnemonic.mnemonic_to_seed(seed, password)
|
return Mnemonic.mnemonic_to_seed(seed, password)
|
||||||
|
|
||||||
def make_seed(self):
|
def make_seed(self):
|
||||||
lang = self.storage.config.get('language')
|
# fixme lang = self.storage.config.get('language')
|
||||||
|
lang = None
|
||||||
return Mnemonic(lang).make_seed()
|
return Mnemonic(lang).make_seed()
|
||||||
|
|
||||||
def format_seed(self, seed):
|
def format_seed(self, seed):
|
||||||
|
|
|
@ -174,7 +174,7 @@ class Authenticator:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
global wallet
|
global wallet
|
||||||
self.qr_data = None
|
self.qr_data = None
|
||||||
storage = WalletStorage({'wallet_path':'/sdcard/electrum/authenticator'})
|
storage = WalletStorage('/sdcard/electrum/authenticator')
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
|
|
||||||
action = self.restore_or_create()
|
action = self.restore_or_create()
|
||||||
|
|
Loading…
Reference in New Issue