Browse Source

small changes in gui_helpers

justtheboss97 4 năm trước cách đây
mục cha
commit
0eb626ba40
1 tập tin đã thay đổi với 12 bổ sung8 xóa
  1. 12 8
      gui/gui_helpers.py

+ 12 - 8
gui/gui_helpers.py

@@ -5,6 +5,8 @@ from lib.contract import Contract
 from lib.block import CURRENT
 from create_keys import get_keys
 import rpyc
+import time
+import json
 
 def add_contract():
 
@@ -47,14 +49,16 @@ def add_contract():
             r = recipient.get()
             transaction1.hash(recipient=r)
 
-            # get the contract with transaction1.data
-            # add reciever and sender keys and data
-            # maybe the intital block value and modyfied by and state values
-            # hash it with the public key of the reciever
-            # send to push_transaction(hashed:str)
-            # hashed has the format: {’sender’:..,’receiver’:…, ‘data’:encrypted contract} (see github readme)
-            # deamon does the rest
-            conn.root.push_transaction({'sender':get_keys(sender.get()), 'reciever':get_keys(recipient.get()), 'data':transaction1.hash_value})           
+            transaction1.timestamp = time.time()
+
+            # keys need to be in plain text, otherwise the json dump fucks up
+            transaction1.sender = get_keys(sender.get())
+            transaction1.receiver = get_keys(recipient.get())
+            transaction1.data = transaction1.hash_value
+            output = transaction1.serialize()
+            print(output, type(output))
+
+            conn.root.push_transaction(output)           
             conn.close()
             term_window.destroy()
             newWindow.destroy()