Beispiel #1
0
    def newaddress_dialog(self, w):

        title = "New Contact"
        dialog = gtk.Dialog(
            title, parent=self.window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_NO_SEPARATOR, buttons=("cancel", 0, "ok", 1)
        )
        dialog.show()

        label = gtk.HBox()
        label_label = gtk.Label("Label:")
        label_label.set_size_request(120, 10)
        label_label.show()
        label.pack_start(label_label)
        label_entry = gtk.Entry()
        label_entry.show()
        label.pack_start(label_entry)
        label.show()
        dialog.vbox.pack_start(label, False, True, 5)

        address = gtk.HBox()
        address_label = gtk.Label("Address:")
        address_label.set_size_request(120, 10)
        address_label.show()
        address.pack_start(address_label)
        address_entry = gtk.Entry()
        address_entry.show()
        address.pack_start(address_entry)
        address.show()
        dialog.vbox.pack_start(address, False, True, 5)

        result = dialog.run()
        address = address_entry.get_text()
        label = label_entry.get_text()
        dialog.destroy()

        if result == 1:
            if is_valid(address):
                self.wallet.addressbook.append(address)
                if label:
                    self.wallet.labels[address] = label
                self.wallet.save()
                self.update_sending_tab()
            else:
                errorDialog = gtk.MessageDialog(
                    parent=self.window,
                    flags=gtk.DIALOG_MODAL,
                    buttons=gtk.BUTTONS_CLOSE,
                    message_format="Invalid address",
                )
                errorDialog.show()
                errorDialog.run()
                errorDialog.destroy()
Beispiel #2
0
    def do_send(self, w, data):
        payto_entry, label_entry, amount_entry, fee_entry = data
        label = label_entry.get_text()
        r = payto_entry.get_text()
        r = r.strip()

        m1 = re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', r)
        m2 = re.match(
            '(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+) \<([1-9A-HJ-NP-Za-km-z]{26,})\>',
            r)

        if m1:
            to_address = self.wallet.get_alias(r, True, self.show_message,
                                               self.question)
            if not to_address:
                return
            else:
                self.update_sending_tab()

        elif m2:
            to_address = m2.group(5)
        else:
            to_address = r

        if not is_valid(to_address):
            self.show_message("invalid bitcoin address:\n" + to_address)
            return

        try:
            amount = int(Decimal(amount_entry.get_text()) * 100000000)
        except:
            self.show_message("invalid amount")
            return
        try:
            fee = int(Decimal(fee_entry.get_text()) * 100000000)
        except:
            self.show_message("invalid fee")
            return

        if self.wallet.use_encryption:
            password = password_dialog(self.window)
            if not password:
                return
        else:
            password = None

        try:
            tx = self.wallet.mktx([(to_address, amount)], password, fee)
        except BaseException, e:
            self.show_message(str(e))
            return
Beispiel #3
0
    def newaddress_dialog(self, w):

        title = "New Contact"
        dialog = gtk.Dialog(title,
                            parent=self.window,
                            flags=gtk.DIALOG_MODAL | gtk.DIALOG_NO_SEPARATOR,
                            buttons=("cancel", 0, "ok", 1))
        dialog.show()

        label = gtk.HBox()
        label_label = gtk.Label('Label:')
        label_label.set_size_request(120, 10)
        label_label.show()
        label.pack_start(label_label)
        label_entry = gtk.Entry()
        label_entry.show()
        label.pack_start(label_entry)
        label.show()
        dialog.vbox.pack_start(label, False, True, 5)

        address = gtk.HBox()
        address_label = gtk.Label('Address:')
        address_label.set_size_request(120, 10)
        address_label.show()
        address.pack_start(address_label)
        address_entry = gtk.Entry()
        address_entry.show()
        address.pack_start(address_entry)
        address.show()
        dialog.vbox.pack_start(address, False, True, 5)

        result = dialog.run()
        address = address_entry.get_text()
        label = label_entry.get_text()
        dialog.destroy()

        if result == 1:
            if is_valid(address):
                self.wallet.add_contact(address, label)
                self.update_sending_tab()
            else:
                errorDialog = gtk.MessageDialog(
                    parent=self.window,
                    flags=gtk.DIALOG_MODAL,
                    buttons=gtk.BUTTONS_CLOSE,
                    message_format="Invalid address")
                errorDialog.show()
                errorDialog.run()
                errorDialog.destroy()
