/blockchain

Primary LanguagePython

project-logo

BLOCKCHAIN

Securing the future, one block at a time.

license last-commit repo-top-language repo-language-count


Table of Contents

Overview

The BlockchainX project implements a decentralized blockchain network with core functionalities encompassing secure transaction handling, mining operations, and blockchain integrity maintenance. Transaction classes ensure data integrity using hashing and signatures, while UTXO ledger management ensures accurate balance updates. Nodes manage peer connections, mempool transactions, and blockchain synchronization, enhancing network efficiency. Wallet generation and mining processes further strengthen blockchain security. This project's value lies in its robust architecture that facilitates secure, efficient, and decentralized transactions within a trustless network.


Repository Structure

└── blockchain/
    ├── Blockchain
    │   ├── Blockchain.py
    │   ├── __pycache__
    │   └── utxo_utils.py
    ├── Node
    │   ├── BlockchainNode.py
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── dataManager
    │   └── utils.py
    ├── README.md
    ├── __pycache__
    │   └── blockchain.cpython-311.pyc
    ├── block
    │   ├── Block.py
    │   └── __pycache__
    ├── mining
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── mining.py
    │   └── mining_test
    ├── tests
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── integration
    │   └── unit
    ├── transaction
    │   ├── CoinbaseTransaction.py
    │   ├── Transaction.py
    │   ├── TransactionData.py
    │   └── __pycache__
    └── user
        ├── Wallet.py
        └── __pycache__

Modules

transaction
File Summary
Transaction.py Implements transaction classes ensuring secure data transfer with hashes and signatures. Validates transaction integrity based on size, key matches, and signature verification. Maintains transaction timestamp and ID.
CoinbaseTransaction.py Defines and validates a coinbase transactions output, ensuring transaction integrity within the blockchain network by serializing and checking transaction validity against predefined rules and size limits.
TransactionData.py Defines and serializes transaction data including sender and receiver public keys, amount, timestamp, and a unique identifier. An essential component within the blockchain architecture for handling transaction information efficiently.
user
File Summary
Wallet.py Generates wallet address through ECC-Signs transaction data with private key-Handles key pair generation-Essential for secure transaction signing in the blockchain architecture.
mining
File Summary
mining.py Initiate blockchain server, connect to gateway node, prompt for miners public key generation or input, then commence mining process with validated blocks sent to all network nodes before stopping server.
mining.mining_test
File Summary
test_connection_network.py Simulates network connections and interactions between blockchain nodes. Establishes communication with a gateway node, shares blocks, and prints chain details. Emulates start and stop operations to test network functionality.
Blockchain
File Summary
utxo_utils.py Handles ledger management by updating receiver and sender balances based on transactions in a blockchain system. Ensures transaction validity before ledger updates.
Blockchain.py Manages blockchain integrity through mining, validation, and UTXO set construction. Verifies blocks, transactions, tree consistency, and inclusion, upholding blockchain integrity and security. Key methods include mining, validation checks, and UTXO set creation.
Node
File Summary
BlockchainNode.py Defines a BlockchainNode in the network, managing peers, mempool, and blockchain. It handles node connections, messages, transactions, and data exchanges. Incorporates key functionalities like connecting to nodes, adding transactions to mempool, and managing node disconnections.
utils.py Implements peer removal logic for the Node component, enabling the removal of a specific peer from the list by matching its address and port.
Node.dataManager
File Summary
manageMempool.py Manages mempool transactions for validation and storage, enhancing node functionality within the blockchain architecture.
manageNewBlock.py Manages addition of new blocks to the blockchain chain, ensuring integrity and syncing with peers. Automatically adds valid blocks from peers and updates the local blockchain.
managePeers.py Manages peer connections by connecting and adding new peers to the network.
manageBlockchain.py Manages blockchain synchronization by updating with a valid chain, removing confirmed transactions from the mempool.
block
File Summary
Block.py Defines and manages the properties and methods of a blockchain block, facilitating hashing, mining, and verification. Required for the blockchains integrity and security.

Getting Started

System Requirements:

  • Python: version x.y.z

Installation

From source

  1. Clone the blockchain repository:
$ git clone https://github.com/neoff69/blockchain
  1. Change to the project directory:
$ cd blockchain

Usage

From source

  1. Use the virtual environment:
$ source venv/bin/activate
  1. Start mining::
$ python -m mining.mining

Tests

Run the test suite using the command below:

$ python -m unittest discover -s tests -p 'test_*.py'

Project Roadmap

  • ► Add multi threading for new block detection
  • ► Fix the merkle tree for verification
  • ► Add a graphic interface

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/neoff69/blockchain
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph