-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction.py
32 lines (25 loc) · 874 Bytes
/
transaction.py
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
from collections import OrderedDict
from utility.printable import Printable
class Transaction(Printable):
def __init__(self, sender, recipient, signature, amount):
"""
A Transaction which can be added to a block in the blockchain
:param sender: The sender of the coins
:param recipient: The receiver of the coins
:param signature: The signature of the transaction
:param amount: The amount of coins sent
"""
self.sender = sender
self.recipient = recipient
self.amount = amount
self.signature = signature
def to_ordered_dict(self):
"""
Convert Transaction to OrderedDict
:return:
"""
return OrderedDict([
('sender', self.sender),
('recipient', self.recipient),
('amount', self.amount)
])