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 edit_bid %}

Edit Bid

diff --git a/basicswap/templates/bid_xmr.html b/basicswap/templates/bid_xmr.html index 5980328..b2683fc 100644 --- a/basicswap/templates/bid_xmr.html +++ b/basicswap/templates/bid_xmr.html @@ -101,6 +101,16 @@ {% endif %}
+{% if data.chain_a_lock_tx_inputs %} +
Chain A Lock TX Inputs:
+ + +{% for txi in data.chain_a_lock_tx_inputs %} + +{% endfor %} +
txidvoutlocked
{{ txi.txid }}{{ txi.vout }}{% if txi.islocked %} true {% else %} false {% endif %}
+{% endif %} +

Old States

diff --git a/basicswap/ui.py b/basicswap/ui.py index 5eae21c..0b32ef7 100644 --- a/basicswap/ui.py +++ b/basicswap/ui.py @@ -273,6 +273,11 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b data['initiate_tx_spend'] = getTxSpendHex(bid, TxTypes.ITX) data['participate_tx_spend'] = getTxSpendHex(bid, TxTypes.PTX) + if bid.initiate_tx and bid.initiate_tx.tx_data is not None: + data['initiate_tx_inputs'] = ci_from.listInputs(bid.initiate_tx.tx_data) + if bid.participate_tx and bid.participate_tx.tx_data is not None: + data['initiate_tx_inputs'] = ci_from.listInputs(bid.participate_tx.tx_data) + if offer.swap_type == SwapTypes.XMR_SWAP: data['coin_a_lock_refund_tx_est_final'] = 'None' if bid.xmr_a_lock_tx and bid.xmr_a_lock_tx.block_time: @@ -289,6 +294,7 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b if xmr_swap: if view_tx_id == xmr_swap.a_lock_tx_id and xmr_swap.a_lock_tx: data['view_tx_hex'] = xmr_swap.a_lock_tx.hex() + data['chain_a_lock_tx_inputs'] = ci_from.listInputs(xmr_swap.a_lock_tx) if view_tx_id == xmr_swap.a_lock_refund_tx_id and xmr_swap.a_lock_refund_tx: data['view_tx_hex'] = xmr_swap.a_lock_refund_tx.hex() if view_tx_id == xmr_swap.a_lock_refund_spend_tx_id and xmr_swap.a_lock_refund_spend_tx: