mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-23 03:49:25 +00:00
ui: Can display chain A lock tx inputs.
This commit is contained in:
parent
edddf9158a
commit
0cf3f8e3b3
6 changed files with 35 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
</table>
|
||||
|
||||
|
||||
|
||||
<form method="post">
|
||||
{% if edit_bid %}
|
||||
<h4>Edit Bid</h4>
|
||||
|
|
|
@ -101,6 +101,16 @@
|
|||
{% endif %}
|
||||
</form>
|
||||
|
||||
{% if data.chain_a_lock_tx_inputs %}
|
||||
<h5>Chain A Lock TX Inputs:</h5>
|
||||
<table>
|
||||
<tr><th>txid</th><th>vout</th><th>locked</th></tr>
|
||||
{% for txi in data.chain_a_lock_tx_inputs %}
|
||||
<tr><td>{{ txi.txid }}</td><td>{{ txi.vout }}</td><td>{% if txi.islocked %} true {% else %} false {% endif %}</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h4>Old States</h4>
|
||||
<table>
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue