<?xml version="1.0" encoding="us-ascii"?><InstanceReport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Version>2.4.0.8</Version><ReportLongName>0015 - Disclosure - Commitments and contingencies</ReportLongName><DisplayLabelColumn>true</DisplayLabelColumn><ShowElementNames>false</ShowElementNames><RoundingOption /><HasEmbeddedReports>false</HasEmbeddedReports><Columns><Column FlagID="0"><Id>1</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><CurrencyCode /><FootnoteIndexer /><hasSegments>false</hasSegments><hasScenarios>false</hasScenarios><MCU><KeyName /><CurrencySymbol /><contextRef><ContextID>From2013-01-01to2013-06-30</ContextID><EntitySchema>http://www.sec.gov/CIK</EntitySchema><EntityValue>0001373485</EntityValue><PeriodDisplayName /><PeriodType>duration</PeriodType><PeriodStartDate>2013-01-01T00:00:00</PeriodStartDate><PeriodEndDate>2013-06-30T00:00:00</PeriodEndDate><Segments /><Scenarios /></contextRef><UPS /><CurrencyCode /><OriginalCurrencyCode /></MCU><CurrencySymbol /><Labels><Label Key="CalendarSupplement" Id="0" Label="6 Months Ended" /><Label Key="Calendar" Id="1" Label="Jun. 30, 2013" /></Labels></Column></Columns><Rows><Row FlagID="0"><Id>1</Id><IsAbstractGroupTitle>true</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>1</Level><ElementName>XBOR_CommitmentsAndContingenciesAbstract</ElementName><ElementPrefix>XBOR_</ElementPrefix><IsBaseElement>false</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText /><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>xbrli:stringItemType</ElementDataType><SimpleDataType>string</SimpleDataType><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Commitments And Contingencies</Label></Row><Row FlagID="0"><Id>2</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>2</Level><ElementName>us-gaap_CommitmentsAndContingenciesDisclosureTextBlock</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="From2013-01-01to2013-06-30" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText>&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: center"&gt;&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: bold 10pt Times New Roman"&gt;10 &amp;#8211; Commitments and contingencies&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;&lt;font style="display: inline; text-decoration: underline"&gt;Litigation&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;div style="text-indent: 36pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;On May 4, 2011, Clifton M. (Marty) Bloodworth filed a lawsuit in the State District Court of Midland County, Texas, against Doral West Corp. d/b/a Doral Energy Corp. and Everett Willard Gray II.&amp;#160;&amp;#160;Mr. Bloodworth alleges that Mr. Gray, as CEO of the Company, made false representations which induced Mr. Bloodworth to enter into an employment contract that was subsequently breached by the Company.&amp;#160;&amp;#160;The claims that Mr. Bloodworth has alleged are:&amp;#160;&amp;#160;breach of his employment agreement with Doral, common law fraud, civil conspiracy breach of fiduciary duty, and violation of the Texas Deceptive Trade Practices-Consumer Protection Act.&amp;#160;&amp;#160;Mr. Bloodworth is seeking damages of approximately $280,000.&amp;#160;&amp;#160;Mr. Gray and the Company deny that Mr. Bloodworth&amp;#8217;s claims have any merit.&amp;#160;&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 36pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;
&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: justify"&gt;&amp;#160;&lt;/div&gt;

&lt;div style="text-indent: 36pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;&lt;font style="background-color: #ffffff; display: inline"&gt;The Company&amp;#160;was previously party to an engagement letter, dated February 7, 2012 (the &lt;/font&gt;&lt;font style="background-color: #ffffff; display: inline"&gt;"Engagement Letter"), with KeyBanc Capital Markets Inc. ("KeyBanc") pursuant to which KeyBanc was to act as exclusive financial advisor to the Company&amp;#8217;s Board of Directors in connection with a possible "Transaction" (as defined in the Engagement Letter).&amp;#160;&amp;#160;The Engagement Letter was formally terminated by the Company on August 21, 2012. The Engagement Letter provided that KeyBanc would be entitled to a fee upon consummation of a Transaction within a certain period of time following termination of the Engagement Letter. On May 16, 2013, KeyBanc delivered an invoice to the Company in the amount of $751,334, representing amounts purportedly owed by the Company to KeyBanc as a result of the consummation of a purported Transaction KeyBanc asserts had been consummated within the required time period and its out-of-pocket expenses in connection therewith.&amp;#160; The Company disputes that any Transaction was consummated and that KeyBanc is entitled to any out-of-pocket expenses.&amp;#160; The matter was originally filed in the 44th-B Judicial District Court for the State of Texas, Dallas County but was subsequently removed to the United States District Court for the Northern District of Texas, Dallas Division.&amp;#160; The Company intends to vigorously defend the action.&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;



