This is a fork of the JBlockchain project (https://github.com/neozo-software/jblockchain).
I forked and extended his demo project for creating a new blockchain in Java which you can also use for productive private (or public) blockchains. Here I added a demo case as use in a decentral blockchain government for handling purposes of normal citizens. Citizens can be added to the blockchain, their marriage or divorce can be added as social status. Also their new born children can be added or citizens can be declared or alive. Thus a whole society can simply control itself via a blockchain 3.0. The blockchain can and should be fitted and compiled to your special needs. Forks are welcome under Apache 2.0 license.
Fork License-Appendix:
Copyright 2018, Philip Kretz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- saving CPU power and voltage by replacing SHA256-algorithm with SCrypt
- added a more complex self ip discovery algorithm similar to Bitcoin
- added a backbone network of trusted root servers, which must be added in config class
- blockchain and entity data are saved, so hosts can go offline (json.gz files)
- saving disk space and data transfer size with gunzip algorithm for transferring and saving data
- added multiple config parameters for client that you must not submit address for communication with nodes
- added a blockchain government as demo case in client
- keys and blockchain files are saved in folder HOME/blockchain
- edit config class and files for setting port (default: 21986) and root servers (default: only localhost)
cd jblockchain-government ./mvnw package
Note: if jar-files do not get generated, it can be a solution to run "mvn clean install" from project main folder!
please respect: all json.gz for blockchain files will be deleted after compiling because of unit test case issues, so please create a backup if you change something!
This builds these 3 Spring Boot/Maven modules:
- node: part of the blockchain network for handling proof of work mining algorithm, building blocks and distributing transactions
- client: a shell client to communicate to local blockchain node
- common: Shared code with entities used by the other 2 components
java -jar node/target/node-0.0.1-SNAPSHOT.jar
java -jar client/target/client-0.0.1-SNAPSHOT.jar --start-miner
java -jar client/target/client-0.0.1-SNAPSHOT.jar --stop-miner
This generates key.priv and key.pub files for user (as you should know in encryption: never share your key.priv-file and keep it as safe as possible).
The local node will distribute this new public address to all other nodes by invoking the publish-address command.
If you did not note it, you will find it via http://localhost:21986/address at the bottom of the list ;-)
cd client/target java -jar client-0.0.1-SNAPSHOT.jar --keypair
java -jar client/target/client-0.0.1-SNAPSHOT.jar --publish-address --publickey key.pub
java -jar client/target/client-0.0.1-SNAPSHOT.jar --transaction --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --message "Hallo Welt" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --add-city --city "Springfield" --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --add-street --name "Simpson av." --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --add-house --houseNr 23 --street "Simpson av." --city "Springfield" --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --add-citizen --firstName Homer --lastName Simpson --birthday 19540204 --father "Grandpa Simpson" --mother "Unknown" --address "Simpson av. 23, Springfield" --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --set-address --firstName Bart --lastName Simpson --address "Tree house" --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --marriage --person1 "Homer Simpson" --person2 "Marge Simpson" --date 19740523 --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --divorce --person1 "Whitney Tears" --person2 "Lars Vegas" --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --declare-death --firstName Pablo --lastName Escobar --date 19930212 --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
declare a citizen alive after death (if a mistake occures, a lost person gets found or also after 3 days for Jesus)
java -jar client/target/client-0.0.1-SNAPSHOT.jar --declare-alive --name Jesus --sender "Tdz0bKDfca3QjFAe5Ccuj9Noy6ah8n+R8DnZznvjic4=" --privatekey key.priv
java -jar client/target/client-0.0.1-SNAPSHOT.jar --show-cities
java -jar client/target/client-0.0.1-SNAPSHOT.jar --show-citizens --city Springfield
java -jar client/target/client-0.0.1-SNAPSHOT.jar --show-citizen-details --name "Homer Simpson" --city Springfield
java -jar client/target/client-0.0.1-SNAPSHOT.jar --show-birth-death-rate --city Springfield