def set_url(self, url): out = parse_URI(url) address = out.get('address') message = out.get('message') amount = out.get('amount') self.notebook.set_current_page(1) self.payto_entry.set_text(address) self.message_entry.set_text(message) self.amount_entry.set_text(amount) self.payto_sig.set_visible(False)
def pay_from_URI(self, URI): try: out = util.parse_URI(URI) except: return address = out.get("address") amount = out.get("amount") amount_text = str(D(amount) / (10 ** self.actuator.g.decimal_point)) self.address_input.setText(address) self.address_field_changed(address) self.amount_input.setText(amount_text)
def make_new_contact(): code = droid.scanBarcode() r = code.result if r: data = str(r['extras']['SCAN_RESULT']).strip() if data: if re.match('^xmc:', data): out = util.parse_URI(data) address = out.get('address') elif is_address(data): address = data else: address = None if address: if modal_question('Add to contacts?', address): # fixme: ask for key contacts[address] = ('address', 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') message = droid.fullQueryDetail("message").result.get('text') amount = droid.fullQueryDetail('amount').result.get('text') if not is_address(recipient): modal_dialog('Error','Invalid XMC address') continue try: amount = int(COIN * Decimal(amount)) except Exception: modal_dialog('Error','Invalid amount') continue result = pay_to(recipient, amount, message) 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 = str(r['extras']['SCAN_RESULT']).strip() if data: print "data", data if re.match('^xmc:', data): payto, amount, label, message, _ = util.parse_URI(data) if amount: amount = str(amount / COIN) droid.fullSetProperty("recipient", "text", payto) droid.fullSetProperty("amount", "text", amount) droid.fullSetProperty("message", "text", message) elif is_address(data): droid.fullSetProperty("recipient", "text", data) else: modal_dialog('Error','cannot parse QR code\n'+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