Regex pubkey

This commit is contained in:
poka 2020-11-17 08:20:47 +01:00
parent 88650ac948
commit 98ccc9b6ae
2 changed files with 44 additions and 17 deletions

View File

@ -13,10 +13,21 @@ Website: www.zetcode.com
from tkinter import Tk, Text, TOP, BOTH, X, N, LEFT from tkinter import Tk, Text, TOP, BOTH, X, N, LEFT
from tkinter.ttk import Frame, Label, Entry, Button from tkinter.ttk import Frame, Label, Entry, Button
from libs.paylib import Transaction from libs.paylib import Transaction
import sys, threading
class StdoutRedirector(object):
def __init__(self, text_widget):
self.text_widget = text_widget
def write(self, s):
self.text_widget.insert('end', s)
self.text_widget.see('end')
def flush(self):
pass
class Pay(Frame): class Pay(Frame):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -39,8 +50,8 @@ class Pay(Frame):
frame2.pack(fill=X) frame2.pack(fill=X)
AmountLabel = Label(frame2, text="Montant:", width=12) AmountLabel = Label(frame2, text="Montant:", width=12)
AmountLabel.pack(side=LEFT, padx=5, pady=5) AmountLabel.pack(side=LEFT, padx=5, pady=5)
self.AmountEntry = Entry(frame2) self.AmountEntry = Entry(frame2, width=7)
self.AmountEntry.pack(fill=X, padx=5, expand=True) self.AmountEntry.pack(side=LEFT, padx=5)
frame3 = Frame(self) frame3 = Frame(self)
frame3.pack(fill=X) frame3.pack(fill=X)
@ -54,22 +65,36 @@ class Pay(Frame):
self.sendButton = Button(frame4, text="Envoyer", command=self.ProceedPaiement) self.sendButton = Button(frame4, text="Envoyer", command=self.ProceedPaiement)
self.sendButton.pack(side=LEFT, padx=5, pady=5, expand=True) self.sendButton.pack(side=LEFT, padx=5, pady=5, expand=True)
def ProceedPaiement(self): frame5 = Frame(self, width=200, height=300)
recipient = str(self.recipientEntry.get()) frame5.pack()
amount = int(self.AmountEntry.get()) self.textbox = Text(frame5, wrap='word')
comment = str(self.commentEntry.get()) self.textbox.pack()
print("Paiement en cours ... " + recipient) sys.stdout = StdoutRedirector(self.textbox)
trans = Transaction(recipient, amount, comment)
trans.send() def ProceedPaiement(self):
recipient = amount = comment = None try:
recipient = str(self.recipientEntry.get())
amount = int(self.AmountEntry.get())
except:
print("Please enter the recipient's public and the amount\n")
else:
comment = str(self.commentEntry.get())
print("Paiement en cours ... " + recipient)
trans = Transaction(recipient, amount, comment)
trans.send()
recipient = amount = comment = None
def main(): def main():
root = Tk() def starter():
root.geometry("300x130+300+300") root = Tk()
app = Pay() root.geometry("500x300+300+300")
root.mainloop() app = Pay()
root.mainloop()
thread = threading.Thread(target=starter)
thread.start()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -26,9 +26,11 @@ class Transaction():
self.comment = comment self.comment = comment
self.issuer = get_privkey(dunikey, "pubsec").pubkey self.issuer = get_privkey(dunikey, "pubsec").pubkey
def genDoc(self): if not re.match(r"(?![OIl])[1-9A-Za-z]{42,45}", self.recipient):
# TODO: Check args sys.stderr.write("Issuer pubkey is not to good format.\n")
sys.exit(1)
def genDoc(self):
# Build TX generation document # Build TX generation document
queryBuild = gql( queryBuild = gql(
""" """