-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.py
More file actions
31 lines (24 loc) · 743 Bytes
/
Copy pathTransaction.py
File metadata and controls
31 lines (24 loc) · 743 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
import copy
import time
import uuid
class Transaction:
def __init__(self, senderPubKey, receiverPubKey, amount, type):
self.senderPubKey = senderPubKey
self.receiverPubKey = receiverPubKey
self.amount = amount
self.type = type
self.id = uuid.uuid1().hex
self.timestamp = time.time()
self.signature = ''
def toJson(self):
return self.__dict__
def getPayload(self):
payload = copy.deepcopy(self.toJson())
payload['signature'] = ''
return payload
def sign(self, signature):
self.signature = signature
def equals(self, transaction):
if self.id == transaction.id:
return True
return False