How iseddik/blockchain works
Project Type and Purpose
• This is an academic Java application that simulates a simple, decentralized blockchain for monetary transactions.
• It is packaged as a NetBeans project (build.xml, nbproject folder) with source code under Sys/src and GUI forms under Sys/src/teste.
High‐Level Architecture Analysis
• Top‐level Packages:
• BlockChain – core blockchain logic (Blockchain.java)
• Utiles – cryptographic utilities (RSA keypair generation, SHA-256 hashing)
• teste – Swing‐based GUI and user‐interaction classes (wallet creation, block views, info screens)
• Build & Deployment:
• build.xml and nbproject/ define compilation targets.
• Sys/dist/ contains the runnable teste.jar and required javax.xml.bind.jar library.
Main Components
a. GUI Layer (Swing Forms)
• Forms: FirstVue, CreatWallet, Infos, VueBlock
• Responsibilities: Accept user input (create wallet, initiate transactions), display blockchain state.
b. Application Logic Layer
• teste.Wallet – represents user wallet, holds keypair and balance.
• teste.Block – data model for a single block (timestamp, previous hash, transactions).
• teste.Calculhash – controller to compute block hashes via Utiles.
c. Blockchain Core
• BlockChain.Blockchain – maintains the list of blocks, validates and adds new blocks, enforces proof-of-work.
d. Crypto Utilities
• Utiles.utiles – generates RSA keypairs, signs/verifies transactions, computes SHA-256 hashes.
e. Persistence/Storage (In‐Memory for Simulation)
• Blockchain held in a Java List/ArrayList in memory.
Relationships and Data Flow
• GUI → Application Logic: User actions (button clicks) trigger controller methods in teste.*
• Application Logic → Crypto Utilities: Calls to utiles.generateKeyPair(), utiles.applySha256(data), utiles.verifySignature().
• Application Logic → Blockchain Core: New blocks created by GUI controllers are passed to Blockchain.addBlock(block).
• Blockchain Core → Application Logic/GUI: After validation, the updated blockchain is pushed back to the GUI for display.
Architectural Patterns & Design Principles
• Layered Architecture: Separate GUI, business logic, core algorithm, and utilities.
• MVC Elements:
• Model: Block, Wallet, Blockchain
• View: .form files (Swing)
• Controller: Calculhash and event handlers in the .java GUI classes
• Single Responsibility: Each package has a clear role—core blockchain vs. crypto vs. presentation.