Fix floating point bug.

This commit is contained in:
tecnovert 2021-01-02 23:04:29 +02:00
parent 1ba2ad6f0b
commit 05c9d9c66d
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
5 changed files with 13 additions and 11 deletions

View File

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

View File

@ -4500,7 +4500,7 @@ class BasicSwap(BaseApp):
else: else:
self.log.debug('TODO - determine in-progress for manualBidUpdate') self.log.debug('TODO - determine in-progress for manualBidUpdate')
if offer.swap_type == SwapTypes.XMR_SWAP: 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 activate_bid = True
if activate_bid: if activate_bid:

View File

@ -917,7 +917,7 @@ class HttpThread(threading.Thread, HTTPServer):
self.port_no = port_no self.port_no = port_no
self.allow_cors = allow_cors self.allow_cors = allow_cors
self.swap_client = swap_client 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.last_form_id = dict()
self.timeout = 60 self.timeout = 60

View File

@ -783,7 +783,7 @@ class BTCInterface(CoinInterface):
for utxo in rv['unspents']: for utxo in rv['unspents']:
if 'height' in utxo and utxo['height'] > 0 and rv['height'] - utxo['height'] > cb_block_confirmed: 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'])) logging.warning('Found output to lock tx pubkey of incorrect value: %s', str(utxo['amount']))
else: else:
return {'txid': utxo['txid'], 'vout': utxo['vout'], 'amount': utxo['amount'], 'height': utxo['height']} 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']: for utxo in rv['unspents']:
if 'height' in utxo and utxo['height'] > 0 and rv['height'] - utxo['height'] > cb_block_confirmed: 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'])) logging.warning('Found output to lock tx pubkey of incorrect value: %s', str(utxo['amount']))
else: else:
return True return True
@ -819,13 +819,13 @@ class BTCInterface(CoinInterface):
if txid and txid.hex() != utxo['txid']: if txid and txid.hex() != utxo['txid']:
continue continue
if expect_value != utxo['amount'] * COIN: if expect_value != self.make_int(utxo['amount']):
continue continue
rv.append({ rv.append({
'depth': 0 if 'height' not in utxo else (chain_height - utxo['height']) + 1, 'depth': 0 if 'height' not in utxo else (chain_height - utxo['height']) + 1,
'height': 0 if 'height' not in utxo else utxo['height'], 'height': 0 if 'height' not in utxo else utxo['height'],
'amount': utxo['amount'] * COIN, 'amount': self.make_int(utxo['amount']),
'txid': utxo['txid'], 'txid': utxo['txid'],
'vout': utxo['vout']}) 'vout': utxo['vout']})
return rv, chain_height return rv, chain_height

View File

@ -33,11 +33,13 @@ After updating the code and rebuilding the container:
## If installed through pip: ## If installed through pip:
cd basicswap $ export SWAP_DATADIR=/Users/$USER/coinswaps
git pull $ . $SWAP_DATADIR/venv/bin/activate && python -V
pip3 install . $ cd $SWAP_DATADIR/basicswap
$ git pull
$ pip3 install .
#### Update core versions #### Update core versions
basicswap-prepare -preparebinonly basicswap-prepare -preparebinonly --withcoins=monero --withoutcoins=litecoin