def do_send(self): if not is_valid(self.str_recipient): print(_('Invalid Digibyte address')) return try: amount = int(Decimal(self.str_amount) * 100000000) except Exception: print(_('Invalid Amount')) return try: fee = int(Decimal(self.str_fee) * 100000000) except Exception: print(_('Invalid Fee')) return if self.wallet.use_encryption: password = self.password_dialog() if not password: return else: password = None c = "" while c != "y": c = raw_input("ok to send (y/n)?") if c == "n": return try: tx = self.wallet.mktx([(self.str_recipient, amount)], password, fee) except Exception as e: print(str(e)) return if self.str_description: self.wallet.labels[tx.hash()] = self.str_description h = self.wallet.send_tx(tx) print(_("Please wait...")) self.wallet.tx_event.wait() status, msg = self.wallet.receive_tx(h, tx) if status: print(_('Payment sent.')) #self.do_clear() #self.update_contacts_tab() else: print(_('Error'))
def make_new_contact(): code = droid.scanBarcode() r = code.result if r: data = r['extras']['SCAN_RESULT'] if data: if re.match('^auroracoin:', data): address, _, _, _, _ = util.parse_URI(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 address_field_changed(self, address): # label or alias, with address in brackets match2 = re.match("(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>", address) if match2: address = match2.group(2) self.address_input.setText(address) if is_valid(address): self.check_button_status() self.address_input.setProperty("isValid", True) self.recompute_style(self.address_input) else: self.send_button.setDisabled(True) self.address_input.setProperty("isValid", False) self.recompute_style(self.address_input) if len(address) == 0: self.address_input.setProperty("isValid", None) self.recompute_style(self.address_input)
def do_send(self): if not is_valid(self.str_recipient): self.show_message(_('Invalid Auroracoin address')) return try: amount = int(Decimal(self.str_amount) * 100000000) except Exception: self.show_message(_('Invalid Amount')) return try: fee = int(Decimal(self.str_fee) * 100000000) except Exception: self.show_message(_('Invalid Fee')) return if self.wallet.use_encryption: password = self.password_dialog() if not password: return else: password = None try: tx = self.wallet.mktx([(self.str_recipient, amount)], password, fee) except Exception as e: self.show_message(str(e)) return if self.str_description: self.wallet.labels[tx.hash()] = self.str_description h = self.wallet.send_tx(tx) self.show_message(_("Please wait..."), getchar=False) self.wallet.tx_event.wait() status, msg = self.wallet.receive_tx(h, tx) if status: self.show_message(_('Payment sent.')) self.do_clear() #self.update_contacts_tab() else: self.show_message(_('Error'))
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 auroracoin address') continue try: amount = int( 100000000 * Decimal(amount) ) except Exception: 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('^auroracoin:', data): payto, amount, label, _, _ = util.parse_URI(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
def send(self, address, amount, parent_window): """Send bitcoins to the target address.""" dest_address = self.fetch_destination(address) if dest_address is None or not is_valid(dest_address): QMessageBox.warning( parent_window, _('Error'), _('Invalid Digibyte Address') + ':\n' + address, _('OK')) return False amount = D(unicode(amount)) * (10 * self.g.decimal_point) print "amount", amount return if self.g.wallet.use_encryption: password_dialog = PasswordDialog(parent_window) password = password_dialog.run() if not password: return else: password = None fee = 0 # 0.1 BTC = 10000000 if amount < bitcoin(1) / 10: # 0.001 BTC fee = bitcoin(1) / 1000 try: tx = self.g.wallet.mktx([(dest_address, amount)], password, fee) except Exception as error: QMessageBox.warning(parent_window, _('Error'), str(error), _('OK')) return False if tx.is_complete(): h = self.g.wallet.send_tx(tx) self.waiting_dialog(lambda: False if self.g.wallet.tx_event.isSet( ) else _("Sending transaction, please wait...")) status, message = self.g.wallet.receive_tx(h, tx) if not status: import tempfile dumpf = tempfile.NamedTemporaryFile(delete=False) dumpf.write(tx) dumpf.close() print "Dumped error tx to", dumpf.name QMessageBox.warning(parent_window, _('Error'), message, _('OK')) return False TransactionWindow(message, self) else: filename = 'unsigned_tx_%s' % (time.mktime(time.gmtime())) try: fileName = QFileDialog.getSaveFileName( QWidget(), _("Select a transaction filename"), os.path.expanduser('~/%s' % (filename))) with open(fileName, 'w') as f: f.write(json.dumps(tx.as_dict(), indent=4) + '\n') QMessageBox.information( QWidget(), _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " + fileName, _('OK')) except Exception as e: QMessageBox.warning( QWidget(), _('Error'), _('Could not write transaction to file: %s' % e), _('OK')) return True