示例#1
0
    def run(self):

        action = self.restore_or_create()
        if not action: exit()

        wallet = Wallet(self.storage)

        if action == 'create':
            wallet.init_seed(None)
            self.show_seed(wallet)
            if self.verify_seed(wallet):
                wallet.save_seed()
                wallet.create_accounts()
                # generate first addresses offline
                wallet.synchronize()
            else:
                return

        elif action == 'restore':
            # ask for seed and gap.
            sg = self.seed_dialog()
            if not sg:
                return
            seed, gap = sg
            if not seed:
                return
            wallet.gap_limit = gap
            wallet.init_seed(str(seed))
            wallet.save_seed()

        elif action == 'watching':
            # ask for seed and gap.
            sg = self.mpk_dialog()
            if not sg:
                return
            mpk, gap = sg
            if not mpk:
                return
            wallet.gap_limit = gap
            wallet.seed = ''

            print eval(mpk)
            try:
                c0, K0 = eval(mpk)
            except:
                QMessageBox.warning(None, _('Error'), _('error'), _('OK'))
                return
            wallet.create_watching_only_wallet(c0, K0)

        else:
            raise

        #if not self.config.get('server'):
        self.network_dialog()

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':
            try:
                keep_it = self.restore_wallet(wallet)
                wallet.fill_addressbook()
            except:
                import traceback
                traceback.print_exc(file=sys.stdout)
                exit()

            if not keep_it: return

        self.password_dialog(wallet)

        return wallet
示例#2
0
    def run(self):

        action = self.restore_or_create()
        if not action: exit()

        wallet = Wallet(self.storage)

        if action == 'create':
            wallet.init_seed(None)
            self.show_seed(wallet)
            if self.verify_seed(wallet):
                wallet.save_seed()
                wallet.create_accounts()
                # generate first addresses offline
                wallet.synchronize()
            else:
                return
                
        elif action == 'restore':
            # ask for seed and gap.
            sg = self.seed_dialog()
            if not sg:
                return
            seed, gap = sg
            if not seed:
                return
            wallet.gap_limit = gap
            wallet.init_seed(str(seed))
            wallet.save_seed()

        elif action == 'watching':
            # ask for seed and gap.
            sg = self.mpk_dialog()
            if not sg:
                return
            mpk, gap = sg
            if not mpk:
                return
            wallet.gap_limit = gap
            wallet.seed = ''

            print eval(mpk)
            try:
                c0, K0 = eval(mpk)
            except:
                QMessageBox.warning(None, _('Error'), _('error'), _('OK'))
                return
            wallet.create_watching_only_wallet(c0,K0)


        else: raise
                
        #if not self.config.get('server'):
        self.network_dialog()

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':
            try:
                keep_it = self.restore_wallet(wallet)
                wallet.fill_addressbook()
            except:
                import traceback
                traceback.print_exc(file=sys.stdout)
                exit()

            if not keep_it: return

        self.password_dialog(wallet)
        
        return wallet
示例#3
0
    def run(self):

        action = self.restore_or_create()
        if not action: exit()

        wallet = Wallet(self.storage)
        gap = self.config.get('gap_limit', 5)
        if gap != 5:
            wallet.gap_limit = gap
            wallet.storage.put('gap_limit', gap, True)

        if action == 'create':
            wallet.init_seed(None)
            self.show_seed(wallet)
            if self.verify_seed(wallet):
                def create():
                    wallet.save_seed()
                    wallet.create_accounts()
                    wallet.synchronize()  # generate first addresses offline
                self.waiting_dialog(create)
            else:
                return
                
        elif action == 'restore':
            # ask for seed and gap.
            seed = self.seed_dialog()
            if not seed:
                return
            try:
                wallet.init_seed(seed)
            except:
                import traceback
                traceback.print_exc(file=sys.stdout)
                QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK'))
                return

            wallet.save_seed()

        elif action == 'watching':
            # ask for seed and gap.
            mpk = self.mpk_dialog()
            if not mpk:
                return
            wallet.seed = ''
            wallet.create_watching_only_wallet(mpk)


        else: raise
                
        #if not self.config.get('server'):
        if self.network:
            self.network_dialog()

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':

            self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText))

            if self.network:
                if wallet.is_found():
                    QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK'))
                else:
                    QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK'))
            else:
                QMessageBox.information(None, _('Information'), _("This wallet was restored offline. It may contain more addresses than displayed."), _('OK'))

        self.password_dialog(wallet)

        return wallet
