From cb27fb6c4c524e50273bc833dffa8cade80dd132 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Fri, 11 Dec 2020 14:08:32 +0200 Subject: [PATCH] Lower min locktime to 1 hour for easier testing. Fix blocks confirmed count. --- basicswap/basicswap.py | 6 ++++-- basicswap/interface_btc.py | 2 +- basicswap/templates/bid.html | 1 - basicswap/templates/bid_xmr.html | 7 ++++++- basicswap/templates/offer_new.html | 2 +- basicswap/ui.py | 4 ++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 9cccfd9..729174c 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -236,6 +236,8 @@ def strBidState(state): return 'Sent' if state == BidStates.BID_RECEIVING: return 'Receiving' + if state == BidStates.BID_RECEIVING_ACC: + return 'Receiving accept' if state == BidStates.BID_RECEIVED: return 'Received' if state == BidStates.BID_ACCEPTED: @@ -2624,16 +2626,16 @@ class BasicSwap(BaseApp): self.logBidEvent(bid, EventLogTypes.LOCK_TX_A_CONFIRMED, '', session) bid.xmr_a_lock_tx.setState(TxStates.TX_CONFIRMED) bid.setState(BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED) - self.saveBidInSession(bid_id, bid, session, xmr_swap) + bid_changed = True if bid.was_sent: delay = random.randrange(self.min_delay_event, self.max_delay_event) self.log.info('Sending xmr swap chain B lock tx for bid %s in %d seconds', bid_id.hex(), delay) self.createEventInSession(delay, EventTypes.SEND_XMR_SWAP_LOCK_TX_B, bid_id, session) # bid.setState(BidStates.SWAP_DELAYING) - bid_changed = True if bid_changed: + self.saveBidInSession(bid_id, bid, session, xmr_swap) session.commit() elif state == BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED: diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index 5bbfeda..231c14c 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -824,7 +824,7 @@ class BTCInterface(CoinInterface): continue rv.append({ - 'depth': 0 if 'height' not in utxo else chain_height - utxo['height'], + 'depth': 0 if 'height' not in utxo else (chain_height - utxo['height']) + 1, 'height': 0 if 'height' not in utxo else utxo['height'], 'amount': utxo['amount'] * COIN, 'txid': utxo['txid'], diff --git a/basicswap/templates/bid.html b/basicswap/templates/bid.html index 7d1a775..b1a90ac 100644 --- a/basicswap/templates/bid.html +++ b/basicswap/templates/bid.html @@ -74,7 +74,6 @@

home

- diff --git a/basicswap/templates/offer_new.html b/basicswap/templates/offer_new.html index ef98ccd..09dff2e 100644 --- a/basicswap/templates/offer_new.html +++ b/basicswap/templates/offer_new.html @@ -31,7 +31,7 @@ Amount To -Contract locked (hrs)Participate txn will be locked for half the time. +Contract locked (hrs)Participate txn will be locked for half the time. Auto Accept Bids diff --git a/basicswap/ui.py b/basicswap/ui.py index c9bbd38..ea72a34 100644 --- a/basicswap/ui.py +++ b/basicswap/ui.py @@ -154,14 +154,14 @@ def describeBid(swap_client, bid, offer, edit_bid, show_txns): if bid.xmr_a_lock_tx: confirms = None if swap_client.coin_clients[ci_from.coin_type()]['last_height'] and bid.xmr_a_lock_tx.chain_height: - confirms = swap_client.coin_clients[ci_from.coin_type()]['last_height'] - bid.xmr_a_lock_tx.chain_height + confirms = (swap_client.coin_clients[ci_from.coin_type()]['last_height'] - bid.xmr_a_lock_tx.chain_height) + 1 txns.append({'type': 'Chain A Lock', 'txid': bid.xmr_a_lock_tx.txid.hex(), 'confirms': confirms}) if bid.xmr_a_lock_spend_tx: txns.append({'type': 'Chain A Lock Spend', 'txid': bid.xmr_a_lock_spend_tx.txid.hex()}) if bid.xmr_b_lock_tx: confirms = None if swap_client.coin_clients[ci_to.coin_type()]['last_height'] and bid.xmr_b_lock_tx.chain_height: - confirms = swap_client.coin_clients[ci_to.coin_type()]['last_height'] - bid.xmr_b_lock_tx.chain_height + confirms = (swap_client.coin_clients[ci_to.coin_type()]['last_height'] - bid.xmr_b_lock_tx.chain_height) + 1 txns.append({'type': 'Chain B Lock', 'txid': bid.xmr_b_lock_tx.txid.hex(), 'confirms': confirms}) if bid.xmr_b_lock_tx and bid.xmr_b_lock_tx.spend_txid: txns.append({'type': 'Chain B Lock Spend', 'txid': bid.xmr_b_lock_tx.spend_txid.hex()})