-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem.py
49 lines (33 loc) · 928 Bytes
/
system.py
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
from modules.blockchain import Blockchain
from modules.transactions import Transaction
from modules.digital_signature import generate_keys
# navid test ------------------------------
# we have 3 users
pu1, pv1 = generate_keys()
pu2, pv2 = generate_keys()
pu3, pv3 = generate_keys()
# miner user
pu4, pv4 = generate_keys()
# tx1
tx1 = Transaction(pu1)
tx1.add_input(pu2, 8)
tx1.add_output(pu3, 8)
tx1.signTransactionWith(pv1)
# tx2
tx2 = Transaction(pu2)
tx2.add_input(pu1, 1)
tx2.add_output(pu3, 1)
tx2.signTransactionWith(pv2)
# tx3
tx3 = Transaction(pu3)
tx3.add_input(pu1, 2)
tx3.add_output(pu3, 2)
tx3.signTransactionWith(pv3)
# creating blockchain
hyperChain = Blockchain()
hyperChain.createBlock([tx1, tx2, tx3])
print(hyperChain.blockList)
# # miner base -------------------------------------------------------------------
# tx4 = Transaction(pu4)
# tx4.add_output(pu4, 25)
# tx4.signTransactionWith(pv4)