From 3c5577c3e1524c3a9c1a5c731eda0d8b521448c0 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sat, 27 Jul 2019 23:34:15 +0200 Subject: [PATCH] Small fixes. --- basicswap/basicswap.py | 6 ++++-- basicswap/http_server.py | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 14d7067..603268b 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -515,9 +515,11 @@ class BasicSwap(): self.addWatchedOutput(coin_to, bid.bid_id, bid.participate_tx.txid.hex(), bid.participate_tx.vout, BidStates.SWAP_PARTICIPATING) if self.coin_clients[coin_from]['last_height_checked'] < 1: - self.coin_clients[coin_from]['last_height_checked'] = bid.initiate_tx.chain_height + if bid.initiate_tx and bid.initiate_tx.chain_height: + self.coin_clients[coin_from]['last_height_checked'] = bid.initiate_tx.chain_height if self.coin_clients[coin_to]['last_height_checked'] < 1: - self.coin_clients[coin_to]['last_height_checked'] = bid.participate_tx.chain_height + if bid.participate_tx and bid.participate_tx.chain_height: + self.coin_clients[coin_to]['last_height_checked'] = bid.participate_tx.chain_height finally: session.close() diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 16d3c9a..7c836df 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -59,9 +59,9 @@ def getTxIdHex(bid, tx_type, prefix): return 'Unknown Type' if not obj: - return None + return 'None' if not obj.txid: - return None + return 'None' return obj.txid.hex() + prefix @@ -74,10 +74,10 @@ def getTxSpendHex(bid, tx_type): return 'Unknown Type' if not obj: - return None + return 'None' if not obj.spend_txid: - return None - obj.spend_txid.hex() + ' {}'.format(obj.spend_n) + return 'None' + return obj.spend_txid.hex() + ' {}'.format(obj.spend_n) def html_content_start(title, h2=None, refresh=None): @@ -469,8 +469,8 @@ class HttpHandler(BaseHTTPRequestHandler): if show_txns: data['initiate_tx_refund'] = 'None' if not bid.initiate_txn_refund else bid.initiate_txn_refund.hex() data['participate_tx_refund'] = 'None' if not bid.participate_txn_refund else bid.participate_txn_refund.hex() - data['initiate_tx_spend'] = getTxSpendHex(bid, TxTypes.ITX), - data['participate_tx_spend'] = getTxSpendHex(bid, TxTypes.PTX), + data['initiate_tx_spend'] = getTxSpendHex(bid, TxTypes.ITX) + data['participate_tx_spend'] = getTxSpendHex(bid, TxTypes.PTX) old_states = [] num_states = len(bid.states) // 12