From f1efb0a31743f3cc8ed5031514cda50a3df7e774 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sat, 20 Jul 2019 21:42:04 +0200 Subject: [PATCH] Fix strange int compare bug. --- .gitignore | 1 + basicswap/basicswap.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e480d10..74746e8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ /dist/ /*.egg-info /*.egg +/*.eggs diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 63cf0fa..a635241 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -601,6 +601,13 @@ class BasicSwap(): for bid in session.query(Bid): if bid.state and bid.state > BidStates.BID_RECEIVED and bid.state < BidStates.SWAP_COMPLETED: self.log.debug('Loading active bid %s', bid.bid_id.hex()) + + offer = session.query(Offer).filter_by(offer_id=bid.offer_id).first() + assert(offer), 'Offer not found' + self.swaps_in_progress[bid.bid_id] = (bid, offer) + + # TODO: load txns, must store height 1st seen + finally: session.close() session.remove() @@ -1476,7 +1483,7 @@ class BasicSwap(): continue # Verify amount if assert_amount: - assert(o['amount'] * COIN == assert_amount), 'Incorrect output amount in txn {}.'.format(assert_txid) + assert(int(o['amount'] * COIN) == int(assert_amount)), 'Incorrect output amount in txn {}.'.format(assert_txid) if not sum_output: if o['height'] > 0: @@ -1519,7 +1526,7 @@ class BasicSwap(): initiate_txn = self.callcoinrpc(coin_from, 'getrawtransaction', [initiate_txnid_hex, True]) # Verify amount vout = getVoutByAddress(initiate_txn, p2sh) - assert(initiate_txn['vout'][vout]['value'] * COIN == bid.amount), 'Incorrect output amount in initiate txn.' + assert(int(initiate_txn['vout'][vout]['value'] * COIN) == int(bid.amount)), 'Incorrect output amount in initiate txn.' bid.initiate_txn_conf = initiate_txn['confirmations'] try: