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.ttk import Frame, Label, Entry, Button
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):
def __init__(self):
super().__init__()
@ -39,8 +50,8 @@ class Pay(Frame):
frame2.pack(fill=X)
AmountLabel = Label(frame2, text="Montant:", width=12)
AmountLabel.pack(side=LEFT, padx=5, pady=5)
self.AmountEntry = Entry(frame2)
self.AmountEntry.pack(fill=X, padx=5, expand=True)
self.AmountEntry = Entry(frame2, width=7)
self.AmountEntry.pack(side=LEFT, padx=5)
frame3 = Frame(self)
frame3.pack(fill=X)
@ -54,22 +65,36 @@ class Pay(Frame):
self.sendButton = Button(frame4, text="Envoyer", command=self.ProceedPaiement)
self.sendButton.pack(side=LEFT, padx=5, pady=5, expand=True)
def ProceedPaiement(self):
recipient = str(self.recipientEntry.get())
amount = int(self.AmountEntry.get())
comment = str(self.commentEntry.get())
print("Paiement en cours ... " + recipient)
frame5 = Frame(self, width=200, height=300)
frame5.pack()
self.textbox = Text(frame5, wrap='word')
self.textbox.pack()
sys.stdout = StdoutRedirector(self.textbox)
trans = Transaction(recipient, amount, comment)
trans.send()
recipient = amount = comment = None
def ProceedPaiement(self):
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():
root = Tk()
root.geometry("300x130+300+300")
app = Pay()
root.mainloop()
def starter():
root = Tk()
root.geometry("500x300+300+300")
app = Pay()
root.mainloop()
thread = threading.Thread(target=starter)
thread.start()
if __name__ == '__main__':

View File

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