Importing more than one private key on Android Electrum?
Hi - How can I import more than one private key on Android Electrum? I manage to import one private key through QR code but then when I import another one, the first private key I just imported before just vanishes. Thanks!
diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py
index aea257ccd..a8dade46b 100644
--- a/gui/kivy/uix/dialogs/installwizard.py
+++ b/gui/kivy/uix/dialogs/installwizard.py
@@ -702,6 +702,7 @@ class AddXpubDialog(WizardDialog):
         self.is_valid = kwargs['is_valid']
         self.title = kwargs['title']
         self.message = kwargs['message']
+        self.allow_multi = kwargs.get('allow_multi', False)
 
     def check_text(self, dt):
         self.ids.next.disabled = not bool(self.is_valid(self.get_text()))
@@ -715,7 +716,10 @@ class AddXpubDialog(WizardDialog):
 
     def scan_xpub(self):
         def on_complete(text):
-            self.ids.text_input.text = text
+            if self.allow_multi:
+                self.ids.text_input.text += text + '\\n'
+            else:
+                self.ids.text_input.text = text
         self.app.scan_qr(on_complete)
 
     def do_paste(self):
diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py
index fc5b440a6..a455389e6 100644
--- a/gui/qt/installwizard.py
+++ b/gui/qt/installwizard.py
@@ -332,8 +332,9 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
     def remove_from_recently_open(self, filename):
         self.config.remove_from_recently_open(filename)
 
-    def text_input(self, title, message, is_valid):
-        slayout = KeysLayout(parent=self, title=message, is_valid=is_valid)
+    def text_input(self, title, message, is_valid, allow_multi=False):
+        slayout = KeysLayout(parent=self, title=message, is_valid=is_valid,
+                             allow_multi=allow_multi)
         self.exec_layout(slayout, title, next_enabled=False)
         return slayout.get_text()
 
@@ -343,8 +344,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
         return slayout.get_seed(), slayout.is_bip39, slayout.is_ext
 
     @wizard_dialog
-    def add_xpub_dialog(self, title, message, is_valid, run_next):
-        return self.text_input(title, message, is_valid)
+    def add_xpub_dialog(self, title, message, is_valid, run_next, allow_multi=False):
+        return self.text_input(title, message, is_valid, allow_multi)
 
     @wizard_dialog
     def add_cosigner_dialog(self, run_next, index, is_valid):
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
index 26ccf6aba..7cbbba2a7 100644
--- a/gui/qt/main_window.py
+++ b/gui/qt/main_window.py
@@ -2414,7 +2414,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
         vbox = QVBoxLayout(d)
         vbox.addWidget(QLabel(_("Enter private keys:")))
 
-        keys_e = ScanQRTextEdit()
+        keys_e = ScanQRTextEdit(allow_multi=True)
         keys_e.setTabChangesFocus(True)
         vbox.addWidget(keys_e)
 
@@ -2464,7 +2464,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
         self.warn_if_watching_only()
 
     def _do_import(self, title, msg, func):
-        text = text_dialog(self, title, msg + ' :', _('Import'))
+        text = text_dialog(self, title, msg + ' :', _('Import'),
+                           allow_multi=True)
         if not text:
             return
         bad = []
diff --git a/gui/qt/qrtextedit.py b/gui/qt/qrtextedit.py
index 9e7e3ba6c..aef68f053 100644
--- a/gui/qt/qrtextedit.py
+++ b/gui/qt/qrtextedit.py
@@ -33,8 +33,9 @@ class ShowQRTextEdit(ButtonsTextEdit):
 
 class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
 
-    def __init__(self, text=""):
+    def __init__(self, text="", allow_multi=False):
         ButtonsTextEdit.__init__(self, text)
+        self.allow_multi = allow_multi
         self.setReadOnly(0)
         self.addButton(":icons/file.png", self.file_input, _("Read file"))
         icon = ":icons/qrcode_white.png" if ColorScheme.dark_scheme else ":icons/qrcode.png"
@@ -58,7 +59,11 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
             data = ''
         if not data:
             data = ''
-        self.setText(data)
+        if self.allow_multi:
+            new_text = self.text() + data + '\\n'
+        else:
+            new_text = data
+        self.setText(new_text)
         return data
 
     def contextMenuEvent(self, e):
diff --git a/gui/qt/seed_dialog.py b/gui/qt/seed_dialog.py
index f1a4e6740..af0498703 100644
--- a/gui/qt/seed_dialog.py
+++ b/gui/qt/seed_dialog.py
@@ -153,11 +153,11 @@ class SeedLayout(QVBoxLayout):
 
 
 class KeysLayout(QVBoxLayout):
-    def __init__(self, parent=None, title=None, is_valid=None):
+    def __init__(self, parent=None, title=None, is_valid=None, allow_multi=False):
         QVBoxLayout.__init__(self)
         self.parent = parent
         self.is_valid = is_valid
-        self.text_e = ScanQRTextEdit()
+        self.text_e = ScanQRTextEdit(allow_multi=allow_multi)
         self.text_e.textChanged.connect(self.on_edit)
         self.addWidget(WWLabel(title))
         self.addWidget(self.text_e)
diff --git a/gui/qt/util.py b/gui/qt/util.py
index f1f2d0bd2..2d2626a18 100644
--- a/gui/qt/util.py
+++ b/gui/qt/util.py
@@ -251,14 +251,14 @@ def line_dialog(parent, title, label, ok_label, default=None):
     if dialog.exec_():
         return txt.text()
 
-def text_dialog(parent, title, label, ok_label, default=None):
+def text_dialog(parent, title, label, ok_label, default=None, allow_multi=False):
     from .qrtextedit import ScanQRTextEdit
     dialog = WindowModalDialog(parent, title)
     dialog.setMinimumWidth(500)
     l = QVBoxLayout()
     dialog.setLayout(l)
     l.addWidget(QLabel(label))
-    txt = ScanQRTextEdit()
+    txt = ScanQRTextEdit(allow_multi=allow_multi)
     if default:
         txt.setText(default)
     l.addWidget(txt)
diff --git a/lib/base_wizard.py b/lib/base_wizard.py
index 987e2cf50..a080f2fed 100644
--- a/lib/base_wizard.py
+++ b/lib/base_wizard.py
@@ -140,7 +140,8 @@ class BaseWizard(object):
         v = lambda x: keystore.is_address_list(x) or keystore.is_private_key_list(x)
         title = _("Import Bitcoin Addresses")
         message = _("Enter a list of Bitcoin addresses (this will create a watching-only wallet), or a list of private keys.")
-        self.add_xpub_dialog(title=title, message=message, run_next=self.on_import, is_valid=v)
+        self.add_xpub_dialog(title=title, message=message, run_next=self.on_import,
+                             is_valid=v, allow_multi=True)
 
     def on_import(self, text):
         if keystore.is_address_list(text):
['gui/qt/qrtextedit.py', 'gui/qt/util.py', 'gui/kivy/uix/dialogs/installwizard.py', 'lib/base_wizard.py', 'gui/qt/seed_dialog.py', 'gui/qt/main_window.py', 'gui/qt/installwizard.py']