func (db *DB) GetBalance(pubkey *koblitz.PublicKey, param *coinparam.Params) (uint64, error) {
	var err error

	// Use the balance schema
	_, err = db.DBHandler.Exec("USE " + db.balanceSchema + ";")
	if err != nil {
		return 0, fmt.Errorf("Could not use balance schema: \n%s", err)
	}

	getBalanceQuery := fmt.Sprintf("SELECT balance FROM %s WHERE pubkey='%x';", param.Name, pubkey.SerializeCompressed())
	res, err := db.DBHandler.Query(getBalanceQuery)
	// db.IncrementReads()
	if err != nil {
		return 0, fmt.Errorf("Error when getting balance: \n%s", err)
	}

	amount := new(uint64)
	success := res.Next()
	if !success {
		return 0, fmt.Errorf("Database error: pubkey doesn't exist")
	}
	err = res.Scan(amount)
	if err != nil {
		return 0, fmt.Errorf("Error scanning for amount: \n%s", err)
	}

	err = res.Close()
	if err != nil {
		return 0, fmt.Errorf("Error closing balance result: \n%s", err)
	}

	return *amount, nil

}
// GetBalance gets the balance of an account
GetBalance gets the balance of an account
// GetBalance gets the balance of an account
func (db *DB) GetBalance(pubkey *koblitz.PublicKey, param *coinparam.Params) (uint64, error) {
	var err error
	_, err = db.DBHandler.Exec("USE " + db.balanceSchema + ";")
	if err != nil {
		return 0, fmt.Errorf("Could not use balance schema: \n%s", err)
	}
	getBalanceQuery := fmt.Sprintf("SELECT balance FROM %s WHERE pubkey='%x';", param.Name, pubkey.SerializeCompressed())
	res, err := db.DBHandler.Query(getBalanceQuery)
	if err != nil {
		return 0, fmt.Errorf("Error when getting balance: \n%s", err)
	}
	amount := new(uint64)
	success := res.Next()
	if !success {
		return 0, fmt.Errorf("Database error: pubkey doesn't exist")
	}
	err = res.Scan(amount)
	if err != nil {
		return 0, fmt.Errorf("Error scanning for amount: \n%s", err)
	}
	err = res.Close()
	if err != nil {
		return 0, fmt.Errorf("Error closing balance result: \n%s", err)
	}
	return *amount, nil
}
func ( db * DB ) GetBalance ( pubkey * koblitz . PublicKey , param * coinparam . Params ) ( uint64 , error ) { var err error _ , err = db . DBHandler . Exec ( " " + db . balanceSchema + " " ) if err != nil { return 0 , fmt . Errorf ( " \n " , err ) } getBalanceQuery := fmt . Sprintf ( " " , param . Name , pubkey . SerializeCompressed ( ) ) res , err := db . DBHandler . Query ( getBalanceQuery ) if err != nil { return 0 , fmt . Errorf ( " \n " , err ) } amount := new ( uint64 ) success := res . Next ( ) if ! success { return 0 , fmt . Errorf ( " " ) } err = res . Scan ( amount ) if err != nil { return 0 , fmt . Errorf ( " \n " , err ) } err = res . Close ( ) if err != nil { return 0 , fmt . Errorf ( " \n " , err ) } return * amount , nil }
GetBalance gets the balance of an account
GetBalance gets the balance of an account
// Use the balance schema // db.IncrementReads()