URI: 
       tqt: warn user if in testnet mode - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 99f9a1b4847422ab78799f187c46a4bde7ed34dd
   DIR parent 162d81c156acd365b4f4888f5edb6893e6bbe20b
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sun, 28 Apr 2019 06:31:01 +0200
       
       qt: warn user if in testnet mode
       
       closes #5295
       
       Diffstat:
         M electrum/gui/qt/__init__.py         |       1 +
         M electrum/gui/qt/main_window.py      |      27 ++++++++++++++++++++++++++-
         M electrum/gui/qt/util.py             |       5 ++++-
       
       3 files changed, 31 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py
       t@@ -198,6 +198,7 @@ class ElectrumGui(PrintError):
                self.build_tray_menu()
                # FIXME: Remove in favour of the load_wallet hook
                run_hook('on_new_window', w)
       +        w.warn_if_testnet()
                w.warn_if_watching_only()
                return w
        
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -468,7 +468,32 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                        _("This means you will not be able to spend Bitcoins with it."),
                        _("Make sure you own the seed phrase or the private keys, before you request Bitcoins to be sent to this wallet.")
                    ])
       -            self.show_warning(msg, title=_('Information'))
       +            self.show_warning(msg, title=_('Watch-only wallet'))
       +
       +    def warn_if_testnet(self):
       +        if not constants.net.TESTNET:
       +            return
       +        # user might have opted out already
       +        if self.config.get('dont_show_testnet_warning', False):
       +            return
       +        # only show once per process lifecycle
       +        if getattr(self.gui_object, '_warned_testnet', False):
       +            return
       +        self.gui_object._warned_testnet = True
       +        msg = ''.join([
       +            _("You are in testnet mode."), ' ',
       +            _("Testnet coins are worthless."), '\n',
       +            _("Testnet is separate from the main Bitcoin network. It is used for testing.")
       +        ])
       +        cb = QCheckBox(_("Don't show this again."))
       +        cb_checked = False
       +        def on_cb(x):
       +            nonlocal cb_checked
       +            cb_checked = x == Qt.Checked
       +        cb.stateChanged.connect(on_cb)
       +        self.show_warning(msg, title=_('Testnet'), checkbox=cb)
       +        if cb_checked:
       +            self.config.set_key('dont_show_testnet_warning', True)
        
            def open_wallet(self):
                try:
   DIR diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py
       t@@ -218,7 +218,8 @@ class MessageBoxMixin(object):
                                    title or _('Information'), msg, **kwargs)
        
            def msg_box(self, icon, parent, title, text, buttons=QMessageBox.Ok,
       -                defaultButton=QMessageBox.NoButton, rich_text=False):
       +                defaultButton=QMessageBox.NoButton, *, rich_text=False,
       +                checkbox=None):
                parent = parent or self.top_level_window()
                if type(icon) is QPixmap:
                    d = QMessageBox(QMessageBox.Information, title, str(text), buttons, parent)
       t@@ -233,6 +234,8 @@ class MessageBoxMixin(object):
                else:
                    d.setTextInteractionFlags(Qt.TextSelectableByMouse)
                    d.setTextFormat(Qt.PlainText)
       +        if checkbox is not None:
       +            d.setCheckBox(checkbox)
                return d.exec_()
        
        class WindowModalDialog(QDialog, MessageBoxMixin):