-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction.py
26 lines (20 loc) · 890 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
from collections import OrderedDict
from utility.printable import Printable
class Transaction(Printable):
"""A transaction which can be added to a block in the blockchain.
Attributes:
:sender: The sender of the coins.
:recipient: The recipient of the coins.
:signature: The signature of the transaction:
:amount: The amount of coins sent.
"""
def __init__(self, sender, recipient, signature, amount):
self.sender = sender
self.recipient = recipient
self.amount = amount
self.signature = signature
# Creating an ordered dict out of a given transaction. Used when order matters.
def to_ordered_dict(self):
return OrderedDict([('sender', self.sender),
('recipient', self.recipient),
('amount', self.amount)])