*** THE REPO IS UNDER CONSTRUCTION - CHECK BACK SOON ***
A cryptocurrency (transaction based data) built on distributed decentralized multi-node P2P open Network using a sha256 Proof of Work (PoW) blockchain with a REST JSON API and a TCP Server to communicate between the Nodes over IP.
Or more simply, a distributed decentralized public ledger.
To dive right in, head down to RUN.
Table of Contents,
- BUILDING BLOCKS
- SOFTWARE ARCHITECTURE
- YOUR PASSWORD & KEYS
- RUN (WALLET ONLY)
- RUN (OPTIONAL)
Documentation and reference,
- I got a lot of inspiration here
- My software architecture is located in architecture.md
go get -v -u github.com/btcsuite/btcutil/base58 go get -v -u golang.org/x/crypto/ripemd160 go get -u -v github.com/gorilla/mux go get -u -v github.com/sirupsen/logrus go get -u -v github.com/pkg/errors go get -u -v github.com/satori/go.uuid go get -u -v golang.org/x/crypto/bcrypt
- GUI golang net/http package
- Routing & REST API framework golang gorilla/mux package
- Inter Node Communication golang TCP package
- Backend golang
- Database N/A
This project was built from some of my other projects,
- The TCP Server built from my simple-tcp-ip-server
jeffCoin (JEFF) is my interpretation of a transaction based (ledger) using a blockchain.
This is a work in progress I feel can be used as a foundation for
building bigger and better things.
The following illustration shows the jeffCoin Network of Nodes,
Coins (a.k.a jeffCoins) are minted as follows,
- A grand total of 1,000,000 jeffCoins
- The blockchain will not store jeffCoins but addies which are 1/1000 of a jeffCoin (.001 JEFF)
- The founders wallet will start with 100,000 jeffCoins (100,000,000 addies) (10% of all jeffCoins)
- Rewards 1 jeffCoin (1000 addies) every 10 minutes (144 jeffCoins/day or 52,560 jeffCoins/year)
- Will take 17.12 years to mint all the jeffCoins (900,000/52,560 = 17.12)
jeffCoin uses the following technology,
- Written in golang
- Implements a blockchain using a sha256 hash
- A distributed decentralized multi-node P2P architecture maintaining a Network of Nodes
- A Webserver with both a GUI and a REST API
- A TCP Server for inter-node communication
- ECDSA Private & Public Key generation
- Private Key AES-256 encryption for storage
- Creates a jeffCoin Address from the ECDSA Public Key (Just like bitcoin) currently not being used
- ECDSA Digital Signature Verification
- Mining uses Proof of Work (PoW)
- Transaction as stored using an unspent transaction output model
- Password hashing and storage using bcrypt
What jeffCoin does not have,
- No database, so if the entire Network dies, the chain dies
- Rigorous testing of all corner cases
This readme got too big so I moved my software explanation to architecture.md.
I divided the software into 5 sections,
- 1. BLOCKCHAIN
- 2. MINER
- 3. ROUTINGNODE
- 4. WALLET
- 5. WEBSERVER
YOUR PASSWORD & KEYS
Your secrets are kept in
/credentials in .json files.
These file are
But if they did make there way onto git you are still protected as follows,
- Password File
- Stores your password hash
- Password hashing using bcrypt
- Wallet File
- Stores your Private and Public ECDSA Key
- The Private Key is Encrypted using AES-256 with your password as your key
This illustration may help,
If this is you first time running and you want to create your own private Network, you need to create your first Node (Genesis Node). You only do this once. You can also set the log level (info, debug, trace) to cut down on the amount of logging.
go run jeffCoin.go \ -genesis \ -loglevel debug \ -nodehttpport 2000 \ -nodeip 127.0.0.1 \ -nodename Founders \ -nodetcpport 3000 \ -nodepassword fpw
This will created the first Node (the Founders Node) in the Network.
It will also create a wallet and password file and save the credentials
/password respectively. Not to worry, the password
is password hashed with bcrypt and your Wallet Private Key is encrypted
using AES-256. I also
Note that the node has an IP address and port for both HTTP and TCP. For this example I use the localhost or 127.0.0.1. But obviously, you can pick anything you want for your rig.
But having one node is boring so lets create more.
ADDING NEW NODES
To hook up to the Network you need the IP of any
working Network Node. If you have the above running Node
127.0.0.1:3000, adding a second Node
"Jeff" in your network could look like,
go run jeffCoin.go \ -loglevel debug \ -networkip 127.0.0.1 \ -networktcpport 3000 \ -nodehttpport 2001 \ -nodeip 127.0.0.1 \ -nodename Jeff \ -nodetcpport 3001 \ -nodepassword jpw
Why stop, might as well add a third Node,
go run jeffCoin.go \ -loglevel debug \ -networkip 127.0.0.1 \ -networktcpport 3000 \ -nodehttpport 2002 \ -nodeip 127.0.0.1 \ -nodename Matt \ -nodetcpport 3002 \ -nodepassword mpw
You will notice logging is set to
-debug. You can be more explicit
and set to
-trace or less wordy and set to
WEBSERVER & REST API
The GUI for the three nodes you just created are,
The API page will list the various API commands. For example, to show a particular block,
Each Node has it's own wallet, so now you can send jeffCoins/Value. To do this, use the Webserver and API. You will notice only the Founders have jeffCoins to send. So Jeff or Matt will not be able to send coins until the Founder gives them some.
Send some coins from the Founders to Jeff or Matt and note they are pending. That's because they are not validated. Like bitcoin, you will need to wait 10 minutes for a miner to solve the nonce and then for the Network to validate the transactions and reach consensus.
-h prints the following,
-gceIs this Node on Google Compute Engine (See below)
-genesisCreate your first Node
-loglevelstring LogLevel (info, debug or trace) (default "info")
-networkipstring Network IP (default "127.0.0.1")
-networktcpportstring Network TCP Port (default "3000")
-nodehttpportstring Node Web Port (default "2001")
-nodeipstring Node IP (default "127.0.0.1")
-nodenamestring Node Name (default "Jeff")
-nodepasswordstring Set/Reset your Password
-nodetcpportstring Node TCP Port (default "3001")
-testblockchainLoads the blockchain with test data (See below)
-vprints current version
walletOnly the wallet and webserver GUI/API (See below)
RUN (WALLET ONLY)
If you just want to have a wallet, use the
You will not be part of the Network since there is no blockchain
or miner. But you can always restart and become part of the Node.
You will need to hook up to a Node, so the following could work,
go run jeffCoin.go \ -loglevel debug \ -networkip 127.0.0.1 \ -networktcpport 3000 \ -nodehttpport 2005 \ -nodeip 127.0.0.1 \ -nodename Jills-Wallet \ -nodetcpport 3005 \ -nodepassword jpw \ -wallet
The Node and Wallet name are the same.
Here are some optional things you can do.
CONNECT USING TCP
You can also bypass the Webserver REST API and just open a connection to the TCP server itself,
netcat -q -1 127.0.0.1 3000
And request commands such as,
--- Waiting for command: SBC, BANN, SNL, BVB, BC, BTR, SAB, TR, EOF SNL [...nodeList...] thank you
Note you will need to handshake it with a
thank you at the end.
There is a complete list of commands in the architecture readme TCP REQUESTS & HANDLERS.
TEST MOCK TRANSACTIONS
If you add the
-test switch you will run some mock transactions from mock wallets.
Those wallets are located in
/wallets and just used for testing.
You must use the MockFounders nodename,
go run jeffCoin.go \ -genesis \ -loglevel debug \ -nodehttpport 2000 \ -nodeip 127.0.0.1 \ -nodename MockFounders \ -nodetcpport 3000 \ -nodepassword mfpw \ -testblockchain
These transactions are the same I used in my bitcoin-ledger example.
So your blockchain and pendingBlock should look similar to blockchain-output.txt.
And the balances in the blockchain should be,
The balance for MockFounders PubKey (Address) is 99657000 The balance for MockJeffs PubKey (Address) is 42500 The balance for MockMatts PubKey (Address) is 265000 The balance for MockJills PubKey (Address) is 35000 The balance for MockCoinVaults PubKey (Address) is 500
Remember, the pendingBlock is pending, so it's not part of this calculation. Transaction do not have value until they are part of the blockchain.
RUN ON GOOGLE COMPUTE ENGINE (GCE)
Make sure your create a firewall rule and have your instance use it as a network tag,
gcloud compute firewall-rules create jeffs-firewall-settings-rule \ --action allow \ --rules tcp:1234,tcp:3334 \ --priority 1000 \ --source-ranges 0.0.0.0/0 \ --target-tags "jeffs-firewall-settings" \ --description "Jeffs firewall rules"
0.0.0.0 gets forwarded to your external IP, hence I added a
-gce switch to deal with this,
go run jeffCoin.go \ -gce \ -genesis \ -loglevel debug \ -nodehttpport 1234 \ -nodeip 184.108.40.206 \ -nodename Founders \ -nodetcpport 3334 \ -nodepassword fpw
Add another node (not at gce) is as simple as connecting to it,
go run jeffCoin.go \ -loglevel debug \ -networkip 220.127.116.11 \ -networktcpport 3334 \ -nodehttpport 2003 \ -nodeip 127.0.0.1 \ -nodename Jill \ -nodetcpport 3003 \ -nodepassword jpw
I have a gce build example here.
There is no documentation for this package.