-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (38 loc) · 1008 Bytes
/
main.cpp
File metadata and controls
50 lines (38 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
#include "Blockchain.h"
#include "sha256.h" //Sha256 hashing algorithm
using namespace std;
using namespace myCoin;
//
//g++ -std=c++11 Blockchain.cpp Block.cpp main.cpp sha256.cpp
int main(){
Blockchain blockchain;
int choice;
while(choice != 5){
cout << "1. VIEW TRANSACTIONS\n"<< "2. CREATE TRANSACTION\n" <<
"3. GENERATE BLOCK\n" << "4. VALIDATE\n" << "5. EXIT\n";
cin >> choice;
if(choice == 1){
cout << blockchain;
}else if(choice == 2){
string name;
cout << "Enter Name: ";
cin >> name;
double amount;
cout << "Enter Amount: ";
cin >> amount;
blockchain.createTransaction(name,amount);
}else if(choice == 3){
blockchain.createTransaction("NULL",0);
}else if(choice == 4){
cout << ( blockchain.isValidChain()
? "Chain is valid" : "Chain is invalid") << endl << endl;
}else if(choice == 5){
break;
}else{
cout << "Invalid Choice!" << endl;
}
}
return 0;
}