-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
26 lines (20 loc) · 1.06 KB
/
main.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
from src.blockchain import Blockchain, Transaction
from src.keyGenerator import loadKeyPair
if __name__ == '__main__':
pySavjeeCoin = Blockchain()
myPublicKey, myPrivateKey = loadKeyPair('./key', mark='my')
hisPublicKey, hisPrivateKey = loadKeyPair('./key', mark='his')
print('INFO: MY PUBLIC KEY IS {}'.format(myPublicKey))
print('INFO: HIS PUBLIC KEY IS {}'.format(hisPublicKey))
tx1 = Transaction(myPublicKey, hisPublicKey, 10)
tx1.signTransaction(myPublicKey, myPrivateKey)
pySavjeeCoin.addTransaction(tx1, myPublicKey)
print('INFO: START MINING...')
pySavjeeCoin.minePendingTransactions(myPublicKey)
tx2 = Transaction(myPublicKey, hisPublicKey, 20)
tx2.signTransaction(myPublicKey, myPrivateKey)
pySavjeeCoin.addTransaction(tx2, myPublicKey)
print('INFO: START MINING...')
pySavjeeCoin.minePendingTransactions(myPublicKey)
print('INFO: BALANCE OF {} is {}'.format(myPublicKey, pySavjeeCoin.getBalanceAddress(myPublicKey)))
print('INFO: THE CHAIN IS VALID? {}'.format(pySavjeeCoin.isChainValid(myPublicKey)))