From 1d6f55b8b9562c068a1fe35a8b15fde0ec1a1f80 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Tue, 2 Nov 2021 17:48:33 +0200 Subject: [PATCH] ui: Display decoded tx in View Tx output. --- basicswap/interface_btc.py | 3 +++ basicswap/templates/bid_xmr.html | 5 +++++ basicswap/ui.py | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index 30d7db7..7e52a88 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -1044,6 +1044,9 @@ class BTCInterface(CoinInterface): length += 1 # flags return length + def describeTx(self, tx_hex): + return self.rpc_callback('decoderawtransaction', [tx_hex]) + def testBTCInterface(): print('testBTCInterface') diff --git a/basicswap/templates/bid_xmr.html b/basicswap/templates/bid_xmr.html index ed1c1f3..5980328 100644 --- a/basicswap/templates/bid_xmr.html +++ b/basicswap/templates/bid_xmr.html @@ -15,6 +15,8 @@ {% else %} Swap{{ data.amt_from }} {{ data.ticker_from }} for {{ data.amt_to }} {{ data.ticker_to }} {% endif %} +Coin From{{ data.coin_from }} +Coin To{{ data.coin_to }} Bid State{{ data.bid_state }} State Description {{ data.state_description }} Offer{{ data.offer_id }} @@ -83,6 +85,9 @@ {% if data.view_tx_hex %}

{{ data.view_tx_hex }}

+ {% endif %} {% if data.lock_transfers %} diff --git a/basicswap/ui.py b/basicswap/ui.py index d2c5219..5eae21c 100644 --- a/basicswap/ui.py +++ b/basicswap/ui.py @@ -203,6 +203,8 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b state_description = f'Waiting for {ticker_to} lock tx spend tx to confirm in chain' data = { + 'coin_from': ci_from.coin_name(), + 'coin_to': ci_to.coin_name(), 'amt_from': ci_from.format_amount(bid.amount), 'amt_to': ci_to.format_amount((bid.amount * offer.rate) // ci_from.COIN()), 'ticker_from': ticker_from, @@ -291,5 +293,10 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b 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: data['view_tx_hex'] = xmr_swap.a_lock_refund_spend_tx.hex() + if view_tx_id == xmr_swap.a_lock_spend_tx_id and xmr_swap.a_lock_spend_tx: + data['view_tx_hex'] = xmr_swap.a_lock_spend_tx.hex() + + if 'view_tx_hex' in data: + data['view_tx_desc'] = json.dumps(ci_from.describeTx(data['view_tx_hex']), indent=4) return data