From 56ccd7c8caaea1782a52dd7affeec5a02b77b4f1 Mon Sep 17 00:00:00 2001 From: Ivan Kuznetsov Date: Sun, 17 Sep 2017 09:16:50 +0700 Subject: [PATCH] Implement rewards --- blockchain.go | 4 ++++ cli_send.go | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/blockchain.go b/blockchain.go index e2579fe..543ddc2 100644 --- a/blockchain.go +++ b/blockchain.go @@ -270,6 +270,10 @@ func (bc *Blockchain) SignTransaction(tx *Transaction, privKey ecdsa.PrivateKey) // VerifyTransaction verifies transaction input signatures func (bc *Blockchain) VerifyTransaction(tx *Transaction) bool { + if tx.IsCoinbase() { + return true + } + prevTXs := make(map[string]Transaction) for _, vin := range tx.Vin { diff --git a/cli_send.go b/cli_send.go index fb8117c..fea84d8 100644 --- a/cli_send.go +++ b/cli_send.go @@ -17,6 +17,9 @@ func (cli *CLI) send(from, to string, amount int) { defer bc.db.Close() tx := NewUTXOTransaction(from, to, amount, bc) - bc.MineBlock([]*Transaction{tx}) + cbTx := NewCoinbaseTX(from, "") + txs := []*Transaction{cbTx, tx} + + bc.MineBlock(txs) fmt.Println("Success!") }