Fix floating point bug.

2024-05-20_merge
tecnovert 4 years ago
parent 1ba2ad6f0b
commit 05c9d9c66d
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 2
      basicswap/__init__.py
  2. 2
      basicswap/basicswap.py
  3. 2
      basicswap/http_server.py
  4. 8
      basicswap/interface_btc.py
  5. 10
      doc/upgrade.md

@ -1,3 +1,3 @@
name = "basicswap"
__version__ = "0.0.8"
__version__ = "0.0.9"

@ -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:

@ -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

@ -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

@ -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

Loading…
Cancel
Save