-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.go
31 lines (24 loc) · 850 Bytes
/
test.go
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
package main
import (
"fmt"
"log"
"mad-blocks/block"
"mad-blocks/wallet"
)
func init() {
log.SetPrefix("MadBlocks: ")
}
func main() {
userA := wallet.NewWallet()
userB := wallet.NewWallet()
miner := wallet.NewWallet()
t := wallet.NewTransaction(userA.PrivateKey(), userA.PublicKey(), userA.Address(), userB.Address(), 1.0)
blockchain := block.NewBlockChain(miner.Address(), 8080)
isAdded := blockchain.AddTransaction(userA.Address(), userB.Address(), 1.0, userA.PublicKey(), t.GenerateSignature())
fmt.Println("Added: ", isAdded)
blockchain.Mining()
blockchain.Print()
fmt.Println("UserA: ", blockchain.BalanceOf(userA.Address()), "\t", userA.Address())
fmt.Println("UserB: ", blockchain.BalanceOf(userB.Address()), "\t", userB.Address())
fmt.Println("Miner: ", blockchain.BalanceOf(miner.Address()), "\t", miner.Address())
}