mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-08 03:39:26 +00:00
Ignore unknown coin types in getCachedWalletsInfo
Some checks failed
ci / ci (3.12) (push) Has been cancelled
Some checks failed
ci / ci (3.12) (push) Has been cancelled
This commit is contained in:
parent
7ad92b1bbd
commit
54f56e0e2c
2 changed files with 64 additions and 25 deletions
|
@ -1187,11 +1187,16 @@ class BasicSwap(BaseApp):
|
||||||
if ci.isWalletLocked():
|
if ci.isWalletLocked():
|
||||||
raise LockedCoinError(Coins.PART)
|
raise LockedCoinError(Coins.PART)
|
||||||
|
|
||||||
|
def isCoinActive(self, c) -> bool:
|
||||||
|
if c not in chainparams:
|
||||||
|
return False
|
||||||
|
if self.coin_clients[c]["connection_type"] == "rpc":
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def activeCoins(self):
|
def activeCoins(self):
|
||||||
for c in Coins:
|
for c in Coins:
|
||||||
if c not in chainparams:
|
if self.isCoinActive(c):
|
||||||
continue
|
|
||||||
if self.coin_clients[c]["connection_type"] == "rpc":
|
|
||||||
yield c
|
yield c
|
||||||
|
|
||||||
def getListOfWalletCoins(self):
|
def getListOfWalletCoins(self):
|
||||||
|
@ -1335,9 +1340,7 @@ class BasicSwap(BaseApp):
|
||||||
identity_stats = self.queryOne(KnownIdentity, cursor, {"address": addr})
|
identity_stats = self.queryOne(KnownIdentity, cursor, {"address": addr})
|
||||||
if not identity_stats:
|
if not identity_stats:
|
||||||
identity_stats = KnownIdentity(
|
identity_stats = KnownIdentity(
|
||||||
active_ind=1,
|
active_ind=1, address=addr, created_at=self.getTime()
|
||||||
address=addr,
|
|
||||||
created_at=self.getTime()
|
|
||||||
)
|
)
|
||||||
is_offer_creator = addr == offer.addr_from
|
is_offer_creator = addr == offer.addr_from
|
||||||
if bid.state == BidStates.SWAP_COMPLETED:
|
if bid.state == BidStates.SWAP_COMPLETED:
|
||||||
|
@ -1347,11 +1350,13 @@ class BasicSwap(BaseApp):
|
||||||
else:
|
else:
|
||||||
old_value = zeroIfNone(identity_stats.num_sent_bids_successful)
|
old_value = zeroIfNone(identity_stats.num_sent_bids_successful)
|
||||||
identity_stats.num_sent_bids_successful = old_value + 1
|
identity_stats.num_sent_bids_successful = old_value + 1
|
||||||
elif bid.state in (BidStates.BID_ERROR,
|
elif bid.state in (
|
||||||
BidStates.XMR_SWAP_FAILED_REFUNDED,
|
BidStates.BID_ERROR,
|
||||||
BidStates.XMR_SWAP_FAILED_SWIPED,
|
BidStates.XMR_SWAP_FAILED_REFUNDED,
|
||||||
BidStates.XMR_SWAP_FAILED,
|
BidStates.XMR_SWAP_FAILED_SWIPED,
|
||||||
BidStates.SWAP_TIMEDOUT):
|
BidStates.XMR_SWAP_FAILED,
|
||||||
|
BidStates.SWAP_TIMEDOUT,
|
||||||
|
):
|
||||||
if is_offer_creator:
|
if is_offer_creator:
|
||||||
old_value = zeroIfNone(identity_stats.num_recv_bids_failed)
|
old_value = zeroIfNone(identity_stats.num_recv_bids_failed)
|
||||||
identity_stats.num_recv_bids_failed = old_value + 1
|
identity_stats.num_recv_bids_failed = old_value + 1
|
||||||
|
@ -8771,7 +8776,7 @@ class BasicSwap(BaseApp):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
chain_height = ci_to.getChainHeight()
|
chain_height = ci_to.getChainHeight()
|
||||||
lock_tx_depth = (chain_height - bid.xmr_b_lock_tx.chain_height)
|
lock_tx_depth = chain_height - bid.xmr_b_lock_tx.chain_height
|
||||||
if lock_tx_depth < ci_to.depth_spendable():
|
if lock_tx_depth < ci_to.depth_spendable():
|
||||||
raise TemporaryError(
|
raise TemporaryError(
|
||||||
f"Chain B lock tx still confirming {lock_tx_depth} / {ci_to.depth_spendable()}."
|
f"Chain B lock tx still confirming {lock_tx_depth} / {ci_to.depth_spendable()}."
|
||||||
|
@ -10416,7 +10421,7 @@ class BasicSwap(BaseApp):
|
||||||
for row in q:
|
for row in q:
|
||||||
coin_id = row[0]
|
coin_id = row[0]
|
||||||
|
|
||||||
if self.coin_clients[coin_id]["connection_type"] != "rpc":
|
if self.isCoinActive(coin_id) is False:
|
||||||
# Skip cached info if coin was disabled
|
# Skip cached info if coin was disabled
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,8 @@ def js_offers(self, url_split, post_string, is_json, sent=False) -> bytes:
|
||||||
"is_expired": o.expire_at <= swap_client.getTime(),
|
"is_expired": o.expire_at <= swap_client.getTime(),
|
||||||
"is_own_offer": o.was_sent,
|
"is_own_offer": o.was_sent,
|
||||||
"is_revoked": True if o.active_ind == 2 else False,
|
"is_revoked": True if o.active_ind == 2 else False,
|
||||||
"is_public": o.addr_to == swap_client.network_addr or o.addr_to.strip() == "",
|
"is_public": o.addr_to == swap_client.network_addr
|
||||||
|
or o.addr_to.strip() == "",
|
||||||
}
|
}
|
||||||
if with_extra_info:
|
if with_extra_info:
|
||||||
offer_data["amount_negotiable"] = o.amount_negotiable
|
offer_data["amount_negotiable"] = o.amount_negotiable
|
||||||
|
@ -660,17 +661,50 @@ def js_identities(self, url_split, post_string: str, is_json: bool) -> bytes:
|
||||||
address = url_split[3]
|
address = url_split[3]
|
||||||
identity = swap_client.getIdentity(address)
|
identity = swap_client.getIdentity(address)
|
||||||
if identity:
|
if identity:
|
||||||
return bytes(json.dumps({
|
return bytes(
|
||||||
"label": identity.label if identity.label is not None else "",
|
json.dumps(
|
||||||
"note": identity.note if identity.note is not None else "",
|
{
|
||||||
"automation_override": identity.automation_override if identity.automation_override is not None else 0,
|
"label": identity.label if identity.label is not None else "",
|
||||||
"num_sent_bids_successful": identity.num_sent_bids_successful if identity.num_sent_bids_successful is not None else 0,
|
"note": identity.note if identity.note is not None else "",
|
||||||
"num_recv_bids_successful": identity.num_recv_bids_successful if identity.num_recv_bids_successful is not None else 0,
|
"automation_override": (
|
||||||
"num_sent_bids_rejected": identity.num_sent_bids_rejected if identity.num_sent_bids_rejected is not None else 0,
|
identity.automation_override
|
||||||
"num_recv_bids_rejected": identity.num_recv_bids_rejected if identity.num_recv_bids_rejected is not None else 0,
|
if identity.automation_override is not None
|
||||||
"num_sent_bids_failed": identity.num_sent_bids_failed if identity.num_sent_bids_failed is not None else 0,
|
else 0
|
||||||
"num_recv_bids_failed": identity.num_recv_bids_failed if identity.num_recv_bids_failed is not None else 0
|
),
|
||||||
}), "UTF-8")
|
"num_sent_bids_successful": (
|
||||||
|
identity.num_sent_bids_successful
|
||||||
|
if identity.num_sent_bids_successful is not None
|
||||||
|
else 0
|
||||||
|
),
|
||||||
|
"num_recv_bids_successful": (
|
||||||
|
identity.num_recv_bids_successful
|
||||||
|
if identity.num_recv_bids_successful is not None
|
||||||
|
else 0
|
||||||
|
),
|
||||||
|
"num_sent_bids_rejected": (
|
||||||
|
identity.num_sent_bids_rejected
|
||||||
|
if identity.num_sent_bids_rejected is not None
|
||||||
|
else 0
|
||||||
|
),
|
||||||
|
"num_recv_bids_rejected": (
|
||||||
|
identity.num_recv_bids_rejected
|
||||||
|
if identity.num_recv_bids_rejected is not None
|
||||||
|
else 0
|
||||||
|
),
|
||||||
|
"num_sent_bids_failed": (
|
||||||
|
identity.num_sent_bids_failed
|
||||||
|
if identity.num_sent_bids_failed is not None
|
||||||
|
else 0
|
||||||
|
),
|
||||||
|
"num_recv_bids_failed": (
|
||||||
|
identity.num_recv_bids_failed
|
||||||
|
if identity.num_recv_bids_failed is not None
|
||||||
|
else 0
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
"UTF-8",
|
||||||
|
)
|
||||||
return bytes(json.dumps({}), "UTF-8")
|
return bytes(json.dumps({}), "UTF-8")
|
||||||
|
|
||||||
filters = {
|
filters = {
|
||||||
|
|
Loading…
Reference in a new issue