&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;&lt;font style="display: inline; text-decoration: underline"&gt;Environmental Contingencies&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;div style="text-indent: 36pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;The Company is subject to federal and state laws and regulations relating to the protection of the environment.&amp;#160; Environmental risk is inherent to oil and natural gas operations and the Company could be subject to environmental cleanup and enforcement actions.&amp;#160;&amp;#160;The Company manages this environmental risk through appropriate environmental policies and practices to minimize the impact to the Company.&lt;/font&gt;&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block"&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;div style="text-indent: 0pt; display: block; margin-left: 0pt; margin-right: 0pt; text-align: left"&gt;&lt;font style="display: inline; font: 10pt Times New Roman"&gt;&lt;font id="TAB1" style="margin-left: 36pt"&gt;&lt;/font&gt;As of June 30, 2013,&amp;#160;the&amp;#160;Company had&amp;#160;approximately $2,100,000 in environmental liabilities related to&amp;#160;its operated Tom Tom Tomahawk field located in Chaves and Roosevelt counties New Mexico.&amp;#160;&amp;#160;In February 2013, the Bureau of Land Management (&amp;#8220;BLM&amp;#8221;) accepted the Company&amp;#8217;s remediation plan for the Tom Tom and Tomahawk fields.&amp;#160;&amp;#160;The Company is working in conjunction with the BLM to initiate remediation on a site-by-site basis.&amp;#160;&amp;#160;This is management&amp;#8217;s best estimate of the costs of remediation and restoration with respect to these environmental matters, although the ultimate cost could differ materially.&amp;#160;&amp;#160;Inherent uncertainties exist in these estimates due to unknown conditions, changing governmental regulation, and legal standards regarding liability, and emerging remediation technologies for handling site remediation and restoration.&amp;#160;&amp;#160;The Company expects to incur these expenditures over a twenty-four month period beginning in April 2013.&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;</NonNumbericText><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>nonnum:textBlockItemType</ElementDataType><SimpleDataType>na</SimpleDataType><ElementDefenition>The entire disclosure for commitments and contingencies.</ElementDefenition><ElementReferences>Reference 1: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 210

 -SubTopic 10

 -Section S99

 -Paragraph 1

 -Subparagraph (SX 210.5-02.25)

 -URI http://asc.fasb.org/extlink&amp;oid=6877327&amp;loc=d3e13212-122682



Reference 2: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 825

 -SubTopic 20

 -Section 50

 -Paragraph 1

 -URI http://asc.fasb.org/extlink&amp;oid=6449706&amp;loc=d3e16207-108621



Reference 3: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 460

 -SubTopic 10

 -Section 50

 -Paragraph 8

 -URI http://asc.fasb.org/extlink&amp;oid=6398077&amp;loc=d3e12565-110249



Reference 4: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 450

 -SubTopic 20

 -Section 50

 -Paragraph 4

 -URI http://asc.fasb.org/extlink&amp;oid=25496072&amp;loc=d3e14435-108349



Reference 5: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 440

 -SubTopic 10

 -Section 50

 -Paragraph 2

 -URI http://asc.fasb.org/extlink&amp;oid=6394976&amp;loc=d3e25287-109308



</ElementReferences><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Commitments and contingencies</Label></Row></Rows><Footnotes /><IsEquityReport>false</IsEquityReport><ReportName>Commitments and contingencies</ReportName><MonetaryRoundingLevel>UnKnown</MonetaryRoundingLevel><SharesRoundingLevel>UnKnown</SharesRoundingLevel><PerShareRoundingLevel>UnKnown</PerShareRoundingLevel><ExchangeRateRoundingLevel>UnKnown</ExchangeRateRoundingLevel><HasCustomUnits>true</HasCustomUnits><IsEmbedReport>false</IsEmbedReport><IsMultiCurrency>false</IsMultiCurrency><ReportType>Sheet</ReportType><RoleURI>http://xbres.com/role/CommitmentsAndContingencies</RoleURI><NumberOfCols>1</NumberOfCols><NumberOfRows>2</NumberOfRows></InstanceReport>
