def do_send(self): if not is_valid(self.str_recipient): print(_('Invalid DogecoinDark 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 newaddress_dialog(self, w): title = "New Contact" dialog = Gtk.Dialog(title, parent=self.window, flags=Gtk.DialogFlags.MODAL, buttons= ("cancel", 0, "ok",1) ) dialog.show() label = Gtk.HBox() label_label = Gtk.Label(label='Label:') label_label.set_size_request(120,10) label_label.show() label.pack_start(label_label, True, True, 0) label_entry = Gtk.Entry() label_entry.show() label.pack_start(label_entry, True, True, 0) label.show() dialog.vbox.pack_start(label, False, True, 5) address = Gtk.HBox() address_label = Gtk.Label(label='Address:') address_label.set_size_request(120,10) address_label.show() address.pack_start(address_label, True, True, 0) address_entry = Gtk.Entry() address_entry.show() address.pack_start(address_entry, True, True, 0) 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.contacts[label] = address self.update_sending_tab() else: errorDialog = Gtk.MessageDialog( parent=self.window, flags=Gtk.DialogFlags.MODAL, buttons= Gtk.ButtonsType.CLOSE, message_format = "Invalid address") errorDialog.show() errorDialog.run() errorDialog.destroy()
def do_send(self): if not is_valid(self.str_recipient): print(_('Invalid DogecoinDark 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 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 dogecoindarkcoin 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 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 DogecoinDark 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
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 dogecoindark address:\n"+to_address) return try: amount = int( Decimal(amount_entry.get_text()) * 100000000 ) except Exception: self.show_message( "invalid amount") return try: fee = int( Decimal(fee_entry.get_text()) * 100000000 ) except Exception: 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 Exception as e: self.show_message(str(e)) return if fee < tx.required_fee(self.wallet): self.show_message( "This transaction requires a higher fee, or it will not be propagated by the network." ) return if label: self.wallet.labels[tx.hash()] = label status, msg = self.wallet.sendtx( tx ) if status: self.show_message( "payment sent.\n" + msg ) payto_entry.set_text("") label_entry.set_text("") amount_entry.set_text("") fee_entry.set_text("") #self.fee_box.hide() self.update_sending_tab() else: self.show_message( msg )