From 0c9429bfa540c4159eca17e079b9141021716093 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sat, 2 Jan 2021 16:59:34 +0200 Subject: [PATCH] Display xmr-swap script coin lock spend tx fees. --- basicswap/http_server.py | 9 +++++++++ basicswap/interface_btc.py | 6 +++++- basicswap/interface_part.py | 4 ++++ basicswap/templates/offer.html | 3 +-- basicswap/templates/offer_confirm.html | 13 +++++++------ basicswap/templates/offer_new_2.html | 8 ++++---- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 6715ff1..aae11d3 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -398,6 +398,11 @@ class HttpHandler(BaseHTTPRequestHandler): page_data['from_fee_override'] = ci_from.format_amount(ci_from.make_int(from_fee_override, r=1)) parsed_data['from_fee_override'] = page_data['from_fee_override'] + lock_spend_tx_vsize = ci_from.xmr_swap_alock_spend_tx_vsize() + lock_spend_tx_fee = ci_from.make_int(ci_from.make_int(from_fee_override, r=1) * lock_spend_tx_vsize / 1000, r=1) + page_data['amt_from_lock_spend_tx_fee'] = ci_from.format_amount(lock_spend_tx_fee // ci_from.COIN()) + page_data['tla_from'] = ci_from.ticker() + if coin_to == Coins.XMR: if b'fee_rate_to' in form_data: page_data['to_fee_override'] = form_data[b'fee_rate_to'][0].decode('utf-8') @@ -565,6 +570,10 @@ class HttpHandler(BaseHTTPRequestHandler): data['a_fee_rate_verify_src'] = fee_source data['a_fee_warn'] = xmr_offer.a_fee_rate < int_fee_rate_now + lock_spend_tx_vsize = ci_from.xmr_swap_alock_spend_tx_vsize() + lock_spend_tx_fee = ci_from.make_int(xmr_offer.a_fee_rate * lock_spend_tx_vsize / 1000, r=1) + data['amt_from_lock_spend_tx_fee'] = ci_from.format_amount(lock_spend_tx_fee // ci_from.COIN()) + if offer.was_sent: data['auto_accept'] = 'True' if offer.auto_accept_bids else 'False' diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index 8ae4b3e..0ae458b 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -111,6 +111,10 @@ class BTCInterface(CoinInterface): def compareFeeRates(a, b): return abs(a - b) < 20 + @staticmethod + def xmr_swap_alock_spend_tx_vsize(): + return 147 + def __init__(self, coin_settings, network): super().__init__() self.rpc_callback = make_rpc_func(coin_settings['rpcport'], coin_settings['rpcauth'], host=coin_settings['rpchost']) @@ -409,7 +413,7 @@ class BTCInterface(CoinInterface): witness_bytes = len(script_lock) witness_bytes += 33 # sv, size - witness_bytes += 73 * 2 # 2 signatures (72 + 1 byts size) + witness_bytes += 73 * 2 # 2 signatures (72 + 1 byte size) witness_bytes += 4 # 1 empty, 1 true witness stack values witness_bytes += getCompactSizeLen(witness_bytes) vsize = self.getTxVSize(tx, add_witness_bytes=witness_bytes) diff --git a/basicswap/interface_part.py b/basicswap/interface_part.py index 69c42d6..cce82c1 100644 --- a/basicswap/interface_part.py +++ b/basicswap/interface_part.py @@ -31,6 +31,10 @@ class PARTInterface(BTCInterface): def txVersion(): return 0xa0 + @staticmethod + def xmr_swap_alock_spend_tx_vsize(): + return 213 + def __init__(self, coin_settings, network): self.rpc_callback = make_rpc_func(coin_settings['rpcport'], coin_settings['rpcauth'], host=coin_settings['rpchost']) self.txoType = CTxOutPart diff --git a/basicswap/templates/offer.html b/basicswap/templates/offer.html index a24ec3c..9efbe74 100644 --- a/basicswap/templates/offer.html +++ b/basicswap/templates/offer.html @@ -42,7 +42,7 @@
{% if data.show_bid_form %}

New Bid

-

You will send {{ data.amt_to }} {{ data.tla_to }} and receive {{ data.amt_from }} {{ data.tla_from }}

+

You will send {{ data.amt_to }} {{ data.tla_to }} and receive {{ data.amt_from }} {{ data.tla_from }} (excluding {{ data.amt_from_lock_spend_tx_fee }} {{ data.tla_from }} in tx fees).

Send From Address -

Bids

diff --git a/basicswap/templates/offer_confirm.html b/basicswap/templates/offer_confirm.html index 2978859..0ba9398 100644 --- a/basicswap/templates/offer_confirm.html +++ b/basicswap/templates/offer_confirm.html @@ -23,15 +23,16 @@ {% if data.swap_style == 'xmr' %} - - - + + + {% endif %} {% if data.swap_style == 'xmr' and coin_to != '6' %} - - - + + {% if data.swap_style == 'xmr' %} - - + {% if data.swap_style == 'xmr' and coin_to != '6' %} - - +
Bid IDBid AmountBid StatusITX StatusPTX Status
Amount FromThe amount you will send.
Fee Rate FromFee Rate Source{{ data.from_fee_src }}
Fee From Confirm Target
Fee From Extra Fee +
Fee Rate FromFee Rate Source{{ data.from_fee_src }}
Fee From Confirm Target
Fee From Increase By
Lock Tx Spend Fee{{ data.amt_from_lock_spend_tx_fee }} {{ data.tla_from }}
Coin To @@ -42,9 +43,9 @@ Amount ToThe amount you will receive.
Fee Rate ToFee Rate Source{{ data.to_fee_src }}
Fee To Confirm Target
Fee To Extra Fee +
Fee Rate ToFee Rate Source{{ data.to_fee_src }}
Fee To Confirm Target
Fee To Increase By Amount FromThe amount you will send.
Fee From Confirm Target
Fee From Extra Fee +
Fee From Confirm Target
Fee From Increase By Amount ToThe amount you will receive.
Fee To Confirm Target
Fee To Extra Fee +
Fee To Confirm Target
Fee To Increase By