From e5ccaa88aa390c73a173e05eb55e181f59032980 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Tue, 6 Aug 2024 13:30:59 +0700 Subject: [PATCH] Create transaction.py --- blockchain/core/transaction.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 blockchain/core/transaction.py diff --git a/blockchain/core/transaction.py b/blockchain/core/transaction.py new file mode 100644 index 000000000..8b6be6b88 --- /dev/null +++ b/blockchain/core/transaction.py @@ -0,0 +1,20 @@ +from typing import List + +class Transaction: + def __init__(self, sender: str, receiver: str, amount: float): + self.sender = sender + self.receiver = receiver + self.amount = amount + + def __str__(self): + return f"Transaction - Sender: {self.sender}, Receiver: {self.receiver}, Amount: {self.amount}" + +class TransactionPool: + def __init__(self): + self.transactions = [] + + def add_transaction(self, transaction: Transaction): + self.transactions.append(transaction) + + def get_transactions(self): + return self.transactions