Implement rewards

This commit is contained in:
Ivan Kuznetsov 2017-09-17 09:16:50 +07:00
parent 402b298d4f
commit 56ccd7c8ca
2 changed files with 8 additions and 1 deletions

View File

@ -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 {

View File

@ -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!")
}