예제 #1
0
    def request_many(self, n, xpub_hot=None):
        vbox = QVBoxLayout()
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setFrameShape(QFrame.NoFrame)
        vbox.addWidget(scroll)

        w = QWidget()
        innerVbox = QVBoxLayout(w)
        scroll.setWidget(w)

        entries = []

        if xpub_hot:
            layout = SeedDisplayLayout(xpub_hot, title=MSG_SHOW_MPK, sid='hot')
        else:
            layout = SeedInputLayout(title=MSG_ENTER_SEED_OR_MPK, sid='hot')
            entries.append(layout.seed_edit())
        innerVbox.addLayout(layout.layout())

        for i in range(n):
            msg = MSG_COSIGNER % (i + 1) if xpub_hot else MSG_ENTER_SEED_OR_MPK
            layout = SeedInputLayout(title=msg, sid='cold')
            innerVbox.addLayout(layout.layout())
            entries.append(layout.seed_edit())

        def get_texts():
            return [clean_text(entry) for entry in entries]

        def set_enabled():
            texts = get_texts()
            is_valid = Wallet.is_xpub if xpub_hot else Wallet.is_any
            all_valid = all(is_valid(text) for text in texts)
            if xpub_hot:
                texts.append(xpub_hot)
            has_dups = len(set(texts)) < len(texts)
            self.next_button.setEnabled(all_valid and not has_dups)

        for e in entries:
            e.textChanged.connect(set_enabled)
        self.set_main_layout(vbox, next_enabled=False)
        return get_texts()
예제 #2
0
    def request_many(self, n, xpub_hot=None):
        vbox = QVBoxLayout()
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setFrameShape(QFrame.NoFrame)
        vbox.addWidget(scroll)

        w = QWidget()
        innerVbox = QVBoxLayout(w)
        scroll.setWidget(w)

        entries = []

        if xpub_hot:
            layout = SeedDisplayLayout(xpub_hot, title=MSG_SHOW_MPK, sid='hot')
        else:
            layout = SeedInputLayout(title=MSG_ENTER_SEED_OR_MPK, sid='hot')
            entries.append(layout.seed_edit())
        innerVbox.addLayout(layout.layout())

        for i in range(n):
            msg = MSG_COSIGNER % (i + 1) if xpub_hot else MSG_ENTER_SEED_OR_MPK
            layout = SeedInputLayout(title=msg, sid='cold')
            innerVbox.addLayout(layout.layout())
            entries.append(layout.seed_edit())

        def get_texts():
            return [clean_text(entry) for entry in entries]
        def set_enabled():
            texts = get_texts()
            is_valid = Wallet.is_xpub if xpub_hot else Wallet.is_any
            all_valid = all(is_valid(text) for text in texts)
            if xpub_hot:
                texts.append(xpub_hot)
            has_dups = len(set(texts)) < len(texts)
            self.next_button.setEnabled(all_valid and not has_dups)
        for e in entries:
            e.textChanged.connect(set_enabled)
        self.set_main_layout(vbox, next_enabled=False)
        return get_texts()