-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (26 loc) · 1.01 KB
/
main.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
32
33
34
35
package main
import (
"fmt"
"log"
"github.com/hugohenrick/blockchaingo/blockchain"
"github.com/hugohenrick/blockchaingo/wallet"
)
func intit() {
log.SetPrefix("Blockchain: ")
}
func main() {
walletM := wallet.NewWallet()
walletA := wallet.NewWallet()
walletB := wallet.NewWallet()
// Wallet
t := wallet.NewTranascation(walletA.PrivateKey(), walletA.PublicKey(), walletA.BlockChainAddress(), walletB.BlockChainAddress(), 1.0)
// Blockchain
blockchain := blockchain.NewBlockchain(walletM.BlockChainAddress())
isAdded := blockchain.AddTransaction(walletA.BlockChainAddress(), walletB.BlockChainAddress(), 1.0, walletA.PublicKey(), t.GenerateSiginature())
fmt.Println("Added? ", isAdded)
blockchain.Mining()
blockchain.Print()
fmt.Printf("Balance A %.1f\n", blockchain.CalculateTotalAmount(walletA.BlockChainAddress()))
fmt.Printf("Balance B %.1f\n", blockchain.CalculateTotalAmount(walletB.BlockChainAddress()))
fmt.Printf("Balance M %.1f\n", blockchain.CalculateTotalAmount(walletM.BlockChainAddress()))
}