Beispiel #4
0
    def do_send(self, w, data):
        payto_entry, label_entry, amount_entry, fee_entry = data
        label = label_entry.get_text()
        r = payto_entry.get_text()
        r = r.strip()

        m1 = re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', r)
        m2 = re.match('(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+) \<([1-9A-HJ-NP-Za-km-z]{26,})\>', r)
        
        if m1:
            to_address = self.wallet.get_alias(r, True, self.show_message, self.question)
            if not to_address:
                return
            else:
                self.update_sending_tab()

        elif m2:
            to_address = m2.group(5)
        else:
            to_address = r

        if not is_valid(to_address):
            self.show_message( "invalid bitcoin address:\n"+to_address)
            return

        try:
            amount = int( Decimal(amount_entry.get_text()) * 100000000 )
        except:
            self.show_message( "invalid amount")
            return
        try:
            fee = int( Decimal(fee_entry.get_text()) * 100000000 )
        except:
            self.show_message( "invalid fee")
            return

        if self.wallet.use_encryption:
            password = password_dialog(self.window)
            if not password:
                return
        else:
            password = None

        try:
            tx = self.wallet.mktx( [(to_address, amount)], password, fee )
        except BaseException, e:
            self.show_message(str(e))
            return
Beispiel #5
0
def make_new_contact():
    code = droid.scanBarcode()
    r = code.result
    if r:
        data = r['extras']['SCAN_RESULT']
        if data:
            if re.match('^bitcoin:', data):
                address, _, _, _, _, _, _ = util.parse_url(data)
            elif is_valid(data):
                address = data
            else:
                address = None
            if address:
                if modal_question('Add to contacts?', address):
                    wallet.add_contact(address)
        else:
            modal_dialog('Invalid address', data)
Beispiel #6
0
def make_new_contact():
    code = droid.scanBarcode()
    r = code.result
    if r:
        data = r["extras"]["SCAN_RESULT"]
        if data:
            if re.match("^bitcoin:", data):
                address, _, _, _, _, _, _ = util.parse_url(data)
            elif is_valid(data):
                address = data
            else:
                address = None
            if address:
                if modal_question("Add to contacts?", address):
                    wallet.add_contact(address)
        else:
            modal_dialog("Invalid address", data)
def payto_loop():
    global recipient
    if recipient:
        droid.fullSetProperty("recipient","text",recipient)
        recipient = None

    out = None
    while out is None:
        event = droid.eventWait().result
        if not event: continue
        print "got event in payto loop", event
        if event == 'OK': continue
        if not event.get("name"): continue

        if event["name"] == "click":
            id = event["data"]["id"]

            if id=="buttonPay":

                droid.fullQuery()
                recipient = droid.fullQueryDetail("recipient").result.get('text')
                label  = droid.fullQueryDetail("label").result.get('text')
                amount = droid.fullQueryDetail('amount').result.get('text')

                if not is_valid(recipient):
                    modal_dialog('Error','Invalid Bitcoin address')
                    continue

                try:
                    amount = int( 100000000 * Decimal(amount) )
                except:
                    modal_dialog('Error','Invalid amount')
                    continue

                result = pay_to(recipient, amount, wallet.fee, label)
                if result:
                    out = 'main'

            elif id=="buttonContacts":
                addr = select_from_contacts()
                droid.fullSetProperty("recipient","text",addr)

            elif id=="buttonQR":
                code = droid.scanBarcode()
                r = code.result
                if r:
                    data = r['extras']['SCAN_RESULT']
                    if data:
                        if re.match('^bitcoin:', data):
                            payto, amount, label, _, _, _, _ = wallet.parse_url(data, None, lambda x: modal_question('Question', x))
                            droid.fullSetProperty("recipient", "text",payto)
                            droid.fullSetProperty("amount", "text", amount)
                            droid.fullSetProperty("label", "text", label)
                        else:
                            droid.fullSetProperty("recipient", "text", data)

                    
        elif event["name"] in menu_commands:
            out = event["name"]

        elif event["name"]=="key":
            if event["data"]["key"] == '4':
                out = 'main'

        #elif event["name"]=="screen":
        #    if event["data"]=="destroy":
        #        out = 'main'

    return out