示例#4
0
    def run(self):

        action = self.restore_or_create()
        if not action:
            exit()

        wallet = Wallet(self.storage)
        gap = self.config.get("gap_limit", 5)
        if gap != 5:
            wallet.gap_limit = gap
            wallet.storage.put("gap_limit", gap, True)

        if action == "create":
            wallet.init_seed(None)
            self.show_seed(wallet)
            if self.verify_seed(wallet):

                def create():
                    wallet.save_seed()
                    wallet.create_accounts()
                    wallet.synchronize()  # generate first addresses offline

                self.waiting_dialog(create)
            else:
                return

        elif action == "restore":
            # ask for seed and gap.
            seed = self.seed_dialog()
            if not seed:
                return
            wallet.init_seed(str(seed))
            wallet.save_seed()

        elif action == "watching":
            # ask for seed and gap.
            mpk = self.mpk_dialog()
            if not mpk:
                return
            wallet.seed = ""

            print eval(mpk)
            try:
                c0, K0 = eval(mpk)
            except:
                QMessageBox.warning(None, _("Error"), _("error"), _("OK"))
                return
            wallet.create_watching_only_wallet(c0, K0)

        else:
            raise

        # if not self.config.get('server'):
        self.network_dialog()

        # start wallet threads
        wallet.start_threads(self.network)

        if action == "restore":

            def wait_for_wallet():
                wallet.set_up_to_date(False)
                while not wallet.is_up_to_date():
                    msg = "%s\n%s %d\n%s %.1f" % (
                        _("Please wait..."),
                        _("Addresses generated:"),
                        len(wallet.addresses(True)),
                        _("Kilobytes received:"),
                        self.network.interface.bytes_received / 1024.0,
                    )
                    self.waiting_label.setText(msg)
                    time.sleep(0.1)

            def wait_for_network():
                while not self.network.interface.is_connected:
                    msg = "%s \n" % (_("Connecting..."))
                    self.waiting_label.setText(msg)
                    time.sleep(0.1)

            def restore():
                # wait until we are connected, because the user might have selected another server
                wait_for_network()

                # try to restore old account
                wallet.create_old_account()
                wait_for_wallet()

                if wallet.is_found():
                    wallet.seed_version = 4
                    wallet.storage.put("seed_version", wallet.seed_version, True)
                else:
                    wallet.accounts.pop(0)
                    wallet.create_accounts()
                    wait_for_wallet()

            self.waiting_dialog(restore)

            if wallet.is_found():
                QMessageBox.information(None, _("Information"), _("Recovery successful"), _("OK"))
            else:
                QMessageBox.information(None, _("Information"), _("No transactions found for this seed"), _("OK"))

            wallet.fill_addressbook()

        self.password_dialog(wallet)

        return wallet
示例#5
0
    def run(self):

        action = self.restore_or_create()
        if not action: exit()

        wallet = Wallet(self.storage)
        gap = self.config.get('gap_limit', 5)
        if gap != 5:
            wallet.gap_limit = gap
            wallet.storage.put('gap_limit', gap, True)

        if action == 'create':
            wallet.init_seed(None)
            self.show_seed(wallet)
            if self.verify_seed(wallet):
                def create():
                    wallet.save_seed()
                    wallet.create_accounts()
                    wallet.synchronize()  # generate first addresses offline
                self.waiting_dialog(create)
            else:
                return
                
        elif action == 'restore':
            # ask for seed and gap.
            seed = self.seed_dialog()
            if not seed:
                return
            wallet.init_seed(str(seed))
            wallet.save_seed()

        elif action == 'watching':
            # ask for seed and gap.
            K, chain = self.mpk_dialog()
            if not K or not chain:
                return
            wallet.seed = ''
            wallet.create_watching_only_wallet(chain,K)


        else: raise
                
        #if not self.config.get('server'):
        self.network_dialog()

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':

            self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText))

            if wallet.is_found():
                QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK'))
            else:
                QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK'))
            
            wallet.fill_addressbook()

        self.password_dialog(wallet)

        return wallet
