mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 07:23:25 +00:00
DRYed the backup wallet
This commit is contained in:
parent
0ab69e2606
commit
bf12bac1f2
3 changed files with 17 additions and 27 deletions
|
@ -320,17 +320,6 @@ class ElectrumWindow(QMainWindow):
|
||||||
else:
|
else:
|
||||||
self.load_wallet(file_name)
|
self.load_wallet(file_name)
|
||||||
|
|
||||||
# TODO: I rather import this from the lite gui, is that possible?
|
|
||||||
def backup_wallet(self):
|
|
||||||
try:
|
|
||||||
folderName = QFileDialog.getExistingDirectory(QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/'))
|
|
||||||
if folderName:
|
|
||||||
# TODO: Can we get the current wallet file instead of bruteforcing the default one?
|
|
||||||
sourceFile = self.wallet.config.path
|
|
||||||
shutil.copy2(sourceFile, str(folderName))
|
|
||||||
QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(folderName))
|
|
||||||
except (IOError, os.error), reason:
|
|
||||||
QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason))
|
|
||||||
|
|
||||||
def init_menubar(self):
|
def init_menubar(self):
|
||||||
menubar = QMenuBar()
|
menubar = QMenuBar()
|
||||||
|
@ -361,7 +350,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
wallet_menu = menubar.addMenu(_("&Wallet"))
|
wallet_menu = menubar.addMenu(_("&Wallet"))
|
||||||
wallet_backup = wallet_menu.addAction(_("&Create backup"))
|
wallet_backup = wallet_menu.addAction(_("&Create backup"))
|
||||||
wallet_backup.triggered.connect(self.backup_wallet)
|
wallet_backup.triggered.connect(backup_wallet)
|
||||||
|
|
||||||
show_menu = wallet_menu.addMenu(_("Show"))
|
show_menu = wallet_menu.addMenu(_("Show"))
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ from electrum.util import format_satoshis, age
|
||||||
import gui_classic
|
import gui_classic
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
from qt_util import *
|
||||||
|
|
||||||
bitcoin = lambda v: v * 100000000
|
bitcoin = lambda v: v * 100000000
|
||||||
|
|
||||||
def IconButton(filename, parent=None):
|
def IconButton(filename, parent=None):
|
||||||
|
@ -367,8 +369,8 @@ class MiniWindow(QDialog):
|
||||||
view_menu = menubar.addMenu(_("&View"))
|
view_menu = menubar.addMenu(_("&View"))
|
||||||
extra_menu = menubar.addMenu(_("&Extra"))
|
extra_menu = menubar.addMenu(_("&Extra"))
|
||||||
|
|
||||||
backup_wallet = extra_menu.addAction( _("&Create wallet backup"))
|
backup_wallet_menu = extra_menu.addAction( _("&Create wallet backup"))
|
||||||
backup_wallet.triggered.connect(self.backup_wallet)
|
backup_wallet_menu.triggered.connect(backup_wallet)
|
||||||
|
|
||||||
export_csv = extra_menu.addAction( _("&Export transactions to CSV") )
|
export_csv = extra_menu.addAction( _("&Export transactions to CSV") )
|
||||||
export_csv.triggered.connect(lambda: csv_transaction(self.actuator.wallet))
|
export_csv.triggered.connect(lambda: csv_transaction(self.actuator.wallet))
|
||||||
|
@ -625,19 +627,6 @@ class MiniWindow(QDialog):
|
||||||
self.main_layout.setRowMinimumHeight(3,0)
|
self.main_layout.setRowMinimumHeight(3,0)
|
||||||
self.history_list.hide()
|
self.history_list.hide()
|
||||||
|
|
||||||
def backup_wallet(self):
|
|
||||||
try:
|
|
||||||
folderName = QFileDialog.getExistingDirectory(QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/'))
|
|
||||||
if folderName:
|
|
||||||
sourceFile = util.user_dir() + '/electrum.dat'
|
|
||||||
shutil.copy2(sourceFile, str(folderName))
|
|
||||||
QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(folderName))
|
|
||||||
except (IOError, os.error), reason:
|
|
||||||
QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BalanceLabel(QLabel):
|
class BalanceLabel(QLabel):
|
||||||
|
|
||||||
SHOW_CONNECTING = 1
|
SHOW_CONNECTING = 1
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
from i18n import _
|
from i18n import _
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
def backup_wallet():
|
||||||
|
try:
|
||||||
|
folderName = QFileDialog.getExistingDirectory(QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/'))
|
||||||
|
if folderName:
|
||||||
|
# TODO: Can we get the current wallet file instead of bruteforcing the default one?
|
||||||
|
sourceFile = self.wallet.config.path
|
||||||
|
shutil.copy2(sourceFile, str(folderName))
|
||||||
|
QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(folderName))
|
||||||
|
except (IOError, os.error), reason:
|
||||||
|
QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason))
|
||||||
|
|
||||||
def ok_cancel_buttons(dialog, ok_label=_("OK") ):
|
def ok_cancel_buttons(dialog, ok_label=_("OK") ):
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
|
|
Loading…
Add table
Reference in a new issue