|
|
@@ -3,17 +3,24 @@ from lib.chain import Chain, Block
|
|
|
from lib.transaction import Transaction
|
|
|
from lib.contract import Contract
|
|
|
from lib.block import CURRENT
|
|
|
-
|
|
|
+from create_keys import get_keys
|
|
|
+import rpyc
|
|
|
|
|
|
def add_contract():
|
|
|
|
|
|
# add contract to the blockchain
|
|
|
def add():
|
|
|
contract1 = Contract()
|
|
|
+ s = get_keys(sender.get())
|
|
|
+ r = get_keys(recipient.get())
|
|
|
+
|
|
|
contract1.create(title=title.get(),
|
|
|
desc=description.get(),
|
|
|
deadline=int(deadline.get()),
|
|
|
- price=float(price.get()))
|
|
|
+ price=float(price.get()),
|
|
|
+ state = False,
|
|
|
+ client=s,
|
|
|
+ contractor=r)
|
|
|
|
|
|
|
|
|
add_term(contract1)
|
|
|
@@ -32,6 +39,8 @@ def add_contract():
|
|
|
add_term(contract1)
|
|
|
|
|
|
def complete():
|
|
|
+ conn = rpyc.connect(host='localhost', port=42069, keepalive=True)
|
|
|
+
|
|
|
# Bind contract to transaction
|
|
|
transaction1 = Transaction()
|
|
|
transaction1.set_contract(contract=contract1)
|
|
|
@@ -45,11 +54,8 @@ def add_contract():
|
|
|
# send to push_transaction(hashed:str)
|
|
|
# hashed has the format: {’sender’:..,’receiver’:…, ‘data’:encrypted contract} (see github readme)
|
|
|
# deamon does the rest
|
|
|
-
|
|
|
- print(transaction1.hash_value)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ conn.root.push_transaction({'sender':get_keys(sender.get()), 'reciever':get_keys(recipient.get()), 'data':transaction1.hash_value})
|
|
|
+ conn.close()
|
|
|
term_window.destroy()
|
|
|
newWindow.destroy()
|
|
|
|
|
|
@@ -98,12 +104,16 @@ def add_contract():
|
|
|
price = Entry(newWindow, width=35, borderwidth=5)
|
|
|
price.grid(row=3, column=1, columnspan=3, padx=10, pady=10)
|
|
|
|
|
|
- Label(newWindow, text='Recipient: ').grid(row=4, column=0)
|
|
|
+ Label(newWindow, text='Sender: ').grid(row=4, column=0)
|
|
|
+ sender = Entry(newWindow, width=35, borderwidth=5)
|
|
|
+ sender.grid(row=4, column=1, columnspan=3, padx=10, pady=10)
|
|
|
+
|
|
|
+ Label(newWindow, text='Recipient: ').grid(row=5, column=0)
|
|
|
recipient = Entry(newWindow, width=35, borderwidth=5)
|
|
|
- recipient.grid(row=4, column=1, columnspan=3, padx=10, pady=10)
|
|
|
+ recipient.grid(row=5, column=1, columnspan=3, padx=10, pady=10)
|
|
|
|
|
|
# create the add contract button
|
|
|
- Button(newWindow, text = "Create contract", command=add).grid(row=5, column=1)
|
|
|
+ Button(newWindow, text = "Create contract", command=add).grid(row=6, column=1)
|
|
|
|
|
|
|
|
|
|