diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 0ff2ba2..e662213 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -589,6 +589,7 @@ class BasicSwap(BaseApp): session.execute('ALTER TABLE bids ADD COLUMN chain_b_height_start INTEGER') session.execute('ALTER TABLE bids ADD COLUMN protocol_version INTEGER') session.execute('ALTER TABLE offers ADD COLUMN protocol_version INTEGER') + session.execute('ALTER TABLE transactions ADD COLUMN tx_data BLOB') db_version += 1 if current_version != db_version: @@ -781,9 +782,11 @@ class BasicSwap(BaseApp): try: self.ci(offer.coin_from).unlockInputs(xmr_swap.a_lock_tx) except Exception as e: - if self.debug: - self.log.info('unlockInputs failed {}'.format(str(e))) + self.log.debug('unlockInputs failed {}'.format(str(e))) pass # Invalid parameter, unknown transaction + elif SwapTypes.SELLER_FIRST: + pass # No prevouts are locked + finally: if session is None: use_session.commit() @@ -1796,6 +1799,7 @@ class BasicSwap(BaseApp): bid_id=bid_id, tx_type=TxTypes.ITX, txid=bytes.fromhex(txid), + tx_data=bytes.fromhex(txn), script=script, ) bid.setITxState(TxStates.TX_SENT) @@ -2298,6 +2302,7 @@ class BasicSwap(BaseApp): vout = getVoutByAddress(txjs, addr_to) self.addParticipateTxn(bid_id, bid, coin_to, txid, vout, chain_height) bid.participate_tx.script = participate_script + bid.participate_tx.tx_data = bytes.fromhex(txn_signed) return txn_signed diff --git a/basicswap/db.py b/basicswap/db.py index e0ef6dc..99827be 100644 --- a/basicswap/db.py +++ b/basicswap/db.py @@ -179,6 +179,7 @@ class SwapTx(Base): txid = sa.Column(sa.LargeBinary) vout = sa.Column(sa.Integer) + tx_data = sa.Column(sa.LargeBinary) script = sa.Column(sa.LargeBinary) diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index ee91853..5ad14c9 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -779,6 +779,17 @@ class BTCInterface(CoinInterface): rv = self.rpc_callback('fundrawtransaction', [tx.hex(), options]) return bytes.fromhex(rv['hex']) + def listInputs(self, tx_bytes): + tx = self.loadTx(tx_bytes) + + all_locked = self.rpc_callback('listlockunspent') + inputs = [] + for pi in tx.vin: + txid_hex = i2h(pi.prevout.hash) + islocked = any([txid_hex == a['txid'] and pi.prevout.n == a['vout'] for a in all_locked]) + inputs.append({'txid': txid_hex, 'vout': pi.prevout.n, 'islocked': islocked}) + return inputs + def unlockInputs(self, tx_bytes): tx = self.loadTx(tx_bytes) @@ -938,8 +949,6 @@ class BTCInterface(CoinInterface): return_txid = True if txid is None else False if txid is None: txns = self.rpc_callback('listunspent', [0, 9999999, [dest_address, ]]) - import json - print('txns', json.dumps(txns, indent=4)) for tx in txns: print('bid_amount', bid_amount) diff --git a/basicswap/templates/bid.html b/basicswap/templates/bid.html index b9b83bd..f1ed7a5 100644 --- a/basicswap/templates/bid.html +++ b/basicswap/templates/bid.html @@ -39,7 +39,6 @@ -
+{% if data.chain_a_lock_tx_inputs %} +txid | vout | locked |
---|---|---|
{{ txi.txid }} | {{ txi.vout }} | {% if txi.islocked %} true {% else %} false {% endif %} |