mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-22 19:49:20 +00:00
Fail with more descriptive error when processing message involving inactive coin.
This commit is contained in:
parent
3ed6781c9f
commit
c7bbdc7022
3 changed files with 24 additions and 4 deletions
|
@ -1,3 +1,3 @@
|
|||
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 .util import (
|
||||
TemporaryError,
|
||||
InactiveCoin,
|
||||
AutomationConstraint,
|
||||
format_amount,
|
||||
format_timestamp,
|
||||
|
@ -473,11 +474,21 @@ class BasicSwap(BaseApp):
|
|||
raise ValueError('Failed to select a working XMR daemon url.')
|
||||
|
||||
def ci(self, coin): # Coin interface
|
||||
use_coinid = coin
|
||||
interface_ind = 'interface'
|
||||
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:
|
||||
return self.coin_clients[Coins.PART]['interface_blind']
|
||||
return self.coin_clients[coin]['interface']
|
||||
use_coinid = Coins.PART
|
||||
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):
|
||||
if coin == Coins.PART:
|
||||
|
@ -4996,6 +5007,8 @@ class BasicSwap(BaseApp):
|
|||
if msg_type == MessageTypes.OFFER_REVOKE:
|
||||
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:
|
||||
self.log.error('processMsg %s', str(ex))
|
||||
if self.debug:
|
||||
|
|
|
@ -25,6 +25,13 @@ class AutomationConstraint(ValueError):
|
|||
pass
|
||||
|
||||
|
||||
class InactiveCoin(Exception):
|
||||
def __init__(self, coinid):
|
||||
self.coinid = coinid
|
||||
def __str__(self):
|
||||
return str(self.coinid)
|
||||
|
||||
|
||||
def ensure(v, err_string):
|
||||
if not v:
|
||||
raise ValueError(err_string)
|
||||
|
|
Loading…
Reference in a new issue