Fail with more descriptive error when processing message involving inactive coin.
This commit is contained in:
parent
3ed6781c9f
commit
c7bbdc7022
@ -1,3 +1,3 @@
|
|||||||
name = "basicswap"
|
name = "basicswap"
|
||||||
|
|
||||||
__version__ = "0.11.37"
|
__version__ = "0.11.38"
|
||||||
|
@ -39,6 +39,7 @@ from . import __version__
|
|||||||
from .rpc_xmr import make_xmr_rpc2_func
|
from .rpc_xmr import make_xmr_rpc2_func
|
||||||
from .util import (
|
from .util import (
|
||||||
TemporaryError,
|
TemporaryError,
|
||||||
|
InactiveCoin,
|
||||||
AutomationConstraint,
|
AutomationConstraint,
|
||||||
format_amount,
|
format_amount,
|
||||||
format_timestamp,
|
format_timestamp,
|
||||||
@ -473,11 +474,21 @@ class BasicSwap(BaseApp):
|
|||||||
raise ValueError('Failed to select a working XMR daemon url.')
|
raise ValueError('Failed to select a working XMR daemon url.')
|
||||||
|
|
||||||
def ci(self, coin): # Coin interface
|
def ci(self, coin): # Coin interface
|
||||||
|
use_coinid = coin
|
||||||
|
interface_ind = 'interface'
|
||||||
if coin == Coins.PART_ANON:
|
if coin == Coins.PART_ANON:
|
||||||
return self.coin_clients[Coins.PART]['interface_anon']
|
use_coinid = Coins.PART
|
||||||
|
interface_ind = 'interface_anon'
|
||||||
if coin == Coins.PART_BLIND:
|
if coin == Coins.PART_BLIND:
|
||||||
return self.coin_clients[Coins.PART]['interface_blind']
|
use_coinid = Coins.PART
|
||||||
return self.coin_clients[coin]['interface']
|
interface_ind = 'interface_blind'
|
||||||
|
|
||||||
|
if use_coinid not in self.coin_clients:
|
||||||
|
raise ValueError('Unknown coinid {}'.format(int(coin)))
|
||||||
|
if interface_ind not in self.coin_clients[use_coinid]:
|
||||||
|
raise InactiveCoin(int(coin))
|
||||||
|
|
||||||
|
return self.coin_clients[use_coinid][interface_ind]
|
||||||
|
|
||||||
def createInterface(self, coin):
|
def createInterface(self, coin):
|
||||||
if coin == Coins.PART:
|
if coin == Coins.PART:
|
||||||
@ -4996,6 +5007,8 @@ class BasicSwap(BaseApp):
|
|||||||
if msg_type == MessageTypes.OFFER_REVOKE:
|
if msg_type == MessageTypes.OFFER_REVOKE:
|
||||||
self.processOfferRevoke(msg)
|
self.processOfferRevoke(msg)
|
||||||
|
|
||||||
|
except InactiveCoin as ex:
|
||||||
|
self.log.info('Ignoring message involving inactive coin {}, type {}'.format(Coins(ex.coinid).name, MessageTypes(msg_type).name))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.log.error('processMsg %s', str(ex))
|
self.log.error('processMsg %s', str(ex))
|
||||||
if self.debug:
|
if self.debug:
|
||||||
|
@ -25,6 +25,13 @@ class AutomationConstraint(ValueError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InactiveCoin(Exception):
|
||||||
|
def __init__(self, coinid):
|
||||||
|
self.coinid = coinid
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.coinid)
|
||||||
|
|
||||||
|
|
||||||
def ensure(v, err_string):
|
def ensure(v, err_string):
|
||||||
if not v:
|
if not v:
|
||||||
raise ValueError(err_string)
|
raise ValueError(err_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user