diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py
index 7d35ec6..3524840 100644
--- a/basicswap/basicswap.py
+++ b/basicswap/basicswap.py
@@ -1667,17 +1667,16 @@ class BasicSwap(BaseApp):
 
             self.checkSynced(coin_from, coin_to)
 
-            contract_count = self.getNewContractId()
-
-            amount_to = int((msg_buf.amount * bid_rate) // self.ci(coin_from).COIN())
+            amount_to = int((msg_buf.amount * bid_rate) // ci_from.COIN())
 
             now = int(time.time())
             if offer.swap_type == SwapTypes.SELLER_FIRST:
-                msg_buf.pkhash_buyer = getKeyID(self.getContractPubkey(dt.datetime.fromtimestamp(now).date(), contract_count))
-
                 proof_addr, proof_sig = self.getProofOfFunds(coin_to, amount_to, offer_id)
                 msg_buf.proof_address = proof_addr
                 msg_buf.proof_signature = proof_sig
+
+                contract_count = self.getNewContractId()
+                msg_buf.pkhash_buyer = getKeyID(self.getContractPubkey(dt.datetime.fromtimestamp(now).date(), contract_count))
             else:
                 raise ValueError('TODO')
 
@@ -2011,6 +2010,11 @@ class BasicSwap(BaseApp):
 
             self.checkSynced(coin_from, coin_to)
 
+            amount_to = int((int(amount) * bid_rate) // ci_from.COIN())
+
+            balance_to = ci_to.getSpendableBalance()
+            ensure(balance_to > amount_to, '{} spendable balance is too low: {}'.format(ci_to.coin_name(), ci_to.format_amount(balance_to)))
+
             msg_buf = XmrBidMessage()
             msg_buf.protocol_version = 1
             msg_buf.offer_msg_id = offer_id
diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py
index 3aa73b4..c447951 100644
--- a/basicswap/interface_btc.py
+++ b/basicswap/interface_btc.py
@@ -1096,6 +1096,9 @@ class BTCInterface(CoinInterface):
     def describeTx(self, tx_hex):
         return self.rpc_callback('decoderawtransaction', [tx_hex])
 
+    def getSpendableBalance(self):
+        return self.make_int(self.rpc_callback('getbalances')['mine']['trusted'])
+
 
 def testBTCInterface():
     print('testBTCInterface')
diff --git a/basicswap/interface_part.py b/basicswap/interface_part.py
index 9ff72ca..ed10fec 100644
--- a/basicswap/interface_part.py
+++ b/basicswap/interface_part.py
@@ -601,6 +601,9 @@ class PARTInterfaceBlind(PARTInterface):
 
         return bytes.fromhex(lock_refund_swipe_tx_hex)
 
+    def getSpendableBalance(self):
+        return self.make_int(self.rpc_callback('getbalances')['mine']['blind_trusted'])
+
 
 class PARTInterfaceAnon(PARTInterface):
     @staticmethod
@@ -712,3 +715,6 @@ class PARTInterfaceAnon(PARTInterface):
             return {'txid': txid_hex, 'amount': 0, 'height': rv['height']}
 
         return None
+
+    def getSpendableBalance(self):
+        return self.make_int(self.rpc_callback('getbalances')['mine']['anon_trusted'])
diff --git a/basicswap/interface_xmr.py b/basicswap/interface_xmr.py
index 1d699f5..30313e3 100644
--- a/basicswap/interface_xmr.py
+++ b/basicswap/interface_xmr.py
@@ -26,7 +26,6 @@ from .util import (
     ensure,
     dumpj,
     make_int,
-    format_amount,
     TemporaryError)
 from .rpc_xmr import (
     make_xmr_rpc_func,
@@ -142,8 +141,8 @@ class XMRInterface(CoinInterface):
             rv = {}
             self.rpc_wallet_cb('refresh')
             balance_info = self.rpc_wallet_cb('get_balance')
-            rv['balance'] = format_amount(balance_info['unlocked_balance'], XMRInterface.exp())
-            rv['unconfirmed_balance'] = format_amount(balance_info['balance'] - balance_info['unlocked_balance'], XMRInterface.exp())
+            rv['balance'] = self.format_amount(balance_info['unlocked_balance'])
+            rv['unconfirmed_balance'] = self.format_amount(balance_info['balance'] - balance_info['unlocked_balance'])
             return rv
 
     def walletRestoreHeight(self):
@@ -477,3 +476,11 @@ class XMRInterface(CoinInterface):
                 return rv
             except Exception as e:
                 return {'error': str(e)}
+
+    def getSpendableBalance(self):
+        with self._mx_wallet:
+            self.rpc_wallet_cb('open_wallet', {'filename': self._wallet_filename})
+
+            self.rpc_wallet_cb('refresh')
+            balance_info = self.rpc_wallet_cb('get_balance')
+            return balance_info['unlocked_balance']
diff --git a/basicswap/rpc.py b/basicswap/rpc.py
index dd2bc78..4986d51 100644
--- a/basicswap/rpc.py
+++ b/basicswap/rpc.py
@@ -107,7 +107,7 @@ def callrpc(rpc_port, auth, method, params=[], wallet=None, host='127.0.0.1'):
         r = json.loads(v.decode('utf-8'))
     except Exception as ex:
         traceback.print_exc()
-        raise ValueError('RPC Server Error')
+        raise ValueError('RPC Server Error ' + str(ex))
 
     if 'error' in r and r['error'] is not None:
         raise ValueError('RPC error ' + str(r['error']))