示例#6
0
    def run(self):

        action = self.restore_or_create()
        if not action: 
            return

        #gap = self.config.get('gap_limit', 5)
        #if gap != 5:
        #    wallet.gap_limit = gap
        #    wallet.storage.put('gap_limit', gap, True)

        if action == 'create':
            wallet = Wallet(self.storage)
            wallet.init_seed(None)
            if not self.show_seed(wallet):
                return
            if not self.verify_seed(wallet):
                return
            ok, old_password, password = self.password_dialog(wallet)
            def create():
                wallet.save_seed(password)
                wallet.synchronize()  # generate first addresses offline
            self.waiting_dialog(create)

        elif action == 'restore':
            seed = self.seed_dialog()
            if not seed:
                return
            wallet = Wallet.from_seed(seed, self.storage)
            ok, old_password, password = self.password_dialog(wallet)
            wallet.save_seed(password)

        elif action == 'watching':
            mpk = self.mpk_dialog()
            if not mpk:
                return
            wallet.seed = ''
            wallet.create_watching_only_wallet(mpk)

        else: raise
                
        #if not self.config.get('server'):
        if self.network:
            if self.network.interfaces:
                self.network_dialog()
            else:
                QMessageBox.information(None, _('Warning'), _('You are offline'), _('OK'))
                self.network.stop()
                self.network = None

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':

            self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText))

            if self.network:
                if wallet.is_found():
                    QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK'))
                else:
                    QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK'))
            else:
                QMessageBox.information(None, _('Information'), _("This wallet was restored offline. It may contain more addresses than displayed."), _('OK'))

        return wallet
示例#7
0
    conn = sqlite3.connect(database);
    # create table if needed
    check_create_table(conn)

    # init network
    config = SimpleConfig({'wallet_path':wallet_path})
    network = Network(config)
    network.start(wait=True)

    # create watching_only wallet
    storage = WalletStorage(config)
    wallet = Wallet(storage)
    if not storage.file_exists:
        wallet.seed = ''
        wallet.create_watching_only_wallet(master_public_key,master_chain)

    wallet.synchronize = lambda: None # prevent address creation by the wallet
    wallet.start_threads(network)
    network.register_callback('updated', on_wallet_update)
    
    out_queue = Queue.Queue()
    thread.start_new_thread(server_thread, (conn,))

    while not stopping:
        cur = conn.cursor()

        # read pending requests from table
        cur.execute("SELECT address, amount, confirmations FROM electrum_payments WHERE paid IS NULL;")
        data = cur.fetchall()
示例#8
0
    def run(self):

        action = self.restore_or_create()
        if not action: exit()

        wallet = Wallet(self.storage)
        gap = self.config.get('gap_limit', 5)
        if gap != 5:
            wallet.gap_limit = gap
            wallet.storage.put('gap_limit', gap, True)

        if action == 'create':
            wallet.init_seed(None)
            self.show_seed(wallet)
            if self.verify_seed(wallet):

                def create():
                    wallet.save_seed()
                    wallet.create_accounts()
                    wallet.synchronize()  # generate first addresses offline

                self.waiting_dialog(create)
            else:
                return

        elif action == 'restore':
            # ask for seed and gap.
            seed = self.seed_dialog()
            if not seed:
                return
            try:
                wallet.init_seed(seed)
            except:
                import traceback
                traceback.print_exc(file=sys.stdout)
                QMessageBox.warning(None, _('Error'), _('Incorrect seed'),
                                    _('OK'))
                return

            wallet.save_seed()

        elif action == 'watching':
            # ask for seed and gap.
            mpk = self.mpk_dialog()
            if not mpk:
                return
            wallet.seed = ''
            wallet.create_watching_only_wallet(mpk)

        else:
            raise

        #if not self.config.get('server'):
        if self.network:
            self.network_dialog()

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':

            self.waiting_dialog(
                lambda: wallet.restore(self.waiting_label.setText))

            if self.network:
                if wallet.is_found():
                    QMessageBox.information(None, _('Information'),
                                            _("Recovery successful"), _('OK'))
                else:
                    QMessageBox.information(
                        None, _('Information'),
                        _("No transactions found for this seed"), _('OK'))
            else:
                QMessageBox.information(
                    None, _('Information'),
                    _("This wallet was restored offline. It may contain more addresses than displayed."
                      ), _('OK'))

        self.password_dialog(wallet)

        return wallet