package main import ( "fmt" "log" ) func (cli *CLI) getBalance(address string) { if !ValidateAddress(address) { log.Panic("ERROR: Address is not valid") } bc := NewBlockchain(address) defer bc.db.Close() balance := 0 pubKeyHash := Base58Decode([]byte(address)) pubKeyHash = pubKeyHash[1 : len(pubKeyHash)-4] UTXOs := bc.FindUTXO(pubKeyHash) for _, out := range UTXOs { balance += out.Value } fmt.Printf("Balance of '%s': %d\n", address, balance) }