2017-09-10 00:53:06 -05:00
|
|
|
package main
|
|
|
|
|
2017-09-10 01:53:14 -05:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
)
|
2017-09-10 00:53:06 -05:00
|
|
|
|
|
|
|
func (cli *CLI) send(from, to string, amount int) {
|
2017-09-10 01:53:14 -05:00
|
|
|
if !ValidateAddress(from) {
|
|
|
|
log.Panic("ERROR: Sender address is not valid")
|
|
|
|
}
|
|
|
|
if !ValidateAddress(to) {
|
|
|
|
log.Panic("ERROR: Recipient address is not valid")
|
|
|
|
}
|
|
|
|
|
2017-09-10 00:53:06 -05:00
|
|
|
bc := NewBlockchain(from)
|
|
|
|
defer bc.db.Close()
|
|
|
|
|
|
|
|
tx := NewUTXOTransaction(from, to, amount, bc)
|
|
|
|
bc.MineBlock([]*Transaction{tx})
|
|
|
|
fmt.Println("Success!")
|
|
|
|
}
|