Beispiel #8
0
def payto_loop():
    global recipient
    if recipient:
        droid.fullSetProperty("recipient","text",recipient)
        recipient = None

    out = None
    while out is None:
        event = droid.eventWait().result
        if not event: continue
        print "got event in payto loop", event
        if event == 'OK': continue
        if not event.get("name"): continue

        if event["name"] == "click":
            id = event["data"]["id"]

            if id=="buttonPay":

                droid.fullQuery()
                recipient = droid.fullQueryDetail("recipient").result.get('text')
                label  = droid.fullQueryDetail("label").result.get('text')
                amount = droid.fullQueryDetail('amount').result.get('text')

                if not is_valid(recipient):
                    modal_dialog('Error','Invalid Bitcoin address')
                    continue

                try:
                    amount = int( 100000000 * Decimal(amount) )
                except:
                    modal_dialog('Error','Invalid amount')
                    continue

                result = pay_to(recipient, amount, wallet.fee, label)
                if result:
                    out = 'main'

            elif id=="buttonContacts":
                addr = select_from_contacts()
                droid.fullSetProperty("recipient","text",addr)

            elif id=="buttonQR":
                code = droid.scanBarcode()
                r = code.result
                if r:
                    data = r['extras']['SCAN_RESULT']
                    if data:
                        if re.match('^bitcoin:', data):
                            payto, amount, label, _, _, _, _ = util.parse_url(data)
                            droid.fullSetProperty("recipient", "text",payto)
                            droid.fullSetProperty("amount", "text", amount)
                            droid.fullSetProperty("label", "text", label)
                        else:
                            droid.fullSetProperty("recipient", "text", data)

                    
        elif event["name"] in menu_commands:
            out = event["name"]

        elif event["name"]=="key":
            if event["data"]["key"] == '4':
                out = 'main'

        #elif event["name"]=="screen":
        #    if event["data"]=="destroy":
        #        out = 'main'

    return out
Beispiel #9
0
def payto_loop():
    global recipient
    if recipient:
        droid.fullSetProperty("recipient", "text", recipient)
        recipient = None

    out = None
    while out is None:
        event = droid.eventWait().result
        if not event:
            continue
        print "got event in payto loop", event
        if event == "OK":
            continue
        if not event.get("name"):
            continue

        if event["name"] == "click":
            id = event["data"]["id"]

            if id == "buttonPay":

                droid.fullQuery()
                recipient = droid.fullQueryDetail("recipient").result.get("text")
                label = droid.fullQueryDetail("label").result.get("text")
                amount = droid.fullQueryDetail("amount").result.get("text")

                if not is_valid(recipient):
                    modal_dialog("Error", "Invalid Bitcoin address")
                    continue

                try:
                    amount = int(100000000 * Decimal(amount))
                except:
                    modal_dialog("Error", "Invalid amount")
                    continue

                result = pay_to(recipient, amount, wallet.fee, label)
                if result:
                    out = "main"

            elif id == "buttonContacts":
                addr = select_from_contacts()
                droid.fullSetProperty("recipient", "text", addr)

            elif id == "buttonQR":
                code = droid.scanBarcode()
                r = code.result
                if r:
                    data = r["extras"]["SCAN_RESULT"]
                    if data:
                        if re.match("^bitcoin:", data):
                            payto, amount, label, _, _, _, _ = util.parse_url(data)
                            droid.fullSetProperty("recipient", "text", payto)
                            droid.fullSetProperty("amount", "text", amount)
                            droid.fullSetProperty("label", "text", label)
                        else:
                            droid.fullSetProperty("recipient", "text", data)

        elif event["name"] in menu_commands:
            out = event["name"]

        elif event["name"] == "key":
            if event["data"]["key"] == "4":
                out = "main"

        # elif event["name"]=="screen":
        #    if event["data"]=="destroy":
        #        out = 'main'

    return out