From 05c9d9c66dd3ba52ffc2909cbf369cbd4812e3e6 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sat, 2 Jan 2021 23:04:29 +0200 Subject: [PATCH] Fix floating point bug. --- basicswap/__init__.py | 2 +- basicswap/basicswap.py | 2 +- basicswap/http_server.py | 2 +- basicswap/interface_btc.py | 8 ++++---- doc/upgrade.md | 10 ++++++---- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/basicswap/__init__.py b/basicswap/__init__.py index 1939488..a72af3f 100644 --- a/basicswap/__init__.py +++ b/basicswap/__init__.py @@ -1,3 +1,3 @@ name = "basicswap" -__version__ = "0.0.8" +__version__ = "0.0.9" diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 72e33b7..a946af7 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -4500,7 +4500,7 @@ class BasicSwap(BaseApp): else: self.log.debug('TODO - determine in-progress for manualBidUpdate') if offer.swap_type == SwapTypes.XMR_SWAP: - if bid.state and bid.state in (BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED, BidStates.XMR_SWAP_LOCK_RELEASED, BidStates.XMR_SWAP_NOSCRIPT_TX_REDEEMED): + if bid.state and bid.state in (BidStates.XMR_SWAP_HAVE_SCRIPT_COIN_SPEND_TX, BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED, BidStates.XMR_SWAP_LOCK_RELEASED, BidStates.XMR_SWAP_NOSCRIPT_TX_REDEEMED): activate_bid = True if activate_bid: diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 1d9780b..b2dec48 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -917,7 +917,7 @@ class HttpThread(threading.Thread, HTTPServer): self.port_no = port_no self.allow_cors = allow_cors self.swap_client = swap_client - self.title = 'Simple Atomic Swap Demo, ' + self.swap_client.chain + self.title = 'BasicSwap, ' + self.swap_client.chain self.last_form_id = dict() self.timeout = 60 diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index 0ae458b..50894e6 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -783,7 +783,7 @@ class BTCInterface(CoinInterface): for utxo in rv['unspents']: if 'height' in utxo and utxo['height'] > 0 and rv['height'] - utxo['height'] > cb_block_confirmed: - if utxo['amount'] * COIN != cb_swap_value: + if self.make_int(utxo['amount']) != cb_swap_value: logging.warning('Found output to lock tx pubkey of incorrect value: %s', str(utxo['amount'])) else: return {'txid': utxo['txid'], 'vout': utxo['vout'], 'amount': utxo['amount'], 'height': utxo['height']} @@ -801,7 +801,7 @@ class BTCInterface(CoinInterface): for utxo in rv['unspents']: if 'height' in utxo and utxo['height'] > 0 and rv['height'] - utxo['height'] > cb_block_confirmed: - if utxo['amount'] * COIN != cb_swap_value: + if self.make_int(utxo['amount']) != cb_swap_value: logging.warning('Found output to lock tx pubkey of incorrect value: %s', str(utxo['amount'])) else: return True @@ -819,13 +819,13 @@ class BTCInterface(CoinInterface): if txid and txid.hex() != utxo['txid']: continue - if expect_value != utxo['amount'] * COIN: + if expect_value != self.make_int(utxo['amount']): continue rv.append({ '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, + 'amount': self.make_int(utxo['amount']), 'txid': utxo['txid'], 'vout': utxo['vout']}) return rv, chain_height diff --git a/doc/upgrade.md b/doc/upgrade.md index 3acf390..819d167 100644 --- a/doc/upgrade.md +++ b/doc/upgrade.md @@ -33,11 +33,13 @@ After updating the code and rebuilding the container: ## If installed through pip: - cd basicswap - git pull - pip3 install . + $ export SWAP_DATADIR=/Users/$USER/coinswaps + $ . $SWAP_DATADIR/venv/bin/activate && python -V + $ cd $SWAP_DATADIR/basicswap + $ git pull + $ pip3 install . #### Update core versions - basicswap-prepare -preparebinonly + basicswap-prepare -preparebinonly --withcoins=monero --withoutcoins=litecoin