def make_new_contact(): code = droid.scanBarcode() r = code.result if r: data = str(r['extras']['SCAN_RESULT']).strip() if data: if re.match('^gamecredits:', 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 do_send(self): scrn = self.ids label = unicode(scrn.message_e.text) r = unicode(scrn.payto_e.text).strip() # label or alias, with address in brackets m = re.match('(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>', r) to_address = m.group(2) if m else r if not bitcoin.is_address(to_address): self.app.show_error(_('Invalid Gamecredits Address') + ':\n' + to_address) return amount = self.app.get_amount(scrn.amount_e.text) #fee = scrn.fee_e.amt #if not fee: # app.show_error(_('Invalid Fee')) # return fee = None message = 'sending {} {} to {}'.format(self.app.base_unit, scrn.amount_e.text, r) outputs = [('address', to_address, amount)] self.app.password_dialog(self.send_tx, (outputs, fee, label))
def parse_address(self, line): r = line.strip() m = re.match('^' + RE_ALIAS + '$', r) address = str(m.group(2) if m else r) assert bitcoin.is_address(address) return address
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 Gamecredits 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('^gamecredits:', data): rr = util.parse_URI(data) amount = rr.get('amount') address = rr.get('address') message = rr.get('message', '') if amount: amount = str(Decimal(amount)/COIN) droid.fullSetProperty("recipient", "text", address) 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
def parse_address(self, line): r = line.strip() m = re.match("^" + RE_ALIAS + "$", r) address = str(m.group(2) if m else r) assert bitcoin.is_address(address) return address
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 Gamecredits 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('^gamecredits:', data): rr = util.parse_URI(data) amount = rr.get('amount') address = rr.get('address') message = rr.get('message', '') if amount: amount = str(Decimal(amount) / COIN) droid.fullSetProperty("recipient", "text", address) 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