func CreateSettlementEngine(coin *coinparam.Params) (engine match.SettlementEngine, err error) {
	conf := new(dbsqlConfig)
	*conf = *defaultConf
	dbConfigSetup(conf)
	var addr net.Addr
	if addr, err = net.ResolveTCPAddr("tcp", net.JoinHostPort(conf.DBHost, fmt.Sprintf("%d", conf.DBPort))); err != nil {
		err = fmt.Errorf("Couldn't resolve db address for CreateSQLSettlementEngine: %s", err)
		return
	}
	se := &SQLSettlementEngine{
		dbUsername:    conf.DBUsername,
		dbPassword:    conf.DBPassword,
		balanceSchema: conf.BalanceSchemaName,
		dbAddr:        addr,
		coin:          coin,
	}
	if err = se.setupSettlementTables(); err != nil {
		err = fmt.Errorf("Error setting up settlement engine tables while creating engine: %s", err)
		return
	}
	openString := fmt.Sprintf("%s:%s@%s(%s)/", se.dbUsername, se.dbPassword, se.dbAddr.Network(), se.dbAddr.String())
	if se.DBHandler, err = sql.Open("mysql", openString); err != nil {
		err = fmt.Errorf("Error opening database for CreateSQLSettlementEngine: %s", err)
		return
	}
	if err = se.DBHandler.Ping(); err != nil {
		err = fmt.Errorf("Could not ping the database, is it running: %s", err)
		return
	}
	engine = se
	return
}
CreateSettlementEngine creates a settlement engine for a specific coin
package cxdbsql
import (
	"database/sql"
	"fmt"
	"net"
	_ "github.com/go-sql-driver/mysql"
	"github.com/mit-dci/lit/coinparam"
	"github.com/mit-dci/opencx/logging"
	"github.com/mit-dci/opencx/match"
)
type SQLSettlementEngine struct {
	DBHandler *sql.DB
	dbUsername string
	dbPassword string
	dbAddr net.Addr
	balanceSchema string
	coin *coinparam.Params
}
const (
	settlementEngineSchema = "pubkey VARBINARY(66), balance BIGINT(64), PRIMARY KEY (pubkey)"
)