-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.py
More file actions
32 lines (25 loc) · 805 Bytes
/
Transaction.py
File metadata and controls
32 lines (25 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import uuid
import time
import copy
class Transaction():
def __init__(self, senderPublicKey, receiverPublicKey, amount, type):
self.senderPublicKey = senderPublicKey
self.receiverPublicKey = receiverPublicKey
self.amount = amount
self.type = type
self.id = (uuid.uuid1()).hex
self.timestamp = time.time()
self.signature = ''
def toJson(self):
return self.__dict__
def sign(self, signature):
self.signature = signature
def payload(self):
jsonRepresentation = copy.deepcopy(self.toJson())
jsonRepresentation['signature'] = ''
return jsonRepresentation
def equals(self, transaction):
if self.id == transaction.id:
return True
else:
return False