mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
parent
d1026b5afe
commit
1a08063928
6 changed files with 25 additions and 22 deletions
|
@ -366,8 +366,7 @@ class Daemon(Logger):
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
if self.gui_object:
|
if self.gui_object:
|
||||||
if hasattr(self.gui_object, 'new_window'):
|
if hasattr(self.gui_object, 'new_window'):
|
||||||
config.open_last_wallet()
|
path = config.get_wallet_path(use_gui_last_wallet=True)
|
||||||
path = config.get_wallet_path()
|
|
||||||
self.gui_object.new_window(path, config.get('url'))
|
self.gui_object.new_window(path, config.get('url'))
|
||||||
response = "ok"
|
response = "ok"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.argv = ['']
|
sys.argv = ['']
|
||||||
|
@ -40,12 +41,17 @@ except ImportError:
|
||||||
kivy.require('1.8.0')
|
kivy.require('1.8.0')
|
||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.simple_config import SimpleConfig
|
||||||
|
from electrum.daemon import Daemon
|
||||||
|
from electrum.plugin import Plugins
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ElectrumGui:
|
class ElectrumGui:
|
||||||
|
|
||||||
def __init__(self, config, daemon, plugins):
|
def __init__(self, config: 'SimpleConfig', daemon: 'Daemon', plugins: 'Plugins'):
|
||||||
Logger.debug('ElectrumGUI: initialising')
|
Logger.debug('ElectrumGUI: initialising')
|
||||||
self.daemon = daemon
|
self.daemon = daemon
|
||||||
self.network = daemon.network
|
self.network = daemon.network
|
||||||
|
@ -54,7 +60,6 @@ class ElectrumGui:
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
from .main_window import ElectrumWindow
|
from .main_window import ElectrumWindow
|
||||||
self.config.open_last_wallet()
|
|
||||||
w = ElectrumWindow(config=self.config,
|
w = ElectrumWindow(config=self.config,
|
||||||
network=self.network,
|
network=self.network,
|
||||||
plugins = self.plugins,
|
plugins = self.plugins,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import traceback
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import threading
|
import threading
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from electrum.bitcoin import TYPE_ADDRESS
|
from electrum.bitcoin import TYPE_ADDRESS
|
||||||
from electrum.storage import WalletStorage
|
from electrum.storage import WalletStorage
|
||||||
|
@ -77,6 +78,10 @@ from electrum.util import (base_units, NoDynamicFeeEstimates, decimal_point_to_b
|
||||||
from .uix.dialogs.lightning_open_channel import LightningOpenChannelDialog
|
from .uix.dialogs.lightning_open_channel import LightningOpenChannelDialog
|
||||||
from .uix.dialogs.lightning_channels import LightningChannelsDialog
|
from .uix.dialogs.lightning_channels import LightningChannelsDialog
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.simple_config import SimpleConfig
|
||||||
|
|
||||||
|
|
||||||
class ElectrumWindow(App):
|
class ElectrumWindow(App):
|
||||||
|
|
||||||
electrum_config = ObjectProperty(None)
|
electrum_config = ObjectProperty(None)
|
||||||
|
@ -311,7 +316,7 @@ class ElectrumWindow(App):
|
||||||
App.__init__(self)#, **kwargs)
|
App.__init__(self)#, **kwargs)
|
||||||
|
|
||||||
title = _('Electrum App')
|
title = _('Electrum App')
|
||||||
self.electrum_config = config = kwargs.get('config', None)
|
self.electrum_config = config = kwargs.get('config', None) # type: SimpleConfig
|
||||||
self.language = config.get('language', 'en')
|
self.language = config.get('language', 'en')
|
||||||
self.network = network = kwargs.get('network', None) # type: Network
|
self.network = network = kwargs.get('network', None) # type: Network
|
||||||
if self.network:
|
if self.network:
|
||||||
|
@ -543,7 +548,7 @@ class ElectrumWindow(App):
|
||||||
self.network.register_callback(self.on_channel, ['channel'])
|
self.network.register_callback(self.on_channel, ['channel'])
|
||||||
self.network.register_callback(self.on_payment_status, ['payment_status'])
|
self.network.register_callback(self.on_payment_status, ['payment_status'])
|
||||||
# load wallet
|
# load wallet
|
||||||
self.load_wallet_by_name(self.electrum_config.get_wallet_path())
|
self.load_wallet_by_name(self.electrum_config.get_wallet_path(use_gui_last_wallet=True))
|
||||||
# URI passed in config
|
# URI passed in config
|
||||||
uri = self.electrum_config.get('url')
|
uri = self.electrum_config.get('url')
|
||||||
if uri:
|
if uri:
|
||||||
|
@ -565,7 +570,8 @@ class ElectrumWindow(App):
|
||||||
elif not self.wallet:
|
elif not self.wallet:
|
||||||
# wizard did not return a wallet; and there is no wallet open atm
|
# wizard did not return a wallet; and there is no wallet open atm
|
||||||
# try to open last saved wallet (potentially start wizard again)
|
# try to open last saved wallet (potentially start wizard again)
|
||||||
self.load_wallet_by_name(self.electrum_config.get_wallet_path(), ask_if_wizard=True)
|
self.load_wallet_by_name(self.electrum_config.get_wallet_path(use_gui_last_wallet=True),
|
||||||
|
ask_if_wizard=True)
|
||||||
|
|
||||||
def load_wallet_by_name(self, path, ask_if_wizard=False):
|
def load_wallet_by_name(self, path, ask_if_wizard=False):
|
||||||
if not path:
|
if not path:
|
||||||
|
@ -1077,7 +1083,7 @@ class ElectrumWindow(App):
|
||||||
self.stop_wallet()
|
self.stop_wallet()
|
||||||
os.unlink(wallet_path)
|
os.unlink(wallet_path)
|
||||||
self.show_error(_("Wallet removed: {}").format(basename))
|
self.show_error(_("Wallet removed: {}").format(basename))
|
||||||
new_path = self.electrum_config.get_wallet_path()
|
new_path = self.electrum_config.get_wallet_path(use_gui_last_wallet=True)
|
||||||
self.load_wallet_by_name(new_path)
|
self.load_wallet_by_name(new_path)
|
||||||
|
|
||||||
def show_seed(self, label):
|
def show_seed(self, label):
|
||||||
|
|
|
@ -343,8 +343,7 @@ class ElectrumGui(Logger):
|
||||||
return
|
return
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
|
|
||||||
self.config.open_last_wallet()
|
path = self.config.get_wallet_path(use_gui_last_wallet=True)
|
||||||
path = self.config.get_wallet_path()
|
|
||||||
if not self.start_new_window(path, self.config.get('url'), app_is_starting=True):
|
if not self.start_new_window(path, self.config.get('url'), app_is_starting=True):
|
||||||
return
|
return
|
||||||
signal.signal(signal.SIGINT, lambda *args: self.app.quit())
|
signal.signal(signal.SIGINT, lambda *args: self.app.quit())
|
||||||
|
|
|
@ -556,7 +556,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
self.recently_visited_menu.setEnabled(len(recent))
|
self.recently_visited_menu.setEnabled(len(recent))
|
||||||
|
|
||||||
def get_wallet_folder(self):
|
def get_wallet_folder(self):
|
||||||
return os.path.dirname(os.path.abspath(self.config.get_wallet_path()))
|
return os.path.dirname(os.path.abspath(self.wallet.storage.path))
|
||||||
|
|
||||||
def new_wallet(self):
|
def new_wallet(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -265,17 +265,17 @@ class SimpleConfig(Logger):
|
||||||
if os.path.exists(self.path): # or maybe not?
|
if os.path.exists(self.path): # or maybe not?
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def get_wallet_path(self):
|
def get_wallet_path(self, *, use_gui_last_wallet=False):
|
||||||
"""Set the path of the wallet."""
|
"""Set the path of the wallet."""
|
||||||
|
|
||||||
# command line -w option
|
# command line -w option
|
||||||
if self.get('wallet_path'):
|
if self.get('wallet_path'):
|
||||||
return os.path.join(self.get('cwd', ''), self.get('wallet_path'))
|
return os.path.join(self.get('cwd', ''), self.get('wallet_path'))
|
||||||
|
|
||||||
# path in config file
|
if use_gui_last_wallet:
|
||||||
path = self.get('default_wallet_path')
|
path = self.get('gui_last_wallet')
|
||||||
if path and os.path.exists(path):
|
if path and os.path.exists(path):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
# default path
|
# default path
|
||||||
util.assert_datadir_available(self.path)
|
util.assert_datadir_available(self.path)
|
||||||
|
@ -304,12 +304,6 @@ class SimpleConfig(Logger):
|
||||||
def get_session_timeout(self):
|
def get_session_timeout(self):
|
||||||
return self.get('session_timeout', 300)
|
return self.get('session_timeout', 300)
|
||||||
|
|
||||||
def open_last_wallet(self):
|
|
||||||
if self.get('wallet_path') is None:
|
|
||||||
last_wallet = self.get('gui_last_wallet')
|
|
||||||
if last_wallet is not None and os.path.exists(last_wallet):
|
|
||||||
self.cmdline_options['default_wallet_path'] = last_wallet
|
|
||||||
|
|
||||||
def save_last_wallet(self, wallet):
|
def save_last_wallet(self, wallet):
|
||||||
if self.get('wallet_path') is None:
|
if self.get('wallet_path') is None:
|
||||||
path = wallet.storage.path
|
path = wallet.storage.path
|
||||||
|
|
Loading…
Add table
Reference in a new issue